Create Interactive AI Tools with Claude Code's AskUserQuestion

John Lindquist
InstructorJohn Lindquist

Social Share Links

Tweet

AI interactions are often a one-way street: you give a prompt, and the AI responds. But what if the AI needs your input to clarify instructions, gather preferences, or decide on the next step? This is where Claude's built-in AskUserQuestion tool becomes essential.

This lesson explores this foundational, internal tool that allows the AI to pause its execution and ask the user a series of questions. You'll learn that while you can't build your own version of this tool, you can completely transform its behavior with a custom system prompt. By providing a new persona and instructing the agent to only use AskUserQuestion, you can create highly specialized, interactive tools—turning a generic coding assistant into a life coach, a project planner, or any other guided experience you can imagine.

Workflow demonstrated in this lesson:

  • Understand the Tool: Review the AskUserQuestion.md definition to see its purpose and capabilities.
  • Direct Invocation: Run the AskUserQuestion tool directly to see its default behavior as a coding assistant.
  • Custom Persona: Use a system prompt to give the agent a new role, such as "You're a life coach."
  • Force Tool Usage: Instruct the agent to only use the AskUserQuestion tool to fulfill its role.
  • Interactive Experience: Engage with the new, multi-step questionnaire that the agent creates based on its new persona, demonstrating how to build guided workflows.

Key benefits:

  • Create Guided Experiences: Build interactive tools that walk users through a series of choices.
  • Clarify Ambiguity: Allow the agent to ask for more information when instructions are unclear.
  • Gather User Preferences: Design workflows that adapt based on user input and requirements.
  • Build Beyond Code: See how foundational tools can be used for applications outside of software development.

Summary

This lesson teaches you how to use Claude's powerful, built-in AskUserQuestion tool to create interactive, multi-step experiences. You will learn that this tool is a foundational component that allows an AI agent to pause and ask for user input. The video demonstrates how a custom system prompt can completely transform the tool's behavior, turning a generic coding assistant into a specialized "life coach" that guides the user through a series of questions. This showcases the versatility of the tool for building guided workflows and interactive applications beyond just writing code.

Prompts

Use the AskUserQuestion tool
I'm stuck. Please help me figure out what to do next in life using only the AskUserQuestion tool

Terminal Commands

claude
claude --system-prompt "You're a life coach" --model haiku "I'm stuck. Please help me figure out what to do next in life using only the AskUserQuestion tool"

Code Snippets

The AskUserQuestion.md file defines the purpose and usage of this foundational tool.

# AskUserQuestion

## Description

Use this tool when you need to ask the user questions during execution. This allows you to:
1. Gather user preferences or requirements
2. Clarify ambiguous instructions
3. Get decisions on implementation choices as you work
4. Offer choices to the user about what direction to take.

Usage notes:
- Users will always be able to select "Other" to provide custom text input
- Use multiSelect: true to allow multiple answers to be selected for a question

[00:00] I've listed all of the available built-in Clod code tools, starting with the Ask User Question tool. These tools are internal to Clod code, so you can't build your own. These are essentially the foundation that everything else is built upon. For example, if I start a session of Cloud and I say use the ask user question tool, you'll see it'll automatically start thinking and switch over into this mode of the most generic thing I could essentially think of based on its system prompt that it is a coding assistant. So you can go through here, select your options, and once you're ready it'll ask you to submit before it continues.

[00:39] And then the Ask User Question tool will be done. So if I submit this we don't really know what's going to happen next, but you'll notice that this time it did not use the Ask User Question tool because we're not in this interactive question mode. So I'm going to exit out of this and as a even better example let's build up something that looks like Claude with a system prompt of you're a life coach. We'll set the model to haiku for speed and we'll just have the prompt be I'm stuck please help me figure out what to do next in life using only the ask user question tool. So if I let this run, we've now essentially built this life coach tool, which will continuously present us this series of questions.

[01:26] So from the options, I will tap four for life direction, for how long, I'll select two just by tapping two. For the goal, let's three make a specific decision by tapping 3. I'll submit the answers and then it'll prompt us back in this ask user question. So let's say 4, I'm overwhelmed by options, and don't worry about me, I'm just picking these at random. And let's go 3 practical constraints, hit enter, and you can go on and on with this brand new tool that we've built, where Cloud is now prompting you, and it's up to you to make the decisions from the list of options to figure out the way forward.

[02:04] So there are numerous applications with this outside of just writing code if you want to build some simple tools for yourself, but it's also extremely useful for many scenarios where you're creating mini plans and you want to build little tools where you know there are a ton of options and you prefer a guided experience rather than just letting Claude do its thing.