General7 min read

Claude Code Model Selection: Use the Right AI for Every Task

model-selectionclaude-codeprompt-engineeringcost-optimization

Aliases, Not Model IDs

Claude Code lets you reference models by alias instead of full API ID. The aliases stay stable as Anthropic ships new versions, which means your scripts and slash commands keep working without code changes when the underlying model updates.

AliasResolves ToWhen to Use
defaultAccount default (usually Sonnet 4.6)Most tasks — let Claude Code decide
sonnetLatest Sonnet (4.6 today)Daily driver for writing code, tests, refactors
opusLatest Opus (4.7 today)Complex reasoning, hard debugging, architecture
haikuLatest Haiku (4.5 today)Review, formatting, log analysis, fast utility tasks
sonnet[1m]Sonnet 4.6 with 1M context windowLarge codebases that need the full window loaded
opusplanOpus for planning, Sonnet for executionMulti-file refactors, architectural changes, agent design

The Smart Routing Strategy

Default to Sonnet 4.6 for everything. It handles the bulk of real development work at a third of the cost of Opus and runs faster end to end. Escalate to opus when you hit a genuinely hard problem — a bug that does not match any obvious pattern, an architecture decision with multiple competing constraints, or a refactor that touches the structure of the system.

Reach for opusplan when the task has a clear planning phase followed by mechanical execution. The Opus model maps out the change, then Sonnet does the file edits. You get reasoning depth where it matters without paying Opus rates on the bulk of the token spend.

Use haiku for the unglamorous work: reviewing diffs, parsing log files, formatting JSON, drafting commit messages, scanning for obvious issues. Haiku 4.5 at $1/$5 per million tokens is so cheap that the cost vanishes from your bill — but it is sharp enough to catch real problems.

Cost Comparison by Routing Strategy

StrategyEffective $/Mtok InputRelative Cost
All Opus 4.7$5.001.00x (baseline)
All Sonnet 4.6$3.000.60x
Smart mix (80% Sonnet, 15% Opus, 5% Haiku)$3.200.64x
Aggressive (60% Haiku, 35% Sonnet, 5% Opus)$1.900.38x

Going from all Opus to smart routing saves about 36 percent. Going aggressive with Haiku for utility work saves over 60 percent. The quality of the work does not drop because each task is going to a model that handles it well.

Tactical Commands

# Start a session pinned to a specific model
claude --model sonnet
claude --model opus
claude --model haiku

# Switch mid-session
/model sonnet
/model haiku
/model opus

# Use the 1M context Sonnet variant
claude --model 'sonnet[1m]'

# Plan with Opus, execute with Sonnet
claude --model opusplan

Routing by Task Type

TaskRecommended Model
Writing a new function or testSonnet 4.6
Debugging a tricky issue across filesOpus 4.7
Reviewing a pull request diffHaiku 4.5
Multi-file refactoropusplan
Reading a 500K-token codebasesonnet[1m]
Drafting a commit messageHaiku 4.5
Architecture or schema designOpus 4.7
Generating test dataHaiku 4.5

The Discipline

The developers who get the most out of Claude Code are not the ones paying for the most expensive model. They are the ones who picked the right model for each task. The savings are real and the quality difference is invisible — because each piece of work landed at a model that handled it well.

Get Started with Claude Code

Start building with Claude Code today. Free to download, powerful enough for production.