Pro11 min

Subagents and Parallel Work

A single agent in a single context window hits limits: long tasks bloat the window and unrelated concerns pollute each other. The pro move is delegation. A lead agent spawns subagents, each with its own clean context and a narrow job, then collects their results. This keeps every context small and lets independent work happen in parallel.

Step 1: Define a reusable subagent

In Claude Code you define a subagent as a Markdown file with a role, the tools it may use, and optionally a cheaper model. A focused reviewer or test-writer subagent can run on Claude Sonnet 4.6 to save cost while the lead runs on Claude Opus 4.8.

.claude/agents/reviewer.md
---
name: reviewer
description: Reviews diffs for bugs and security issues. Use after any change.
tools: Read, Grep, Bash
model: sonnet
---

You are a senior reviewer. Read the diff, flag correctness bugs,
missing tests, and security risks. Be specific and cite file:line.
Do not rewrite code; report findings only.

Step 2: Delegate explicitly

Ask the lead agent to fan work out. Independent pieces (write the migration, write the tests, draft the docs) can run as separate subagents and merge back, while dependent steps stay sequential.

claude - platform
$> use subagents: one writes the API, one writes tests, then the reviewer checks both
Spawned 2 subagents (api-builder, test-writer) in parallel
Both returned. Spawning reviewer ...
Reviewer: 1 missing edge-case test on empty input. Patching.
$

Step 3: Isolate risky work in worktrees

For truly parallel feature work, give each agent its own Git worktree so they edit separate working directories on separate branches and never clobber each other. Merge the branches when each passes its checks.

Small contexts win
Delegation is not about looking sophisticated. It is the practical way to keep each context window small and focused, which is exactly what produces reliable output. One giant context is the enemy.
Claude Code - orchestration
lead (opus 4.8)
|- api-builder [done]
|- test-writer [done]
'- reviewer [1 finding -> patched]
A lead agent fans work out to focused subagents, then reconciles.

Hands-on tasks