Skip to content
Claude Code Subagents: Build a Parallel Review Fleet — ContentBuffer guide

Claude Code Subagents: Build a Parallel Review Fleet

K
Kodetra Technologies··11 min read Intermediate

Summary

Define custom .claude/agents specialists and fan them out in parallel to review code.

If you have spent any time in the AI dev communities this week, you have seen the same phrase over and over: orchestration beats a bigger model. The threads that keep climbing Hacker News and r/ClaudeAI are not about which model tops a benchmark. They are about how people are wiring several specialized Claude instances into something that behaves like a small engineering team, and shaving real time off code review, refactors, and audits.

The primitive that makes this work inside Claude Code is the subagent. A subagent is a named, isolated Claude instance with its own context window, its own system prompt, its own tool permissions, and its own model choice. Your main session can hand a job to one, or fan a job out to several at once, and only the summarized results come back. That last detail is the whole trick: the noisy back-and-forth stays out of your main context, so your primary session stays clean and cheap.

This guide walks you from zero to a working review fleet: three custom subagents that inspect a code change in parallel, each from a different angle, and report back in a format you can act on. Every file and command here is real and runnable in Claude Code. By the end you will know how to define subagents, delegate to them explicitly or automatically, run them concurrently, and avoid the token traps that catch people on day one.

Prerequisites

  • Claude Code installed and authenticated (run claude in any project directory to confirm).
  • A git repository with some code in it. The examples assume a Python or JavaScript project, but nothing here is language-specific.
  • Basic comfort with YAML frontmatter and Markdown. Subagents are just text files.
  • About 15 minutes. No API keys beyond what Claude Code already uses.

Check your version first. Subagents and the /agents manager have been stable for a while, but parallel fan-out behaves best on recent builds:

claude --version
# Then, inside a Claude Code session, open the manager:
# /agents

Step 1: Understand what a subagent actually is

Before writing any files, get the mental model right, because it explains every design decision later. A subagent differs from your main Claude session in four ways:

  • Isolated context. The subagent starts fresh. It does not see your main conversation unless you pass the relevant details in the delegation prompt. This is a feature: it keeps a focused task from polluting your main window.
  • Its own system prompt. The Markdown body of the agent file becomes the subagent's instructions. This is where you make it a specialist.
  • Scoped tools. You choose exactly which tools it can touch. A reviewer that only reads should never get write or execute permissions.
  • Its own model. Cheap, high-volume checks can run on Haiku while a deep reasoning pass runs on Opus, all in the same fleet.

Two limitations matter and shape how you design fleets. First, a subagent cannot spawn its own subagents — there is no nested delegation, so orchestration stays flat with your main session as the only coordinator. Second, each subagent burns tokens independently. Running three Sonnet subagents in parallel costs roughly three times a single pass. Parallelism buys you wall-clock speed and independent perspectives, not free compute.


Step 2: Create your first subagent

Subagents live as Markdown files with YAML frontmatter. Put them in .claude/agents/ to scope them to the current project, or in ~/.claude/agents/ to make them available everywhere. Project files win when names collide.

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

---
name: code-reviewer
description: >
  Use PROACTIVELY right after code is written or changed. Reviews the diff for
  bugs, edge cases, readability, and maintainability. Trigger on "review",
  "check my code", or after a feature is implemented.
tools: Read, Grep, Glob, Bash
model: sonnet
---

You are a senior code reviewer. You are thorough, specific, and kind.

When invoked:
1. Run `git diff` (or `git diff --staged`) to see exactly what changed.
   Do not review the whole repository, only the change.
2. Read the surrounding code for the files touched so you understand context.
3. Review against this checklist:
   - Correctness: off-by-one, null/None handling, error paths, race conditions.
   - Security: injection, unvalidated input, secrets in code, unsafe eval.
   - Readability: naming, dead code, functions doing too much.
   - Tests: is the new behavior covered? Name the missing cases.

Output a Markdown table with columns: file, line, severity, note.
Use severity values: BLOCKER, MAJOR, MINOR, NIT.
After the table, write a two-sentence verdict: ship, or fix-first.
Never rewrite the code yourself. Point, explain, and let the human decide.

