Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for developing custom slash commands for Claude Code plugins from the official Anthropic repository.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/interactive-commands.md
1# Interactive Command Patterns23Comprehensive guide to creating commands that gather user feedback and make decisions through the AskUserQuestion tool.45## Overview67Some commands need user input that doesn't work well with simple arguments. For example:8- Choosing between multiple complex options with trade-offs9- Selecting multiple items from a list10- Making decisions that require explanation11- Gathering preferences or configuration interactively1213For these cases, use the **AskUserQuestion tool** within command execution rather than relying on command arguments.1415## When to Use AskUserQuestion1617### Use AskUserQuestion When:18191. **Multiple choice decisions** with explanations needed202. **Complex options** that require context to choose213. **Multi-select scenarios** (choosing multiple items)224. **Preference gathering** for configuration235. **Interactive workflows** that adapt based on answers2425### Use Command Arguments When:26271. **Simple values** (file paths, numbers, names)282. **Known inputs** user already has293. **Scriptable workflows** that should be automatable304. **Fast invocations** where prompting would slow down3132## AskUserQuestion Basics3334### Tool Parameters3536```typescript37{38questions: [39{40question: "Which authentication method should we use?",41header: "Auth method", // Short label (max 12 chars)42multiSelect: false, // true for multiple selection43options: [44{45label: "OAuth 2.0",46description: "Industry standard, supports multiple providers"47},48{49label: "JWT",50description: "Stateless, good for APIs"51},52{53label: "Session",54description: "Traditional, server-side state"55}56]57}58]59}60```6162**Key points:**63- Users can always choose "Other" to provide custom input (automatic)64- `multiSelect: true` allows selecting multiple options65- Options should be 2-4 choices (not more)66- Can ask 1-4 questions per tool call6768## Command Pattern for User Interaction6970### Basic Interactive Command7172```markdown73---74description: Interactive setup command75allowed-tools: AskUserQuestion, Write76---7778# Interactive Plugin Setup7980This command will guide you through configuring the plugin with a series of questions.8182## Step 1: Gather Configuration8384Use the AskUserQuestion tool to ask:8586**Question 1 - Deployment target:**87- header: "Deploy to"88- question: "Which deployment platform will you use?"89- options:90- AWS (Amazon Web Services with ECS/EKS)91- GCP (Google Cloud with GKE)92- Azure (Microsoft Azure with AKS)93- Local (Docker on local machine)9495**Question 2 - Environment strategy:**96- header: "Environments"97- question: "How many environments do you need?"98- options:99- Single (Just production)100- Standard (Dev, Staging, Production)101- Complete (Dev, QA, Staging, Production)102103**Question 3 - Features to enable:**104- header: "Features"105- question: "Which features do you want to enable?"106- multiSelect: true107- options:108- Auto-scaling (Automatic resource scaling)109- Monitoring (Health checks and metrics)110- CI/CD (Automated deployment pipeline)111- Backups (Automated database backups)112113## Step 2: Process Answers114115Based on the answers received from AskUserQuestion:1161171. Parse the deployment target choice1182. Set up environment-specific configuration1193. Enable selected features1204. Generate configuration files121122## Step 3: Generate Configuration123124Create `.claude/plugin-name.local.md` with:125126\`\`\`yaml127---128deployment_target: [answer from Q1]129environments: [answer from Q2]130features:131auto_scaling: [true if selected in Q3]132monitoring: [true if selected in Q3]133ci_cd: [true if selected in Q3]134backups: [true if selected in Q3]135---136137# Plugin Configuration138139Generated: [timestamp]140Target: [deployment_target]141Environments: [environments]142\`\`\`143144## Step 4: Confirm and Next Steps145146Confirm configuration created and guide user on next steps.147```148149### Multi-Stage Interactive Workflow150151```markdown152---153description: Multi-stage interactive workflow154allowed-tools: AskUserQuestion, Read, Write, Bash155---156157# Multi-Stage Deployment Setup158159This command walks through deployment setup in stages, adapting based on your answers.160161## Stage 1: Basic Configuration162163Use AskUserQuestion to ask about deployment basics.164165Based on answers, determine which additional questions to ask.166167## Stage 2: Advanced Options (Conditional)168169If user selected "Advanced" deployment in Stage 1:170171Use AskUserQuestion to ask about:172- Load balancing strategy173- Caching configuration174- Security hardening options175176If user selected "Simple" deployment:177- Skip advanced questions178- Use sensible defaults179180## Stage 3: Confirmation181182Show summary of all selections.183184Use AskUserQuestion for final confirmation:185- header: "Confirm"186- question: "Does this configuration look correct?"187- options:188- Yes (Proceed with setup)189- No (Start over)190- Modify (Let me adjust specific settings)191192If "Modify", ask which specific setting to change.193194## Stage 4: Execute Setup195196Based on confirmed configuration, execute setup steps.197```198199## Interactive Question Design200201### Question Structure202203**Good questions:**204```markdown205Question: "Which database should we use for this project?"206Header: "Database"207Options:208- PostgreSQL (Relational, ACID compliant, best for complex queries)209- MongoDB (Document store, flexible schema, best for rapid iteration)210- Redis (In-memory, fast, best for caching and sessions)211```212213**Poor questions:**214```markdown215Question: "Database?" // Too vague216Header: "DB" // Unclear abbreviation217Options:218- Option 1 // Not descriptive219- Option 2220```221222### Option Design Best Practices223224**Clear labels:**225- Use 1-5 words226- Specific and descriptive227- No jargon without context228229**Helpful descriptions:**230- Explain what the option means231- Mention key benefits or trade-offs232- Help user make informed decision233- Keep to 1-2 sentences234235**Appropriate number:**236- 2-4 options per question237- Don't overwhelm with too many choices238- Group related options239- "Other" automatically provided240241### Multi-Select Questions242243**When to use multiSelect:**244245```markdown246Use AskUserQuestion for enabling features:247248Question: "Which features do you want to enable?"249Header: "Features"250multiSelect: true // Allow selecting multiple251Options:252- Logging (Detailed operation logs)253- Metrics (Performance monitoring)254- Alerts (Error notifications)255- Backups (Automatic backups)256```257258User can select any combination: none, some, or all.259260**When NOT to use multiSelect:**261262```markdown263Question: "Which authentication method?"264multiSelect: false // Only one auth method makes sense265```266267Mutually exclusive choices should not use multiSelect.268269## Command Patterns with AskUserQuestion270271### Pattern 1: Simple Yes/No Decision272273```markdown274---275description: Command with confirmation276allowed-tools: AskUserQuestion, Bash277---278279# Destructive Operation280281This operation will delete all cached data.282283Use AskUserQuestion to confirm:284285Question: "This will delete all cached data. Are you sure?"286Header: "Confirm"287Options:288- Yes (Proceed with deletion)289- No (Cancel operation)290291If user selects "Yes":292Execute deletion293Report completion294295If user selects "No":296Cancel operation297Exit without changes298```299300### Pattern 2: Multiple Configuration Questions301302```markdown303---304description: Multi-question configuration305allowed-tools: AskUserQuestion, Write306---307308# Project Configuration Setup309310Gather configuration through multiple questions.311312Use AskUserQuestion with multiple questions in one call:313314**Question 1:**315- question: "Which programming language?"316- header: "Language"317- options: Python, TypeScript, Go, Rust318319**Question 2:**320- question: "Which test framework?"321- header: "Testing"322- options: Jest, PyTest, Go Test, Cargo Test323(Adapt based on language from Q1)324325**Question 3:**326- question: "Which CI/CD platform?"327- header: "CI/CD"328- options: GitHub Actions, GitLab CI, CircleCI329330**Question 4:**331- question: "Which features do you need?"332- header: "Features"333- multiSelect: true334- options: Linting, Type checking, Code coverage, Security scanning335336Process all answers together to generate cohesive configuration.337```338339### Pattern 3: Conditional Question Flow340341```markdown342---343description: Conditional interactive workflow344allowed-tools: AskUserQuestion, Read, Write345---346347# Adaptive Configuration348349## Question 1: Deployment Complexity350351Use AskUserQuestion:352353Question: "How complex is your deployment?"354Header: "Complexity"355Options:356- Simple (Single server, straightforward)357- Standard (Multiple servers, load balancing)358- Complex (Microservices, orchestration)359360## Conditional Questions Based on Answer361362If answer is "Simple":363- No additional questions364- Use minimal configuration365366If answer is "Standard":367- Ask about load balancing strategy368- Ask about scaling policy369370If answer is "Complex":371- Ask about orchestration platform (Kubernetes, Docker Swarm)372- Ask about service mesh (Istio, Linkerd, None)373- Ask about monitoring (Prometheus, Datadog, CloudWatch)374- Ask about logging aggregation375376## Process Conditional Answers377378Generate configuration appropriate for selected complexity level.379```380381### Pattern 4: Iterative Collection382383```markdown384---385description: Collect multiple items iteratively386allowed-tools: AskUserQuestion, Write387---388389# Collect Team Members390391We'll collect team member information for the project.392393## Question: How many team members?394395Use AskUserQuestion:396397Question: "How many team members should we set up?"398Header: "Team size"399Options:400- 2 people401- 3 people402- 4 people403- 6 people404405## Iterate Through Team Members406407For each team member (1 to N based on answer):408409Use AskUserQuestion for member details:410411Question: "What role for team member [number]?"412Header: "Role"413Options:414- Frontend Developer415- Backend Developer416- DevOps Engineer417- QA Engineer418- Designer419420Store each member's information.421422## Generate Team Configuration423424After collecting all N members, create team configuration file with all members and their roles.425```426427### Pattern 5: Dependency Selection428429```markdown430---431description: Select dependencies with multi-select432allowed-tools: AskUserQuestion433---434435# Configure Project Dependencies436437## Question: Required Libraries438439Use AskUserQuestion with multiSelect:440441Question: "Which libraries does your project need?"442Header: "Dependencies"443multiSelect: true444Options:445- React (UI framework)446- Express (Web server)447- TypeORM (Database ORM)448- Jest (Testing framework)449- Axios (HTTP client)450451User can select any combination.452453## Process Selections454455For each selected library:456- Add to package.json dependencies457- Generate sample configuration458- Create usage examples459- Update documentation460```461462## Best Practices for Interactive Commands463464### Question Design4654661. **Clear and specific**: Question should be unambiguous4672. **Concise header**: Max 12 characters for clean display4683. **Helpful options**: Labels are clear, descriptions explain trade-offs4694. **Appropriate count**: 2-4 options per question, 1-4 questions per call4705. **Logical order**: Questions flow naturally471472### Error Handling473474```markdown475# Handle AskUserQuestion Responses476477After calling AskUserQuestion, verify answers received:478479If answers are empty or invalid:480Something went wrong gathering responses.481482Please try again or provide configuration manually:483[Show alternative approach]484485Exit.486487If answers look correct:488Process as expected489```490491### Progressive Disclosure492493```markdown494# Start Simple, Get Detailed as Needed495496## Question 1: Setup Type497498Use AskUserQuestion:499500Question: "How would you like to set up?"501Header: "Setup type"502Options:503- Quick (Use recommended defaults)504- Custom (Configure all options)505- Guided (Step-by-step with explanations)506507If "Quick":508Apply defaults, minimal questions509510If "Custom":511Ask all available configuration questions512513If "Guided":514Ask questions with extra explanation515Provide recommendations along the way516```517518### Multi-Select Guidelines519520**Good multi-select use:**521```markdown522Question: "Which features do you want to enable?"523multiSelect: true524Options:525- Logging526- Metrics527- Alerts528- Backups529530Reason: User might want any combination531```532533**Bad multi-select use:**534```markdown535Question: "Which database engine?"536multiSelect: true // ❌ Should be single-select537538Reason: Can only use one database engine539```540541## Advanced Patterns542543### Validation Loop544545```markdown546---547description: Interactive with validation548allowed-tools: AskUserQuestion, Bash549---550551# Setup with Validation552553## Gather Configuration554555Use AskUserQuestion to collect settings.556557## Validate Configuration558559Check if configuration is valid:560- Required dependencies available?561- Settings compatible with each other?562- No conflicts detected?563564If validation fails:565Show validation errors566567Use AskUserQuestion to ask:568569Question: "Configuration has issues. What would you like to do?"570Header: "Next step"571Options:572- Fix (Adjust settings to resolve issues)573- Override (Proceed despite warnings)574- Cancel (Abort setup)575576Based on answer, retry or proceed or exit.577```578579### Build Configuration Incrementally580581```markdown582---583description: Incremental configuration builder584allowed-tools: AskUserQuestion, Write, Read585---586587# Incremental Setup588589## Phase 1: Core Settings590591Use AskUserQuestion for core settings.592593Save to `.claude/config-partial.yml`594595## Phase 2: Review Core Settings596597Show user the core settings:598599Based on these core settings, you need to configure:600- [Setting A] (because you chose [X])601- [Setting B] (because you chose [Y])602603Ready to continue?604605## Phase 3: Detailed Settings606607Use AskUserQuestion for settings based on Phase 1 answers.608609Merge with core settings.610611## Phase 4: Final Review612613Present complete configuration.614615Use AskUserQuestion for confirmation:616617Question: "Is this configuration correct?"618Options:619- Yes (Save and apply)620- No (Start over)621- Modify (Edit specific settings)622```623624### Dynamic Options Based on Context625626```markdown627---628description: Context-aware questions629allowed-tools: AskUserQuestion, Bash, Read630---631632# Context-Aware Setup633634## Detect Current State635636Check existing configuration:637- Current language: !`detect-language.sh`638- Existing frameworks: !`detect-frameworks.sh`639- Available tools: !`check-tools.sh`640641## Ask Context-Appropriate Questions642643Based on detected language, ask relevant questions.644645If language is TypeScript:646647Use AskUserQuestion:648649Question: "Which TypeScript features should we enable?"650Options:651- Strict Mode (Maximum type safety)652- Decorators (Experimental decorator support)653- Path Mapping (Module path aliases)654655If language is Python:656657Use AskUserQuestion:658659Question: "Which Python tools should we configure?"660Options:661- Type Hints (mypy for type checking)662- Black (Code formatting)663- Pylint (Linting and style)664665Questions adapt to project context.666```667668## Real-World Example: Multi-Agent Swarm Launch669670**From multi-agent-swarm plugin:**671672```markdown673---674description: Launch multi-agent swarm675allowed-tools: AskUserQuestion, Read, Write, Bash676---677678# Launch Multi-Agent Swarm679680## Interactive Mode (No Task List Provided)681682If user didn't provide task list file, help create one interactively.683684### Question 1: Agent Count685686Use AskUserQuestion:687688Question: "How many agents should we launch?"689Header: "Agent count"690Options:691- 2 agents (Best for simple projects)692- 3 agents (Good for medium projects)693- 4 agents (Standard team size)694- 6 agents (Large projects)695- 8 agents (Complex multi-component projects)696697### Question 2: Task Definition Approach698699Use AskUserQuestion:700701Question: "How would you like to define tasks?"702Header: "Task setup"703Options:704- File (I have a task list file ready)705- Guided (Help me create tasks interactively)706- Custom (Other approach)707708If "File":709Ask for file path710Validate file exists and has correct format711712If "Guided":713Enter iterative task creation mode (see below)714715### Question 3: Coordination Mode716717Use AskUserQuestion:718719Question: "How should agents coordinate?"720Header: "Coordination"721Options:722- Team Leader (One agent coordinates others)723- Collaborative (Agents coordinate as peers)724- Autonomous (Independent work, minimal coordination)725726### Iterative Task Creation (If "Guided" Selected)727728For each agent (1 to N from Question 1):729730**Question A: Agent Name**731Question: "What should we call agent [number]?"732Header: "Agent name"733Options:734- auth-agent735- api-agent736- ui-agent737- db-agent738(Provide relevant suggestions based on common patterns)739740**Question B: Task Type**741Question: "What task for [agent-name]?"742Header: "Task type"743Options:744- Authentication (User auth, JWT, OAuth)745- API Endpoints (REST/GraphQL APIs)746- UI Components (Frontend components)747- Database (Schema, migrations, queries)748- Testing (Test suites and coverage)749- Documentation (Docs, README, guides)750751**Question C: Dependencies**752Question: "What does [agent-name] depend on?"753Header: "Dependencies"754multiSelect: true755Options:756- [List of previously defined agents]757- No dependencies758759**Question D: Base Branch**760Question: "Which base branch for PR?"761Header: "PR base"762Options:763- main764- staging765- develop766767Store all task information for each agent.768769### Generate Task List File770771After collecting all agent task details:7727731. Ask for project name7742. Generate task list in proper format7753. Save to `.daisy/swarm/tasks.md`7764. Show user the file path7775. Proceed with launch using generated task list778```779780## Best Practices781782### Question Writing7837841. **Be specific**: "Which database?" not "Choose option?"7852. **Explain trade-offs**: Describe pros/cons in option descriptions7863. **Provide context**: Question text should stand alone7874. **Guide decisions**: Help user make informed choice7885. **Keep concise**: Header max 12 chars, descriptions 1-2 sentences789790### Option Design7917921. **Meaningful labels**: Specific, clear names7932. **Informative descriptions**: Explain what each option does7943. **Show trade-offs**: Help user understand implications7954. **Consistent detail**: All options equally explained7965. **2-4 options**: Not too few, not too many797798### Flow Design7998001. **Logical order**: Questions flow naturally8012. **Build on previous**: Later questions use earlier answers8023. **Minimize questions**: Ask only what's needed8034. **Group related**: Ask related questions together8045. **Show progress**: Indicate where in flow805806### User Experience8078081. **Set expectations**: Tell user what to expect8092. **Explain why**: Help user understand purpose8103. **Provide defaults**: Suggest recommended options8114. **Allow escape**: Let user cancel or restart8125. **Confirm actions**: Summarize before executing813814## Common Patterns815816### Pattern: Feature Selection817818```markdown819Use AskUserQuestion:820821Question: "Which features do you need?"822Header: "Features"823multiSelect: true824Options:825- Authentication826- Authorization827- Rate Limiting828- Caching829```830831### Pattern: Environment Configuration832833```markdown834Use AskUserQuestion:835836Question: "Which environment is this?"837Header: "Environment"838Options:839- Development (Local development)840- Staging (Pre-production testing)841- Production (Live environment)842```843844### Pattern: Priority Selection845846```markdown847Use AskUserQuestion:848849Question: "What's the priority for this task?"850Header: "Priority"851Options:852- Critical (Must be done immediately)853- High (Important, do soon)854- Medium (Standard priority)855- Low (Nice to have)856```857858### Pattern: Scope Selection859860```markdown861Use AskUserQuestion:862863Question: "What scope should we analyze?"864Header: "Scope"865Options:866- Current file (Just this file)867- Current directory (All files in directory)868- Entire project (Full codebase scan)869```870871## Combining Arguments and Questions872873### Use Both Appropriately874875**Arguments for known values:**876```markdown877---878argument-hint: [project-name]879allowed-tools: AskUserQuestion, Write880---881882Setup for project: $1883884Now gather additional configuration...885886Use AskUserQuestion for options that require explanation.887```888889**Questions for complex choices:**890```markdown891Project name from argument: $1892893Now use AskUserQuestion to choose:894- Architecture pattern895- Technology stack896- Deployment strategy897898These require explanation, so questions work better than arguments.899```900901## Troubleshooting902903**Questions not appearing:**904- Verify AskUserQuestion in allowed-tools905- Check question format is correct906- Ensure options array has 2-4 items907908**User can't make selection:**909- Check option labels are clear910- Verify descriptions are helpful911- Consider if too many options912- Ensure multiSelect setting is correct913914**Flow feels confusing:**915- Reduce number of questions916- Group related questions917- Add explanation between stages918- Show progress through workflow919920With AskUserQuestion, commands become interactive wizards that guide users through complex decisions while maintaining the clarity that simple arguments provide for straightforward inputs.921