Lesson

Create Interactive AI Tools with Claude Code's AskUserQuestion

Learn how to leverage Claude's built-in AskUserQuestion tool to transform one-way AI interactions into dynamic, multi-step guided experiences. This lesson demonstrates how a custom system prompt can turn this foundational tool into a specialized interactive application, like a life coach, for gathering user preferences and making decisions.

Access
Included
Transcript
Needs source

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