Allow AskUserQuestion to execute slash commands when user selects an option
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Claude can detect when task complexity doesn't match the current model and should suggest switching. However, Claude cannot execute /model commands - it can only tell the user to type them manually.
Current workflow:
- User asks a question on Opus
- Claude detects it's a standard task (better suited for Sonnet)
- Claude suggests: "Please type
/model sonnet" - User must manually type the command
This would make Claude's eco-responsibility guidelines much more effective by removing friction from model switching based on task complexity.
Proposed Solution
Extend the AskUserQuestion tool to allow executing slash commands when the user selects an option.
Alternative Solutions
Pre-filling the prompt with the command - rejected because:
- Less discoverable (user doesn't see the options)
- Requires editing if user wants different choice
- Doesn't work well for multi-step decisions
Priority
Medium - Would be very helpful
Feature Category
Other
Use Case Example
Example: Model Selection
```typescript
AskUserQuestion({
questions: [{
question: "This is a standard implementation task. Which model to use?",
header: "Model",
multiSelect: false,
options: [
{
label: "Sonnet (Recommended)",
description: "Sufficient for this task - faster and eco-friendly",
command: "/model sonnet" // ← NEW: auto-execute on selection
},
{
label: "Stay on Opus",
description: "Continue with current model",
command: null // no command = no action
}
]
}]
})
When user selects "Sonnet (Recommended)", the /model sonnet command is automatically executed.
Benefits
- Seamless workflow - one click instead of typing
- Better eco-responsibility - easier to use the right model
- Proactive guidance - Claude can suggest optimal model without friction
- Reusable pattern - works for any slash command (/clear, /help, etc.)
Use Cases
- Model Switching
Claude detects complex task on Sonnet → offers Opus
Claude detects simple task on Opus → offers Haiku/Sonnet
- Other Commands
After implementation → offer "/commit" to create git commit
After many messages → offer "/clear" to start fresh
User confused → offer "/help" for documentation
- Custom Commands
Offer executing user's custom slash commands from .claude/commands/
Implementation Considerations
Security:
- Only execute slash commands, not arbitrary shell commands
- Show clear confirmation of what will be executed
- Allow user to cancel before execution
UX:
- Visual indicator when option includes a command (e.g., ⚡ icon)
- Show command that will run: "Sonnet (Recommended) → will run: /model sonnet"
API:
interface QuestionOption {
label: string;
description: string;
command?: string; // optional slash command to execute
confirmBefore?: boolean; // show confirmation dialog (default: false)
}
Additional Context
Related Issues
- #4823 - Display current model and shortcuts
- #4937 - Model selection for custom commands
- #6009 - Piping input to pre-populate prompt
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