Skip to content
Mastering Claude

The course175 lessons

Home / Several agents and adversarial checking

Several agents and adversarial checking9 minApplication

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.

Figure 1

The kit's three roles

RoleModelToolsWhat it returns
CollectorHaikuRead, Grep, GlobRaw data with path and line, "manquant" if absent
ExecutorSonnetRead, Grep, Glob, Edit, Write, BashA settled task, with the decisive line of its check
JudgeOpusRead, Grep, GlobA verdict: CONFORME, NON CONFORME or NON VÉRIFIABLE
The table gives, for each of the kit's subagents, its model, its tools and what it returns.
Figure 2

Compaction, then resume

01
PreCompact
The hook writes .claude/etat-reprise.md: goal, modified files, date.
02
Compaction
Claude Code summarizes the conversation, and the hook cannot block it.
03
SessionStart compact
The hook reinjects the state and the instruction to resume at the next step.
04
Resume
The work continues; /goal carries it from one turn to the next until the completion condition.
The figure follows a state written before compaction, reinjected after, then the work carrying on.
Figure 3

The skill model-switch test

SkillModel requested for the sessionModel named by modelUsage
No model: linesonnetclaude-sonnet-5-5 only
model: haikusonnetclaude-haiku-5-5 only
One launch per row, same throwaway project, Claude Code 2.1.325, 2026-11-16: the model named by modelUsage changes with the model: field alone.
Calibrate it yourself

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 to remember
  • 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.
Do this now

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.

Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.