Build This Now
Build This Now
Was ist der Claude Code?Claude Code installierenClaude Code Native InstallerDein erstes Claude Code-Projekt
Subscription BillingMulti-Tenant SaaSAI Chat FeatureRate LimitingStripe WebhooksSemantic SearchRealtime UpdatesDrip Email Sequencesv2.1.122 Release NotesClaude Code Dynamic Workflows: 1.000 Subagents auf einer echten Codebase orchestrierenClaude Code Best PracticesClaude Opus 4.7 Best PracticesClaude Code auf einem VPSGit-IntegrationClaude Code ReviewClaude Code WorktreesClaude Code Remote ControlClaude Code ChannelsChannels, Routines, Teleport, DispatchGeplante Aufgaben mit Claude CodeClaude Code BerechtigungenClaude Code Auto-ModusStripe-Zahlungen mit Claude Code einbauenFeedback-LoopsTodo-WorkflowsClaude Code TasksProjekt-TemplatesClaude Code Preise und Token-NutzungClaude Code Preise: Was du wirklich zahlstClaude Code Ultra ReviewEine Next.js-App mit Claude Code bauenSupabase DatabaseVercel DeepsecTest-Driven DevelopmentSo baust du ein SaaS-MVP mit Claude CodeAuthentifizierung mit Claude Code einbauen (Supabase Auth)Transaktions-E-Mails mit Claude Code einbauen (Resend + React Email)Eine typsichere API mit Claude Code bauen (oRPC + Zod)File UploadsBackground Jobs (Inngest)Admin DashboardFull-Text SearchClaude Agent SDKKiro Migration GuideClaude Research AgentLeave Grok BuildRoute Subagent ModelsClaude Monorepo SetupCI Repair AgentVisual Regression TestsAgent Cost DashboardCursor Migration GuideAgentic Commerce: Wie du eine App baust, für die KI-Agents bezahlen können1M ContextUser API KeysAudit LogsCSV Import PipelineDatabase MigrationsProduction Error TrackingFeature FlagsGitHub ActionsHeadless ModeMax Plan vs APICaching and RevalidationIn-App NotificationsOutbound WebhooksPrompt CachingRoles & PermissionsMarketplace PaymentsUsage-Based BillingWas es 2026 kostet, ein SaaS mit Claude Code zu bauenParallel AI AgentsCoding Agent Injection
speedy_devvkoen_salo
Blog/Handbook/Workflow/Route Subagent Models

Claude Model Routing

Route Claude Code subagents to Haiku, Sonnet, or Opus by task, with complete agent files, safe tools, and a testable workflow.

Hören Sie auf zu konfigurieren. Fangen Sie an zu bauen.

SaaS-Builder-Vorlagen mit KI-Orchestrierung.

Sehen Sie, was wir für Unternehmen bauen →
speedy_devvWritten by speedy_devvPublished Jul 26, 2026Updated Jul 26, 202613 min readHandbook hubWorkflow index

Claude Code model routing works best when each subagent has one narrow job and an explicit model field. Put cheap, bounded repository searches on Haiku, normal implementation on Sonnet, and reserve Opus for decisions where a bad answer is more expensive than a slower one.

The model name is the easy part. Good routing also needs tight descriptions, restricted tools, small inputs, and a clear output contract. Without those, you have three expensive personalities reading the same files.

The routing rule

Anthropic's own cost guidance is blunt: Sonnet handles most coding tasks well, Opus is for complex architecture or multi-step reasoning, and simple subagent tasks can use model: haiku (Claude Code cost documentation).

Turn that into a task rule:

Task shapeModel aliasWhy
Find files, map symbols, summarize logs, check conventionshaikuBounded read-only work with an objective answer
Implement a feature, fix a bug, write tests, review a normal diffsonnetDefault coding lane
Decide architecture, resolve conflicting constraints, audit high-risk codeopusDeeper reasoning is worth the extra usage
Follow the parent's current model exactlyinheritUseful when consistency matters more than specialization

Use aliases when you want Claude Code to follow the current model family. Use a full model ID when reproducibility matters more than automatic upgrades. Anthropic supports both, plus inherit, in subagent frontmatter (custom subagent reference).

Do not route by file extension. A Markdown change can require an Opus-level product decision. A 20-file rename can be mechanical. Route by uncertainty, blast radius, and how easy the answer is to verify.

What Claude Code actually resolves

