How we route between Claude models: the cost / context / quality triangle | Claude Code Toolkit
Technical Decisions

How we route between Claude models: the cost / context / quality triangle

Not every task needs Opus. Not every task can survive Haiku. A framework and specific numbers from three months of production routing.

MK
Mubashir K. September 2, 2026 · 10 min read

When you build with a single-model mindset — "just call Sonnet for everything" — you leave money and speed on the table. When you route across models by task type, you often get better quality and lower cost, because different jobs really do fit different models.

This post is our routing framework and the numbers we track. We've been running it in production for three months across roughly 40 slash commands, 12 subagents, and a couple of CI-based automations. It's not a science; there's judgment involved. But the framework holds up.

The triangle

Every task sits somewhere on three axes. Cost — how much you'll spend, especially at scale. Context — how much information the task needs to see. Quality — how much correctness and reasoning depth matters. Pick a model based on where the task actually sits, not where you assume it sits.

The trap: teams anchor on quality because "we want the best." But most tasks don't need frontier quality. And frontier models on high-context tasks are expensive at scale — routing matters.

Most tasks don't need frontier quality. Route what needs it to Opus. Route the rest to Haiku or Sonnet and spend the savings on more iterations.

Where each model fits, from our data

Here's our current routing, with the reasoning behind it. Prices are directional; the ratios matter more than the absolute numbers.

  • Haiku — classification, extraction, formatting, structured output where the task is clear and the schema tight. Sub-second responses; cheap enough that we don't think about cost at typical scales. Weakness: complex reasoning, ambiguous input, multi-step tasks.
  • Sonnet — the default. Code writing, code review, refactoring, most agent work, most subagent tasks. Strong general-purpose quality; balanced cost. Weakness: cutting-edge reasoning, deep math, the hardest coding problems.
  • Opus — architecture decisions, ambiguous debugging, complex refactors touching many concerns, senior-review-level judgment. Expensive; slow. Use when the wrong answer costs more than the model does.

How our commands route today

Concrete list. Categorized by which model each command uses by default. This isn't exhaustive — we run about 40 total — but it's representative.

Routing map (illustrative subset)
HAIKU (fast, cheap, tight-schema):
  /extract-todos          Scan file for TODO comments, categorize.
  /commit-message         Generate a conventional-commit message.
  /rename-var             Rename a variable, respecting scope.
  /categorize-error       Classify an error message.
  /format-json            Format and validate JSON blob.

SONNET (most work):
  /test-unit              Write unit tests for a file.
  /refactor-extract       Extract a function.
  /pr-review              Review a pull request diff.
  /debug                  Debug a failing test.
  /migrate-endpoint       Migrate an endpoint to new pattern.

OPUS (senior judgment):
  /architect              Draft an architecture decision (ADR).
  /investigate-incident   Root-cause a production issue.
  /refactor-cross-cutting Big refactor touching many concerns.
  /audit-security         Audit code for security issues.

The context axis, which people forget

Cost and quality get talked about. Context often doesn't. It matters.

Some tasks need to see a lot — a whole subsystem, several files, historical context. If you're passing 100K tokens into every call, cost scales differently and prompt-caching becomes essential. If you're passing 2K tokens, none of that matters.

Our rule: if the task typically loads under 5K tokens of context, cost is dominated by model choice. If it loads over 30K tokens, cost is dominated by context (and by whether you're using prompt caching). Between 5K and 30K, both matter and it's task-specific.

Prompt caching changes the math

If you're making many calls with the same large context (running Claude over the same codebase repeatedly), prompt caching can cut costs by 90%+. This shifts the "when is Opus affordable" calculation significantly for repeat workloads.

Quality thresholds — how we decide

This is the fuzziest axis and the one we still argue about internally. Our heuristic is a two-question test: what's the cost of a wrong answer? and how detectable is a wrong answer?

High cost of wrong + low detectability = must use Opus (or Sonnet with human review). Example: architecture decisions. A bad ADR shapes months of work. And the "badness" won't be obvious for weeks.

Low cost of wrong + high detectability = Haiku is fine. Example: commit message generation. If it's wrong, the human just rewrites it. Cost is 10 seconds. Detectability is instant.

Middle cases = Sonnet, usually. Which is why Sonnet handles the majority.

What routing does to cost and time

Numbers from our team, three months in:

  • Total API cost down about 45% vs "always Sonnet" baseline. Most of the savings came from Haiku catching a lot of what used to be Sonnet work.
  • Median response time down about 30%. The Haiku commands are noticeably faster; the Opus commands are noticeably slower but represent maybe 5% of calls.
  • Perceived quality up, in weekly team surveys. Interesting: the routing to Opus for judgment-calls seems to be doing real work. Not because Sonnet is bad at architecture, but because "architect" tasks benefit from the deeper reasoning meaningfully.
  • What didn't change: reliability. All three models are reliable in our workloads; no model tier gives us more outages or weird failures than another.

Where we still get it wrong

Two ongoing questions. First, we sometimes over-route to Haiku for cost savings and then feel the quality hit for a week before catching it. We now have a monthly review: pull 10 random Haiku outputs, have someone senior grade them. If quality dropped, revisit the routing.

Second, we under-use Opus. It's tempting to save money by picking Sonnet for a judgment call, and sometimes we regret that specifically. Opus for ADRs is worth it. Opus for post-mortem writing is probably worth it. Opus for pair-programming a hard bug is probably worth it. We're still calibrating.

The framework in one paragraph

Route by task shape, not by team preference. Haiku for structured, fast, tight tasks. Sonnet for general work — code, review, refactor, most agent runs. Opus for judgment, ambiguity, and tasks where the wrong answer is expensive and slow to detect. Watch the numbers monthly; adjust when quality drifts. Use prompt caching for repeat-context workloads. Don't default to "always the best" — the "best" answer isn't always worth its cost, and forcing everything through one model wastes both money and speed.

MK

Written by

Mubashir K.

Mubashir writes about testing, refactoring, and the CLI workflows that keep Claude Code teams shipping.

Get cctk running in one command

85 slash commands, 12 subagents, 12 MCP integrations, 12 hooks. All the patterns from this post are shipped in cctk.

npx cctk@latest init Get cctk v1.5.2 →