A few things are load-bearing here. The description is what Claude reads to decide whether to auto-delegate. Lead with the trigger and be concrete: "Use PROACTIVELY right after code is written" fires reliably; "helps with code" almost never does. The tools line is an allowlist — this reviewer can read and grep and run git, but it has no Edit or Write tool, so it physically cannot change your files. The fixed output format (a table plus a verdict) is what makes the result parseable when three of these run at once.


Step 3: Add a specialist teammate

A fleet is only useful when each member sees something the others miss. Add a security-focused reviewer that thinks like an attacker. Create .claude/agents/security-auditor.md:

---
name: security-auditor
description: >
  Use PROACTIVELY on any change that touches auth, input handling, file I/O,
  network calls, subprocess, or dependencies. Audits for exploitable
  vulnerabilities. Trigger on "security", "audit", or "is this safe".
tools: Read, Grep, Glob, Bash
model: opus
---

You are an application security engineer running a focused audit.

When invoked:
1. Inspect the diff and the files it touches.
2. Hunt specifically for: command/SQL injection, path traversal, SSRF,
   deserialization of untrusted data, hardcoded secrets, weak crypto,
   and missing authz checks.
3. For each finding, give a concrete exploit sketch: what an attacker sends
   and what happens. No hand-waving.

Output a Markdown table: file, line, vuln_class, exploit, fix.
If you find nothing exploitable, say so plainly and list what you checked.
Do not report style issues. That is the code-reviewer's job, not yours.

Notice the model is opus here. Security reasoning benefits from the stronger model, and since this agent only fires on risky diffs, the extra cost is contained. Notice also the explicit boundary in the last line: telling an agent what not to do is how you stop two teammates from producing the same noise.

Add a third, cheaper worker for test coverage. Create .claude/agents/test-scout.md and set model: haiku so the volume work stays inexpensive:

---
name: test-scout
description: >
  Use after a feature or bugfix to find missing test coverage. Trigger on
  "tests", "coverage", or "what should I test".
tools: Read, Grep, Glob
model: haiku
---

You are a pragmatic test engineer. You do not write full test files; you
identify the specific cases that are missing.

When invoked:
1. Read the changed code and any existing tests near it.
2. List the untested paths: happy path, boundaries, error handling,
   and one realistic "weird input" per public function.

Output a Markdown list. Each item: the function, the case, and a one-line
reason it matters. Prioritize by risk, highest first.

Step 4: Delegate work to a subagent

There are two ways your main session hands work to a subagent, and you will use both.

Automatic delegation. When your request matches an agent's description, Claude routes to it on its own. Because the descriptions above lead with "Use PROACTIVELY," this just happens after you write code:

> I just finished the login handler in auth.py.

Claude: I'll have the code-reviewer subagent look at this.
  ⎿ Delegating to code-reviewer (sonnet)...
  ⎿ code-reviewer returned:

| file     | line | severity | note                                        |
|----------|------|----------|---------------------------------------------|
| auth.py  | 42   | BLOCKER  | Password compared with ==, not constant-time|
| auth.py  | 58   | MAJOR    | Bare except swallows the DB error           |
| auth.py  | 12   | MINOR    | `usr` should be `user` for readability      |

Verdict: Fix-first. The timing-safe comparison is a real auth weakness.

Explicit invocation. When you want a specific agent regardless of routing, name it. This is how you force the specialist you have in mind:

> Use the security-auditor subagent to audit the changes in payments.py

You can inspect, edit, and test your agents any time with the manager. Inside a session, run /agents to open a menu that lists project and user agents, shows their tools, and lets you create or edit them interactively rather than by hand.


Step 5: Fan out the full fleet in parallel

The payoff. When you ask for several independent reviews in a single turn, Claude launches the subagents concurrently instead of one after another. Each has its own context, so they never step on each other, and they finish roughly in the time of the slowest one rather than the sum of all three.

> Review the current diff with three subagents in parallel:
  code-reviewer for correctness, security-auditor for vulnerabilities,
  and test-scout for missing coverage. Then give me a combined summary.

Claude issues three delegations at once and waits for all of them:

  ⎿ code-reviewer (sonnet)   ... done  (3 findings)
  ⎿ security-auditor (opus)  ... done  (1 finding)
  ⎿ test-scout (haiku)       ... done  (4 cases)

Combined summary
----------------
BLOCKER  auth.py:42  timing-unsafe password compare  (fix before merge)
MAJOR    auth.py:58  bare except hides DB failures
SECURITY auth.py:31  session id from predictable seed -> fixation risk
TESTS    missing: expired-token path, empty-password, unicode username
Verdict: 1 blocker, 1 security issue. Do not merge yet.

