Every model in the Claude 5 family can write code, but "which one is best for coding" is the wrong question — the better one is "best for which coding task." Sonnet 5 handles the bulk of day-to-day development at a fraction of Opus 5's price. Opus 5 is worth the premium specifically on large, ambiguous refactors where a wrong first attempt costs real time. Fable 5 is built for the kind of long, unsupervised coding run that doesn't fit a normal working session at all. And Haiku 4.5 still has a legitimate role for fast, narrow generation inside a bigger pipeline. The right setup for most teams uses at least two of these, not one.
How it works: matching model to task size
The deciding factor isn't "how good is this model at coding" in the abstract — every current-generation Claude model is good at coding. It's how expensive a wrong or incomplete answer is on this specific task, and how long the task genuinely needs to run unsupervised. A quick bug fix and an overnight repo migration are both "coding," but they have almost nothing in common as far as model selection goes.
Coding task to model mapping
| Coding task |
Best fit |
Why |
| Single-file edits, small bug fixes |
Sonnet 5 |
Fast and typically correct on the first pass; no reason to pay more |
| Day-to-day feature work, agent loops under ~20 steps |
Sonnet 5 at high or xhigh effort |
Closes most of the gap to Opus 5 at a third of the price |
| Multi-file refactors across a large repo |
Opus 5 |
Higher tolerance for ambiguity, fewer redo cycles |
| Repo-scale code review and bug-finding |
Opus 5 |
Strong precision and recall on real bugs, holds up at lower effort too |
| Overnight or multi-hour autonomous coding sessions |
Fable 5 |
Built for long, self-verifying runs on a well-specified task |
| Boilerplate generation, simple completions, linting-adjacent tasks |
Haiku 4.5 |
Cheap and fast for narrow, well-scoped generation inside a pipeline |
Building the actual coding setup
- Default to Sonnet 5. Route standard development work here first, and only escalate a specific request when it demonstrably needs more.
- Escalate to Opus 5 on failure or scope. If Sonnet 5 hedges, produces an inconsistent plan, or the task spans a large, unfamiliar part of the codebase, move that specific request up a tier instead of defaulting the whole pipeline there.
- Reserve Fable 5 for genuinely long, autonomous work. A well-specified multi-hour migration or a from-scratch implementation of a documented spec is a reasonable candidate; a normal pull request is not.
- Use Haiku 4.5 for the narrow, high-volume slice. Autocomplete-style generation, simple boilerplate, and tasks with a tightly bounded scope don't need a reasoning-heavy model at all.
- Run these through an actual agent harness, not a single completion call. Tools like the Claude Agent SDK or an editor integration give the model the ability to read files, run tests, and iterate — which matters more for coding quality than the model choice alone in many cases.
Common mistakes
- Defaulting every coding task to Opus 5. It's the safer-feeling choice, but for most requests Sonnet 5 at a higher effort level gets the same result for less money and less latency.
- Running Fable 5 for routine pull requests. Its strengths are long-horizon coherence and first-shot completeness on hard, well-specified tasks — a small, well-understood change doesn't benefit from either.
- Skipping effort tuning. Raising a model's effort level is often a cheaper way to close a quality gap than switching to a more expensive model entirely.
- Ignoring the harness. A capable model given only a single prompt and no ability to run tests or read surrounding files will underperform the same model wired into a proper coding agent loop.
FAQ
Is Opus 5 always better than Sonnet 5 for coding?
Not on every task. Sonnet 5 closed most of the gap this generation, and for the majority of day-to-day coding it's the more efficient choice at a comparable quality bar.
When is Fable 5 actually worth it for coding specifically?
When the task is genuinely long-horizon and well-specified — think an overnight migration or a from-scratch build against a clear spec — rather than iterative back-and-forth development.
Does Haiku 4.5 have a real place in a coding pipeline?
Yes, for the narrow slice of fast, well-scoped generation — simple completions, boilerplate, and tasks that don't need multi-step reasoning.
What's the single biggest lever for better coding results?
Matching effort level and model tier to the actual task, and giving the model a real harness with file access and test execution rather than a single isolated prompt.
Where to go next
For the full model-selection framework beyond coding, see Sonnet 5 vs Opus 5 for real workloads. If you're building the harness that actually runs these models against your codebase, read what the Claude Agent SDK enables for developers, or compare editor options in how to use the Cursor AI editor.