The model field is not always the final word. Claude Code resolves a subagent model in this order:

  1. CLAUDE_CODE_SUBAGENT_MODEL, when set.
  2. A model passed for that individual invocation.
  3. The subagent's model frontmatter.
  4. The main conversation's model.

That order is documented in the Claude Code subagent guide. It explains the most common routing bug: every agent says model: haiku, but all of them still run another model because a shell profile exports a global override.

Check before debugging your agent files:

if [[ -n "${CLAUDE_CODE_SUBAGENT_MODEL:-}" ]]; then
  printf 'Global subagent override: %s\n' "$CLAUDE_CODE_SUBAGENT_MODEL"
else
  printf 'No global subagent model override\n'
fi

If you want frontmatter to decide, remove the override from the current shell:

unset CLAUDE_CODE_SUBAGENT_MODEL

Also check organization policy. Managed availableModels settings can restrict what users and subagents may select. When a requested model is excluded, Claude Code can fall back to an inherited allowed model (model configuration documentation).

Final file tree

The complete setup uses three project subagents and one project instruction file:

.
├── CLAUDE.md
└── .claude
    └── agents
        ├── repo-scout.md
        ├── feature-builder.md
        └── risk-reviewer.md

Project subagents live in .claude/agents/. Claude watches that directory and reloads edits for later delegations. If the directory did not exist when the session started, restart Claude after creating the first file (Anthropic subagent documentation).

Haiku agent for repository scouting

The scout is read-only. It can search and inspect files, but it cannot edit them or run arbitrary shell commands. Its answer has a fixed shape so the parent receives a compact map instead of a transcript dump.

Create .claude/agents/repo-scout.md:

---
name: repo-scout
description: Maps relevant files, symbols, tests, and conventions before implementation. Use for bounded repository discovery when no edits are needed.
tools: Read, Glob, Grep
model: haiku
maxTurns: 8
---

You are a repository scout. Investigate only the delegated question.

Return:

1. Relevant files, with one sentence explaining each.
2. Existing patterns the implementation should copy.
3. Tests that cover the affected behavior.
4. Unknowns the parent must resolve.

Do not propose broad refactors. Do not edit files. Do not guess about files you did not inspect. Keep the response under 700 words.

The description matters. Claude uses it to decide when to delegate. "Helpful coding agent" is useless because it overlaps every task. "Maps relevant files before implementation" creates a clean boundary.

maxTurns is a guard, not a performance target. Eight turns are enough for a bounded search. If the scout repeatedly runs out, narrow the delegation prompt before raising the cap.

Sonnet agent for implementation

The builder owns normal feature work. It can read, edit, and run focused commands. The prompt tells it to inspect the existing pattern first, which prevents a second architecture from appearing beside the first.

Create .claude/agents/feature-builder.md:

---
name: feature-builder
description: Implements a scoped feature or bug fix after requirements and relevant files are known. Use for normal code and test changes.
tools: Read, Glob, Grep, Edit, Write, Bash
model: sonnet
permissionMode: default
maxTurns: 24
---

You are the implementation worker for a scoped change.

Before editing:

1. Read the delegated requirements.
2. Inspect the nearest existing implementation and its tests.
3. State the files you expect to change.

During implementation:

- Follow repository conventions already present in code.
- Keep the diff inside the delegated scope.
- Add or update tests for changed behavior.
- Run the narrowest relevant test after edits.
- Never change deployment, billing, secrets, or production data unless the delegation explicitly authorizes it.

Return the changed files, commands run, results, and any remaining risk. Do not claim a test passed unless you ran it and saw a successful exit.

permissionMode: default keeps the normal permission flow. A model choice should never silently become a permission choice. Anthropic warns that bypass modes can let a subagent write sensitive project configuration without a prompt, so leave them out of a general-purpose builder (subagent permission documentation).

If builders work concurrently, add isolation: worktree and partition files. A worktree gives a subagent an isolated checkout, but it does not solve two workers making incompatible designs. The parent still has to split ownership cleanly.

Opus agent for risk review

Opus should receive a small, consequential question. Sending it the whole repository "for a deep review" is not routing. It is a costly scavenger hunt.

Create .claude/agents/risk-reviewer.md:

---
name: risk-reviewer
description: Reviews a completed high-risk change for architecture, security boundaries, data integrity, or irreversible failure modes.
tools: Read, Glob, Grep, Bash
model: opus
effort: high
permissionMode: plan
maxTurns: 16
---

