Home / Several agents and adversarial checking
Orchestrating several models in Claude Code, with a ready-to-install kit
Split the models by role, small to collect, mid-size to execute, large to judge blind, and declare that choice in skills and subagents: no hook changes the main session's model.
In a long session, cost and quality depend first on who does what. A small model reads and extracts without judging, a mid-size model carries out a settled instruction, and the most capable one judges blind, receiving the deliverable and the criteria but never the author's reasoning. A ready-to-install kit, tested on Windows on Claude Code 2.1.326, applies this split in Claude Code and, as a plugin, in Cowork.
Who does what
The collector runs on Haiku with only the Read, Grep and Glob tools: it returns raw data and concludes nothing. The executor runs on Sonnet and applies a precise instruction. The judge runs on Opus, read-only, and returns a verdict (see the lesson on adversarial verification and the lesson on routing by cost).
The fallback planner runs on Fable, read-only: when the same error comes back twice, it returns a new plan without executing anything, twice per session at most (lesson on capping a judge loop). fallbackModel, for its part, only covers the main model being unavailable.
Three ways to switch models without thinking about it
First way: the model: field (and effort:) in a skill's header, such as model: haiku in the kit's releve-brut skill. Second way: the same field in a subagent definition, here the kit's judge (description shortened):
---
name: juge
description: Vérification en aveugle, en lecture seule. […]
tools: Read, Grep, Glob
model: opus
effort: high
---
CLAUDE_CODE_SUBAGENT_MODEL only sets the default: the agent definition and the model passed at the call take precedence. Third way: the opusplan alias, Opus in plan mode, Sonnet to execute.
A hook, however, does not change the main session's model: the kit's hook refuses a subagent launch with no explicit model, and chooses nothing. Switching models mid-session also loses the prompt cache, so prefer subagents and skills with model: (lesson on what a subagent costs).
The choix-skills hook, on UserPromptSubmit, flags on each message the three skills whose description matches the request, without choosing for Claude. The sync-memoire skill writes the durable facts into memory at the end of a batch, one note per subject.
Compaction at 600,000 tokens, then resume
autoCompactWindow takes an integer from 100000 to 1000000 in settings.json; CLAUDE_CODE_AUTO_COMPACT_WINDOW wins if it is set (lesson on the auto-compact threshold). An excerpt of the kit's fragment (the installer replaces __HOOKS_DIR__):
{
"autoCompactWindow": 600000,
"model": "opus[1m]",
"fallbackModel": ["sonnet"],
"hooks": {
"PreCompact": [
{
"matcher": "auto|manual",
"hooks": [
{ "type": "command", "command": "node \"__HOOKS_DIR__/avant-compaction.mjs\"" }
]
}
],
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{ "type": "command", "command": "node \"__HOOKS_DIR__/apres-compaction.mjs\"" }
]
}
],
"PreToolUse": [
{
"matcher": "Agent|Task",
"hooks": [
{ "type": "command", "command": "node \"__HOOKS_DIR__/garde-modele.mjs\"" }
]
}
]
}
}
Before each compaction, PreCompact writes a resume note and asks the summary for two sections, resume note and durable facts; PostCompact saves that summary in memoire/. Then SessionStart has Claude run sync-memoire and resume at the next step. This is proven on a real manual compaction, not yet on an automatic one.
Install and verify
As a plugin: claude --plugin-dir in Claude Code, upload in Cowork, where the kit is not yet tested. Otherwise node installer.mjs installs for Claude Code only. The tests (Windows only) run like this:
node tests/essais.mjs
TOUS LES ESSAIS PASSENT (116 vérifications)
A real test completes them: with claude -p "/releve-brut" --model sonnet, modelUsage names only claude-sonnet-5-5 without a model: line, and only claude-haiku-5-5 with model: haiku (one launch per part).
A ready-to-copy CLAUDE.md
The zip also contains CLAUDE.md (direct links: English, French, Spanish), a base of fifty numbered working rules: proof before any claim of success, bounded autonomy, models split by role, resume after compaction.
The installer does not copy it: merge it with your personal instructions rather than replacing them, in ~/.claude/CLAUDE.md or at the root of a project, and let your own rules win any conflict. Fill in section 1, and change a rule only after a real problem.
The kit's three roles
| Role | Model | Tools | What it returns |
|---|---|---|---|
| Collector | Haiku | Read, Grep, Glob | Raw data with path and line, "manquant" if absent |
| Executor | Sonnet | Read, Grep, Glob, Edit, Write, Bash | A settled task, with the decisive line of its check |
| Judge | Opus | Read, Grep, Glob | A verdict: CONFORME, NON CONFORME or NON VÉRIFIABLE |
Compaction, then resume
The skill model-switch test
| Skill | Model requested for the session | Model named by modelUsage |
|---|---|---|
| No model: line | sonnet | claude-sonnet-5-5 only |
| model: haiku | sonnet | claude-haiku-5-5 only |
A team installs the kit at user level with node installer.mjs, then runs node tests/essais.mjs, whose last line is TOUS LES ESSAIS PASSENT (116 vérifications). It then works on a project with autoCompactWindow at 600000. The session reaches an automatic compaction, the file .claude/etat-reprise.md appears in the project with the goal and the list of modified files, and the session finishes the requested task.
Write in one sentence what this situation establishes, and in one sentence what it does not establish.
What this establishes: It establishes that the kit's 67 checks passed, that an automatic compaction took place on this project, that the resume state was written with the goal and the modified files, and that the requested task finished.
What this does not establish: It does not establish that the state was reinjected after the compaction, nor that the resume happened at the right step thanks to it, nor that the kit holds on other projects or other compactions: the situation describes a single compaction and says nothing about reinjection.
The three most common miscalibrations
- Too broad The kit is proven for every compaction at 600000 tokens, on any project.
- Too narrow Only the 67 checks count, and the state file that was written proves nothing about how the hook works.
- Off target The state file being written confirms that each of the kit's agents runs on the model of its role.
- The small model collects without judging, the mid-size one executes a settled instruction, the large one judges blind on the deliverable and the criteria.
- A fallback model is justified by a failure that was observed and capped, whereas fallbackModel only covers the main model being unavailable.
- A skill's frontmatter, a subagent definition and the opusplan alias switch the model by task, with no action on your part; a two-part test shows the effect of a skill's model: field (Sonnet only without it, Haiku only with it), on a single skill.
- A hook can refuse a launch or add context but does not change the session's model, and switching that session loses the prompt cache.
- Resuming after compaction rests on a state written before and reinjected after, and on /goal to last from one turn to the next; the kit is not proven on a real compaction at 600,000 tokens.
Download the kit, unzip it into a throwaway folder, move into the folder that contains installer.mjs, run node installer.mjs --essai to read the plan without writing anything, then node tests/essais.mjs and check that the last line announces 67 checks passed.
Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.
- Claude Code changelog (autoCompactWindow, /goal, compaction hooks, model: in skill and subagent headers, opusplan, CLAUDE_CODE_SUBAGENT_MODEL) accessed on 2026-11-16
- Claude Code, model configuration (opusplan) accessed on 2026-11-16
- Claude Code, hooks reference accessed on 2026-11-16
- Claude Code, subagents accessed on 2026-11-16
- Claude Code, prompt caching (switching models) accessed on 2026-11-16