Which model to give each Claude Code subagent: how I split Opus and Sonnet
A subagent's model is set in the model field of its header: sonnet, opus, haiku, a full model ID, or inherit. Without that field, it runs on the same model as the conversation that starts it. My rule: the reviewer is always at least as strong as whoever wrote the code, the agent that writes the tests runs on Sonnet, and the agent that codes runs on Opus, except for a simple screen that needed no fix last time.
The problem: one model for different roles
In a chain of agents, the roles are not equally hard. Writing a test from a precise brief is well-bounded work. Writing code that touches a business rule means holding many constraints at once. Reviewing a diff you did not write means understanding what had to be done, then seeing what is missing.
If everything runs on the session's model, you pay full price for the easy tasks, or you hand the hard ones to a model that gets them wrong. Claude Code lets you set the model agent by agent. You still have to know which one goes where.
Where a subagent's model is set
A subagent is a Markdown file stored in .claude/agents/ for one project, in ~/.claude/agents/ for all your projects, or shipped in a plugin. How it differs from a skill is covered in the skills vs subagents article. The model is declared in the header, next to the tools. Here are the headers of two of my agents, shortened:
---
name: pipeline-v2-tests
tools: Read, Edit, Write, Bash, Grep, Glob
model: sonnet
---
---
name: pipeline-v2-code
tools: Read, Edit, Write, Bash, Grep, Glob
model: opus
---When several settings exist, the Claude Code documentation gives a precise order. The first one present wins:
- The `model` parameter passed when Claude starts the subagent. It only accepts an alias such as
sonnetoropus. - The `model` field in the header,
inheritincluded. - The `CLAUDE_CODE_SUBAGENT_MODEL` environment variable.
- The main conversation's model.
The first level is the most useful. It lets you keep a default in the header and change it for a single task, without touching the agent's file.
My split, and why it changed
In the first version of my chain, packaged as a plugin, the agents that write tests and code ran on Sonnet, and the reviewer on Opus, read-only. That last rule comes from my global instructions: a model cannot find a bug it does not understand. The reviewer's role is detailed in the article on code review by an agent.
The plugin records the outcome of every task. Across the 30 tasks logged on three of my projects, in October and November 2026:
- 4 passed review on the first try.
- 22 needed one round of fixes.
- 4 needed two, the maximum allowed.
So the reviewer almost always found something, and every round of fixes means another agent run and another review. In the next version of the chain, I flipped the default: the agent that codes runs on Opus. Sonnet stays for tests, and for the coding agent only when the task is a simple screen with a mockup and no logic. The plan flags it on the task with a **Model:** sonnet line, and the orchestrator then passes model at launch. The instruction written in the skill is short: keep Sonnet only where the last run needed no fix.
What a stronger model does not fix
One of the 30 tasks stopped with blocking issues after its two rounds: six on the first pass, four on the second. It was a database schema, with its access rules, functions and scheduled jobs. The postmortem does not blame the model. Nothing executed the SQL: the command-line tool was not authenticated and Docker was missing, so the only “tests” checked the text of the migrations. And the task was too big for a single review cycle.
The rules added afterwards are about method, not model: a task that ships SQL does not start without a database to run it on, and tasks are split by runtime.
Second lesson, about cost. In a session that orchestrates subagents, the main session costs the most: it rereads its whole context at every turn, and I measured 630,000 tokens of it at the end of one session. Hence my rule: one plan per fresh session, and the orchestrator reads neither briefs nor diffs during the tasks. Moving a subagent from Opus to Sonnet matters less than that. These rules are detailed in the article on token usage.
How to get started
- Put `model` in every agent's header. Without it, the agent follows the session's model, which changes from one day to the next.
- A reviewer at least as strong as the author, and read-only.
- Record the number of fix rounds per task. That number tells you whether a cheaper model is enough, not the impression a session leaves.
- Step down a notch only where the last run needed no fix, and make that choice task by task with the
modelparameter at launch.
Finally, check that what the agent ships is actually executed by your checks. No model makes up for a test that does not run.
Article written with the help of AI, from my daily practice and my projects.
The whole notebook