You are the final risk reviewer. Review the delegated diff and the smallest set of surrounding files needed to understand it.

Focus on:

- Broken trust boundaries or permission checks.
- Data loss, unsafe migrations, and non-idempotent operations.
- Race conditions and failure recovery.
- Requirements the implementation quietly skipped.
- Tests that can pass while the production behavior is still wrong.

Run read-only inspection and test commands only. Do not edit files.

Return findings ordered by severity. For each finding, include the file, the concrete failure path, and the smallest credible fix. If no blocking issue exists, say so and list the residual risks. Do not invent a finding to justify the review.

permissionMode: plan gives the reviewer read-only exploration. effort: high asks for deeper reasoning on models that support effort. The supported effort levels depend on the active model and organization policy (Claude model configuration).

There is a small trap here. A reviewer with Bash can still be noisy even in a read-oriented workflow. Keep the task prompt explicit about allowed commands, and use project permission denies for anything that must never run.

Teach the parent how to route

Claude can discover agents from their descriptions, but a short policy in CLAUDE.md makes the intended sequence harder to miss.

Add this section:

## Subagent routing

- Use repo-scout for bounded, read-only discovery before unfamiliar changes.
- Use feature-builder for scoped implementation once requirements are settled.
- Use risk-reviewer only after a completed change affects auth, billing, permissions, migrations, destructive operations, or public API compatibility.
- Pass each agent a narrow task with explicit files and acceptance criteria.
- Do not spawn agents for work the main conversation can finish with one or two direct tool calls.
- Never let two agents edit the same files concurrently.

Claude Code loads project CLAUDE.md files into the main session and most custom subagents. A subagent still begins with a fresh context window and does not inherit the conversation transcript, so the delegation must carry the actual requirements (Claude Code subagent context documentation).

That isolation is useful. The scout can read 20 files and return a 500-word map. The main conversation gets the answer without keeping every file in its own active context.

Run the routed workflow

Restart Claude if .claude/agents/ was created after the current session started:

claude --model opusplan

opusplan is a main-session hybrid. It uses Opus in plan mode and Sonnet for execution. It is separate from the model field inside each custom subagent (Anthropic model configuration).

Use a prompt with a real acceptance test:

Add a per-user API request limit.

Acceptance criteria:
- Existing authenticated routes keep their response shape.
- The limit is enforced before the handler performs work.
- A focused test covers allowed and rejected requests.
- No deployment or billing configuration changes.

First use repo-scout to map the current middleware and tests.
Then use feature-builder for the scoped implementation.
After tests pass, use risk-reviewer because this changes an authorization boundary.

Watch the sequence in /agents and inspect the transcript. The point is not that three agents ran. The point is that each received a task it could finish without rediscovering the whole project.

Test whether routing is helping

Take five tasks your repository has already solved. Pick a small bug, a normal feature, a refactor, a permission change, and a migration review. Run the baseline with one Sonnet session, then run the routed setup from the same commits.

Record:

MeasureWhat to capture
CorrectnessTests passed and review findings confirmed
ReworkExtra edits after the first implementation
ScopeFiles changed outside the intended area
UsagePlan usage or API cost shown by the account
TimeWall time until a reviewable diff
NoiseDuplicate file reads and repeated explanations

Parallel and delegated work can multiply token usage because each worker has its own context. Anthropic explicitly warns that running multiple agents increases usage (parallel agents documentation). A Haiku scout is not cheaper if four scouts each map the same folder.

Keep routing only where it wins on the whole task. Sometimes one Sonnet session is the boring, correct answer.

Common routing failures

Every subagent runs the same model

Check CLAUDE_CODE_SUBAGENT_MODEL, per-invocation overrides, and managed model allowlists. Frontmatter is third in the documented resolution order.

The parent ignores the specialist

Tighten the specialist's description and name the agent explicitly in the prompt. Test with an @repo-scout mention before expecting automatic delegation.

The scout returns a wall of text

Give it an output schema and a word limit. Read-only does not mean concise.

The builder asks for permissions constantly

Do not jump to bypass mode. Add narrowly scoped project permission rules for commands you have reviewed, or let the main session perform sensitive operations.

Opus reviews everything

Define a trigger list. Auth, payments, data migrations, destructive actions, and public compatibility deserve the expensive lane. A CSS spacing fix does not.

For a deeper look at agent boundaries, read Claude Code subagent best practices and Claude Code model selection. If context size is driving your routing decisions, start with how to fix the Claude Code context limit.

