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.
Showing cached comments. Read the full discussion on GitHub ↗
11 Comments
Found 3 possible duplicate issues:
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:That persists after the logout/login, even with a max sub that hasn't used up its Opus 5-hour quota.
With
model: sonnetormodel: 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-0andmodel: claude-3-5-haiku-latestis 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-5seems 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
commandfiles, and here's what it found:So it looks like you can in fact set up a
modelmodifier in your "command"mdfiles, it's just not documented...Here's what that would look like:
Tested it, and it actually works:
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:
--
勇気とユーモア
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:
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:
--
勇気とユーモア
@cgaaf — model selection in custom commands is locked to sonnet/opus/haiku because the enum is hardcoded. I built claude-alias-patch that opens up the enum to accept any model alias registered via
ANTHROPIC_DEFAULT_*_MODELenv vars.After patching, your custom commands and agent definitions can use custom model names in frontmatter — not just the built-in three. Single install script, auto-patches your Claude instance.