Allow AskUserQuestion to execute slash commands when user selects an option

Resolved 💬 3 comments Opened Dec 21, 2025 by apn-pn Closed Feb 14, 2026

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:

  1. User asks a question on Opus
  2. Claude detects it's a standard task (better suited for Sonnet)
  3. Claude suggests: "Please type /model sonnet"
  4. 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

  1. Seamless workflow - one click instead of typing
  2. Better eco-responsibility - easier to use the right model
  3. Proactive guidance - Claude can suggest optimal model without friction
  4. Reusable pattern - works for any slash command (/clear, /help, etc.)

Use Cases

  1. Model Switching

Claude detects complex task on Sonnet → offers Opus
Claude detects simple task on Opus → offers Haiku/Sonnet

  1. Other Commands

After implementation → offer "/commit" to create git commit
After many messages → offer "/clear" to start fresh
User confused → offer "/help" for documentation

  1. 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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