Where the $29 Code Kit fits

The three agent files above give Claude a routing policy. They do not give you a complete product delivery loop. The $29 Code Kit is a one-time harness on top of Claude Code that connects planning, building, evaluation, browser testing, and quality gates into a repeatable workflow. There is no Code Kit subscription. Claude Code still runs on your own paid Anthropic plan, which is separate. If you only need one scout and one builder, use the files in this post. The Kit makes the same discipline repeatable across a real feature backlog.

Posted by @speedy_devv

Continue in Workflow

  • Agentic Commerce: Wie du eine App baust, für die KI-Agents bezahlen können
    Ein Guide in einfachem Deutsch zu Agentic Commerce im Jahr 2026: Was x402, ACP und das Machine Payments Protocol tun, plus eine Wochenend-Anleitung, um eine bezahlte API auszuliefern, von der KI-Agents kaufen können.
  • Claude Code Best Practices
    Fünf Gewohnheiten trennen Entwickler, die mit Claude Code liefern: PRDs, modulare CLAUDE.md-Regeln, Custom-Slash-Commands, /clear-Resets und eine System-Evolutions-Denkweise.
  • Claude Code Auto-Modus
    Ein zweites Sonnet-Modell prüft jeden Claude Code-Tool-Aufruf, bevor er ausgeführt wird. Was der Auto-Modus blockiert, was er erlaubt, und die Erlaubnisregeln, die er in deine Einstellungen schreibt.
  • Channels, Routines, Teleport, Dispatch
    Die vier Claude-Code-Features, die Anthropic im März und April 2026 ausgeliefert hat und die die CLI in eine ereignisgesteuerte Koordinationsschicht über Handy, Web und Desktop verwandeln.
  • Claude Code 1M Context in Practice: When Bigger Isn't Better
    The 1M-token context window is GA at flat pricing, but bigger isn't always better. A decision framework, token-cost math, and when to use /compact, subagents, and dynamic workflows instead.
  • How to Build an Admin Dashboard With Claude Code
    Ship an internal admin panel with Claude Code: role-gated routes, a searchable users and orders table with pagination, impersonation-safe RLS, and metrics tiles pulled through a type-safe API.

More from Handbook

  • Grundlagen für Agenten
    Fünf Möglichkeiten, spezialisierte Agenten in Claude Code zu erstellen: Aufgaben-Unteragenten, .claude/agents YAML, benutzerdefinierte Slash-Befehle, CLAUDE.md Personas und perspektivische Aufforderungen.
  • Agent-Harness-Engineering
    Der Harness ist jede Schicht rund um deinen KI-Agenten, außer dem Modell selbst. Lern die fünf Steuerungshebel, das Constraint-Paradoxon und warum das Harness-Design die Performance des Agenten mehr bestimmt als das Modell.
  • Agenten-Muster
    Orchestrator, Fan-out, Validierungskette, Spezialistenrouting, Progressive Verfeinerung und Watchdog. Sechs Orchestrierungsformen, um Claude Code Sub-Agenten zu verdrahten.
  • Agent Teams Best Practices
    Bewährte Muster für Claude Code Agent Teams. Kontextreiche Spawn-Prompts, richtig bemessene Aufgaben, Datei-Eigentümerschaft, Delegate-Modus und Fixes für v2.1.33-v2.1.45.

Hören Sie auf zu konfigurieren. Fangen Sie an zu bauen.

SaaS-Builder-Vorlagen mit KI-Orchestrierung.

Sehen Sie, was wir für Unternehmen bauen →

Leave Grok Build

Move from Grok Build to Claude Code without losing instructions, skills, agents, MCP servers, hooks, or project safety rules.

Claude Monorepo Setup

Set up Claude Code for a pnpm monorepo with scoped CLAUDE.md files, path rules, safe permissions, and package-level verification commands.

On this page

The routing rule
What Claude Code actually resolves
Final file tree
Haiku agent for repository scouting
Sonnet agent for implementation
Opus agent for risk review
Teach the parent how to route
Run the routed workflow
Test whether routing is helping
Common routing failures
Every subagent runs the same model
The parent ignores the specialist
The scout returns a wall of text
The builder asks for permissions constantly
Opus reviews everything
Where the $29 Code Kit fits

Hören Sie auf zu konfigurieren. Fangen Sie an zu bauen.

SaaS-Builder-Vorlagen mit KI-Orchestrierung.

Sehen Sie, was wir für Unternehmen bauen →