Because every agent was told to emit a fixed shape, your main session can merge the three reports into one prioritized list without guessing. This is why the "return a Markdown table with these columns" instruction earlier was not cosmetic — structured output is what makes a fleet composable.


A real-world workflow: gating a pull request

Here is how this fits a daily loop. Say you are about to open a PR. Instead of eyeballing your own diff, you wire the fleet into a repeatable step.

  1. Stage your changes so the reviewers see a clean diff: git add -p.
  2. In Claude Code, run one instruction: "Run the review fleet on the staged diff and tell me if this is mergeable."
  3. The three subagents fan out. Blockers and security findings come back first because you told each agent to sort by severity.
  4. You fix the blocker (constant-time compare), re-stage, and re-run just the code-reviewer explicitly to confirm it cleared.
  5. Only then do you open the PR — with the combined summary pasted into the description as a reviewer's head start.

The reason this is faster than doing it yourself is not that Claude is smarter than you. It is that three focused passes with clean context and no shared bias each catch a different class of problem, and they run while you get coffee. Teams report cutting review time meaningfully by pushing the first pass to a fleet and reserving human attention for the judgment calls.


Common pitfalls and how to dodge them

Vague descriptions kill auto-delegation. Claude picks agents by pattern-matching the description against your request. "Assists with quality" will sit unused. Lead with the trigger and name the situation: "Use PROACTIVELY after code changes to review the diff." If an agent never fires on its own, its description is almost always the cause.

Over-broad tools are a real risk. A reviewer with the Bash tool and no discipline can run anything. Give read-only agents only Read, Grep, Glob. Add Bash only when they genuinely need git diff, and never hand Edit or Write to something whose job is to critique, not change.

Parallelism is not free. Three Sonnet subagents cost about 3x one pass, and Opus multiplies that. Match the model to the job: Haiku for scanning and coverage, Sonnet for the main review, Opus only for the deep security or reasoning pass. A mixed fleet is far cheaper than an all-Opus one and usually just as good.

Expecting nested delegation. A subagent cannot spawn subagents. If your design needs an agent to "then have another agent do X," that coordination has to live in your main session. Keep the tree flat: one coordinator, many workers.

Forgetting the fresh-context tax. Subagents do not see your conversation. If a reviewer needs to know "we deliberately allow this because of X," say it in the delegation prompt or in the agent's system prompt, or it will flag the thing you already decided to keep.

Unstructured output that will not merge. If each agent free-writes prose, your main session cannot cleanly combine three reports. Pin the shape — a table with named columns or a strict list — in every agent file.


Quick reference

ConceptWhat to know
File location.claude/agents/ (project) or ~/.claude/agents/ (global); project wins on name clash
Required frontmattername and description; tools and model are optional
description fieldLoad-bearing for auto-delegation. Lead with the trigger, be specific.
tools fieldAllowlist. Omit it to inherit all tools; set it to restrict (e.g. Read, Grep, Glob).
model fieldhaiku, sonnet, opus, or inherit. Match cost to the task.
Manage agentsRun /agents inside a session to create, edit, and inspect.
Explicit invoke"Use the subagent to ..."
Parallel fan-outAsk for several independent reviews in one turn; Claude runs them concurrently.
Hard limitsNo nested subagents; each burns tokens independently; context is isolated.

Next steps

  • Commit your .claude/agents/ directory to the repo so the whole team shares the same fleet.
  • Add a docs-writer agent (model: haiku, tools: Read, Grep) that drafts changelog entries from the diff.
  • Wrap the fan-out instruction in a project command or skill so "run the review fleet" is one word.
  • Tune descriptions by watching what auto-delegates. If an agent misfires, tighten its trigger language.
  • Measure it: time a few PRs with and without the fleet, and price the token cost, so you keep the parts that pay off.

Subagents are a small idea with a large payoff. You are not chasing a bigger model; you are giving one model a clear role, a clean context, and a tightly scoped set of tools, then running a few of them side by side. That is the whole reason "orchestration beats a bigger model" is the phrase of the week — and now you can build it yourself in about the time it took to read this.

Comments

Subscribe to join the conversation...

Be the first to comment

Found this useful?

Get new AI guides for builders by email. Free.

Join 3,617 newsletter subscribers.

Also get