Claude Code model router saves 76% on a 340-test schema migration
Haiku scans and runs tests, Sonnet does the schema migration, and Opus only reviews the diff, cutting a 340-test migration from $4.26 to $1.03, with Jev-style branching in code.
THIS IS A PURE F*CKING GOLDMINE yesterday's Claude Code router post blew up, so I ran it again with harder work: a database schema migration, 340 tests, 64 files all-Opus would have cost $4.26. the router run cost $1.03. that's $3.23 kept, 76% never burned same launch line: claude --model opus # subagents: haiku, sonnet here's the split: → Haiku 5.5 swarms 6 tasks: scan 64 files, grep 27 imports, list 5 flaky tests, summarize 8 logs, run 340 tests, type-check + lint. 720k tokens for $0.07 → Sonnet 5.5 takes 2 tasks: migrate the db schema, write 2 tests. 210k tokens for $0.42 → Opus 5.5 takes 1 task: reviews the diff and raises 3 flags. 134k tokens for $0.54 → everything comes back as summaries only, Opus never sees raw output watch the savings meter in the video. it climbs to 87% while Haiku swarms, then drops to 76% the second Opus starts reviewing that drop is the only money you actually want to spend the part most people get wrong: they think a schema migration is an Opus job. it ran on Sonnet for $0.21. Opus still read the diff at the end and caught 3 things Haiku is 40x cheaper per token than Opus. running 340 tests cost $0.012. scanning 64 files cost $0.012 one catch worth knowing: once a prompt passes 100k, Haiku costs 5x its own price, so every lane stays small on purpose Haiku does the volume. Sonnet does the code. Opus does the judgment. JEV engineering is the same move one layer down: [X] forks this run (which tier, which agent, retry or stop) resolved in code at [0.XX] sharpness, and only the split ones ever reach Opus the full tree > a router sorts every task: read/grep/list, write/refactor, plan/review, summarize/test/lint > 6 tasks go to Haiku 5.5, each lane kept under 100k > 2 tasks go to Sonnet 5.5, including the schema migration > 1 task goes to Opus 5.5: review the diff, flag what's wrong > every agent returns a summary, never raw files or logs > JEV resolves [X] micro-forks in code and escalates only the split ones paste the tree and this prompt into Claude Code ↓ "Rebuild my Claude Code setup around this tree: 1. Run the main session on Opus 5.5 for planning and review only. 2. Add a router that sorts every task by kind before it runs. 3. Read, grep, list, test, lint, type-check and summarize go to Haiku 5.5. Write, refactor and migrations go to Sonnet 5.5. Plan and review stay on Opus 5.5. 4. Keep each agent under 100k of context and split the work if it goes over. Agents return summaries only. 5. Add one rule to CLAUDE.md: every task runs on the cheapest model that can do it, and Opus only spends tokens on review. Route deterministic forks (which tier, agent choice, retries) through JEV. Show me every change as a diff first. No edits until I say go." ↳ http://code.claude.com/docs/en/model-config save it, it'll come in handy.
This post quotes another post: x.com/mirku21/status/2098836008468992471