Feature Request: Add model selection support for custom commands (similar to subagents)
Feature Request: Add model selection support for custom commands (similar to subagents)
Summary
With the recent addition of model customization support for subagents, I'd like to request similar functionality for custom commands (slash commands in .claude/commands/). This would allow users to specify which Claude model should be used when executing specific custom commands, enabling more cost-effective and performance-optimized workflows.
Background
According to the recent changelog, subagents now support model customization:
"Agents: Added model customization support - you can now specify which model an agent should use"
This is a fantastic addition that addresses the need for granular model control expressed in several issues (#2532, #1457, #4377, #4807). However, custom commands currently don't have similar functionality.
Problem
Currently, all custom commands use the same model that's set globally via /model or the default model configuration. This creates several limitations:
- Cost inefficiency: Simple utility commands that could work well with Sonnet are forced to use Opus if that's the global setting
- Performance mismatch: Complex analytical commands might need Opus but are stuck with Sonnet if that's the global preference
- Workflow fragmentation: Users must manually switch models before running specific commands, breaking flow
-
Team consistency: Shared custom commands in
.claude/commands/can't enforce their optimal model requirements
Proposed Solution
Add an optional model parameter to custom command configuration, similar to how subagents now work. This could be implemented in several ways:
Option 1: Frontmatter in Markdown files
---
name: code-review
description: Perform detailed code review with best practices
model: opus
---
You are a senior code reviewer. Analyze the provided code for...
Option 2: Special comment syntax
<!-- model: sonnet -->
# Quick Documentation Generator
You are a documentation specialist. Generate concise docs for...
Option 3: TOML-style configuration (similar to Issue #4370)
[metadata]
model = "opus"
description = "Complex system architecture analysis"
[command]
prompt = """
You are a system architect...
"""
Use Cases
Cost Optimization
-
/quick-docs→ Sonnet (fast, cost-effective for simple tasks) -
/architecture-review→ Opus (complex analysis requiring deep reasoning) -
/code-format→ Sonnet/Haiku (simple formatting tasks)
Performance Optimization
-
/debug-complex→ Opus (needs deep problem-solving) -
/generate-tests→ Sonnet (structured, predictable output) -
/explain-code→ Sonnet (good at explanations, cost-effective)
Team Workflows
# Team can create specialized commands with guaranteed model usage
/security-audit # Always uses Opus for thorough security analysis
/quick-refactor # Always uses Sonnet for speed and cost efficiency
/deep-analysis # Always uses Opus for complex problem-solving
Implementation Suggestions
- Fallback behavior: If no model is specified, use the current global model setting
- Model validation: Validate that specified models are available and accessible
-
Override capability: Allow temporary override with syntax like
/command --model=sonnet - Documentation: Update custom command docs to show model selection examples
- Consistency: Use the same model names/syntax as subagents for consistency
Benefits
- Cost Control: Users can optimize costs by using appropriate models for each task type
- Performance: Match model capabilities to command requirements
- Team Efficiency: Shared commands automatically use their optimal models
- User Experience: Eliminates need to manually switch models before running commands
- Consistency: Aligns with the new subagent model selection functionality
Related Issues
- #2532 - Model Selection of Sub Agents
- #1457 - Feature Request: Instruct Model use for Subagents
- #4377 - Feature Request: Add Optional Model Parameter to Sub-Agents
- #4807 - New Rate Limits Require Granular Model Selection for Cost-Effective Usage
- #4370 - Feature Request: Formalize Custom Slash Commands with Structured Definitions
Priority
With the upcoming rate limits mentioned in #4807, granular model control becomes increasingly important for professional Claude Code usage. Having this functionality for custom commands would complement the existing subagent model selection and provide users with comprehensive control over their model usage patterns.
This feature would make custom commands much more powerful and align them with the excellent model selection capabilities now available for subagents.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/4370
- https://github.com/anthropics/claude-code/issues/4637
- https://github.com/anthropics/claude-code/issues/1327
If your issue is a duplicate, please close it and 👍 the existing issue instead.
🤖 Generated with Claude Code
This would be very useful. It already seems to be a documented feature, but it doesn't work yet.
With model: opus, I get this message:
Claude Opus 4 is not available with the Claude Pro plan. If you have updated your subscription plan recently, run /logout and /login
for the plan to take effect.
That persists after the logout/login, even with a max sub that hasn't used up its Opus 5-hour quota.
With model: sonnet or model: haiku, I get this message:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"system: Invalid model name"}}
So in addition to being a useful feature request, it's also a bug with the current doc.
model: claude-sonnet-4-0 and model: claude-3-5-haiku-latest is working.
See https://docs.anthropic.com/en/docs/about-claude/models/overview#model-aliases
But it's related to https://github.com/anthropics/claude-code/issues/4910 I think
This would be a big help! Seems silly wasting Opus 4.5 on menial commands when Haiku would be best placed
EDIT: model: claude-haiku-4-5 seems to work in the frontmatter. So...thanks!! Not sure if this is well documented though.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I absolutely would want this, it'd be a huge help...
I've asked claude code to analyze the minified claude code for the latest version, and to check what it looks at/interprets in the top of command files, and here's what it found:
● Based on my analysis of the Claude Code CLI's minified JavaScript file at /home/arthur/.nvm/versions/node/v22.20.0/lib/node_modules/@anthropic-ai/claude-code/cli.js, here's what I found regarding frontmatter parsing in custom command files:
Frontmatter Fields Parsed
Claude Code does parse frontmatter from .md files in ~/.claude/commands/. The following fields are recognized:
Core Fields:
┌───────────────────────────┬────────────────────────────────────────────────────────────────────────────┐
│ Field │ Purpose │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ allowed-tools │ List of tools the command can use (can be string or array) │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ description │ Description of the command │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ argument-hint │ Hint for arguments the command accepts │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ when-to-use / when_to_use │ Describes when the command should be used │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ model │ Which model to use (inherit means inherit from parent, or specify a model) │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ disable-model-invocation │ Boolean to disable model invocation │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ version │ Version of the command │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ name │ Name of the command │
├───────────────────────────┼────────────────────────────────────────────────────────────────────────────┤
│ skills │ Related skills for the command │
└───────────────────────────┴────────────────────────────────────────────────────────────────────────────┘
Example Frontmatter:
---
allowed-tools:
- Bash
- Read
- Write
description: My custom command
argument-hint: <filename>
when-to-use: Use this when you need to...
model: inherit
disable-model-invocation: false
version: 1.0.0
name: my-command
---
Notes:
1. The allowed-tools field can be either a string (comma-separated) or an array
2. The model value "inherit" means it uses the parent context's model
3. disable-model-invocation affects whether the model can be invoked directly
4. The parser also supports the SKILL.md pattern in subdirectories for skill-based commands
5. The $ARGUMENTS placeholder in command content is replaced with actual arguments passed to the command
✻ Baked for 3m 29s
─────────────────────────────────────────────────────────────────────────────────────────────────────────
So it looks like you can in fact set up a model modifier in your "command" md files, it's just not documented...
Here's what that would look like:
● Write(~/.claude/commands/haiku.md)
⎿ Wrote 8 lines to ../../../.claude/commands/haiku.md
---
description: Run a prompt with Claude Haiku (fast, cost-effective)
argument-hint: <your prompt>
model: claude-haiku-4-5-20251001
---
$ARGUMENTS
● Write(~/.claude/commands/sonnet.md)
⎿ Wrote 8 lines to ../../../.claude/commands/sonnet.md
---
description: Run a prompt with Claude Sonnet (balanced)
argument-hint: <your prompt>
model: claude-sonnet-4-20250514
---
$ARGUMENTS
● Write(~/.claude/commands/opus.md)
⎿ Wrote 8 lines to ../../../.claude/commands/opus.md
---
description: Run a prompt with Claude Opus (most capable)
argument-hint: <your prompt>
model: claude-opus-4-5-20251101
---
$ARGUMENTS
Tested it, and it actually works:
❯ /haiku 2+2
● I'll help you with that calculation using Claude Haiku.
● /haiku
● 2 + 2 = 4
❯ how do I make sure this command was actually run with "haiku"? can you check the "jsonl" file in ~/.claude/ for this session?
● Search(pattern: "~/.claude/**/*.jsonl")
⎿ Found 0 files
● Bash(ls -la ~/.claude/projects/ 2>/dev/null | head -20)
⎿ total 1688
drwxrwxr-x 287 arthur arthur 20480 Jan 9 01:17 .
drwxrwxr-x 20 arthur arthur 4096 Jan 9 01:24 ..
… +17 lines (ctrl+o to expand)
● Bash(ls -lat ~/.claude/projects/-home-arthur-dev-ai-<super secret claude code project>/ | head -20)
⎿ total 1214064
-rw------- 1 arthur arthur 20469 Jan 9 01:24 29b7101c-d4b1-4516-800b-97d668d67416.jsonl
-rw------- 1 arthur arthur 2451298 Jan 9 01:24 402b7aea-c484-4ed4-97c5-4fff4df8a5d5.jsonl
… +17 lines (ctrl+o to expand)
● The most recent session file is 29b7101c-d4b1-4516-800b-97d668d67416.jsonl. Let me check it for the haiku model usage.
● Bash(cat ~/.claude/projects/-home-arthur-dev-ai-<super secret claude code project>/29b7101c-d4b1-4516-800b-97d668d67416.jsonl | jq -c 'select(.model != null) | {model: .model, type: .type}…)
⎿ {
"type": "summary",
"summary": "Remove compaction detection instance restart feature",
… +898 lines (ctrl+o to expand)
● I can confirm from the session log that the /haiku 2+2 command was indeed run with Claude Haiku. Here's the evidence:
1. Model in assistant messages: "model":"claude-haiku-4-5-20251001" - this appears in the entries where the calculation was performed
2. Tool result confirmation: The Skill tool result includes "model":"claude-haiku-4-5-20251001" in the toolUseResult field
3. For comparison: My current messages (checking this log file) show "model":"claude-opus-4-5-20251101" - that's Opus, the main model handling this conversation
So the skill system correctly switched to Haiku for that calculation, then switched back to Opus for subsequent messages.
✻ Worked for 32s
TL;DR for the Anthropic folks: This is actually a feature, it's just not documented.
Wait, uh, now that skills and commands are merged, does model: still work?
it does, just checked by using claude code to decompile claude code. but yeah it'd be great if this was documented.
On Tue, Jan 27, 2026 at 10:33 PM Alexander Riccio @.***> wrote:
ariccio left a comment (anthropics/claude-code#4937) https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384
Wait, uh, now that skills and commands are merged, does model: still work?
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2SFNDWBGBBGGOTLJMPHT4I7KSJAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBXGY2DKMZYGQ . You are receiving this because you commented.Message ID: @.***>
--
勇気とユーモア
Hehe as a total sidenote: what's your workflow to do that like these days? And does it work for the bun version too?
Sincerely, Alexander Riccio
"Change the world or go home." about.me/ariccio
http://about.me/ariccio If left to my own devices, I will build more. ⁂
On Tue, Jan 27, 2026, 7:48 PM Arthur Wolf @.***> wrote:
arthurwolf left a comment (anthropics/claude-code#4937) https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808333729 it does, just checked by using claude code to decompile claude code. but yeah it'd be great if this was documented.
On Tue, Jan 27, 2026 at 10:33 PM Alexander Riccio @.***> wrote:
ariccio left a comment (anthropics/claude-code#4937) < https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384>
Wait, uh, now that skills and commands are merged, does model: still work?
— Reply to this email directly, view it on GitHub < https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAA2SFNDWBGBBGGOTLJMPHT4I7KSJAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBXGY2DKMZYGQ>
. You are receiving this because you commented.Message ID: @.***>
--
勇気とユーモア
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808333729, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQLAZHASYFRSM2KWF6R6DT4JABPNAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBYGMZTGNZSHE . You are receiving this because you commented.Message ID: @.***>
I'm using the bun version, works fine.
I pretty much just tell Claude Code something like « find the .js file that gets run when I type "claude" in my terminal, then use sub-agents to decompile/de-minify it into useful typescript, with different files and classes as relevant, organize it like a normal coding project, just completely matching the "claude" minified javascript file. » Sometimes it'll stop before it's done (you know how claude be for very large/long tasks), I just tell it to continue, and it'll eventually manage.
It's pretty interesting to read the code, I was thinking of maybe publishing it on Github in a repo, but I'm not sure how that could be made to work from a license standpoint.
On Wed, Jan 28, 2026 at 1:59 AM Alexander Riccio @.***> wrote:
ariccio left a comment (anthropics/claude-code#4937) https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808364528 Hehe as a total sidenote: what's your workflow to do that like these days? And does it work for the bun version too?
Sincerely, Alexander Riccio
"Change the world or go home." about.me/ariccio
http://about.me/ariccio If left to my own devices, I will build more. ⁂
On Tue, Jan 27, 2026, 7:48 PM Arthur Wolf @.***> wrote:
arthurwolf left a comment (anthropics/claude-code#4937) < https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808333729>
it does, just checked by using claude code to decompile claude code. but yeah it'd be great if this was documented.
On Tue, Jan 27, 2026 at 10:33 PM Alexander Riccio @.***> wrote:
ariccio left a comment (anthropics/claude-code#4937) <
https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384>
Wait, uh, now that skills and commands are merged, does model: still work?
— Reply to this email directly, view it on GitHub <
https://github.com/anthropics/claude-code/issues/4937#issuecomment-3807645384>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/AAA2SFNDWBGBBGGOTLJMPHT4I7KSJAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBXGY2DKMZYGQ>
. You are receiving this because you commented.Message ID: @.***>
--
勇気とユーモア
— Reply to this email directly, view it on GitHub < https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808333729>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAQLAZHASYFRSM2KWF6R6DT4JABPNAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBYGMZTGNZSHE>
. You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/4937#issuecomment-3808364528, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2SFPRFE6MNC4YPKSORED4JACVNAVCNFSM6AAAAACC5FHDZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBYGM3DINJSHA . You are receiving this because you commented.Message ID: @.***>
--
勇気とユーモア