Feature: Auto model routing by task type (plan → opus, code → sonnet, chat → haiku)
Problem
Power users burn significant tokens using expensive models (Opus) for tasks that don't need them. There's no way to automatically route to the right model based on what Claude Code is doing. Today, users must manually run /model opus, /model sonnet, /model haiku throughout a session — which is easy to forget, leading to Opus-level costs on routine file reads and simple edits.
Proposed Solution
Allow users to configure model routing rules based on task type or mode in settings.json:
{
"modelRouting": {
"plan": "claude-opus-4-6",
"code": "claude-sonnet-4-6",
"default": "claude-haiku-4-5"
}
}
Routing triggers
| Mode | Trigger | Suggested model |
|------|---------|----------------|
| plan | EnterPlanMode, architecture/design discussions | Most capable (Opus) |
| code | Edit, Write, Bash tool use, implementation work | Mid-tier (Sonnet) |
| default | Everything else — questions, exploration, chat | Cheapest (Haiku) |
How it could work
- When Claude Code enters plan mode → auto-switch to the configured
planmodel - When the first
Edit/Write/Bashtool call happens → switch tocodemodel - When exiting plan mode or between tasks → fall back to
defaultmodel - A status line indicator shows the current routing mode (e.g.,
[plan:opus],[code:sonnet]) - Users can still override with
/modelat any time
Alternative: Hook-based approach
If native routing is too opinionated, expose model switching to the hooks system:
{
"hooks": {
"PrePlanMode": [{ "type": "model", "model": "claude-opus-4-6" }],
"PostPlanMode": [{ "type": "model", "model": "claude-haiku-4-5" }],
"PreToolUse": [{
"type": "model",
"matcher": "Edit|Write|Bash",
"model": "claude-sonnet-4-6"
}]
}
}
This would let users build their own routing logic without Claude Code being opinionated about which model fits which task.
Why this matters
Real usage data from a power user (44 days, single account):
| Month | API-equivalent cost | Primary model |
|-------|-------------------|---------------|
| Feb 2026 | $1,217 | Opus |
| Mar 2026 | $2,965 | Mixed |
| Apr 2026 (7 days) | $1,307 | Opus |
| Total | $5,489 | |
Conservatively, 60-70% of those tokens were spent on tasks where Sonnet or Haiku would have been sufficient (file reads, simple edits, exploration, chat). Auto-routing could cut costs by $2,000-3,000/month for heavy users without any loss in output quality.
For organizations paying API rates, this is the difference between Claude Code being viable or not for a team.
Related
- Extends the existing
/modelcommand infrastructure - Complements the status line system (could show active routing mode)
- Addresses cost concerns raised in #33978, #18550, #41200
Environment
- Claude Code CLI on macOS
- Individual Claude Code user
- Heavy agent teams usage (multiplies the cost problem)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