Lesson 339 of 2116
Multi-Agent Coordination — When Subagents Step on Each Other
Claude Code supports up to 10 parallel subagents; Cursor has cloud agents; Codex has codex cloud. Parallel agents are powerful and chaotic. Learn the coordination patterns that work and the failure modes that hurt.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1Ten Agents, One Repo
- 2subagent
- 3parallelism
- 4coordination
Concept cluster
Terms to connect while reading
Section 1
Ten Agents, One Repo
Spawning multiple agents in parallel is the killer feature of 2026 coding tools. Claude Code can run up to 10 subagents at once. Cursor's cloud agents run in parallel branches. Codex CLI has `codex cloud` for background work. Done well, this collapses a day of work into an hour. Done badly, it's ten agents fighting for the same files.
When parallelism is a clear win
Compare the options
| Task | Why parallel works |
|---|---|
| Codebase exploration | Each agent reads a different module — no overlap |
| Independent bug fixes | Different files, different test files, different PRs |
| Test generation across modules | Agents can each tackle one module's tests |
| Documentation generation | Each subagent documents one feature area |
| Migration sweeps | Each agent handles one batch of files for the same migration |
When parallelism breaks
- Two agents editing the same file — last writer wins, lost work
- Refactors that touch shared abstractions — types drift across agents
- Tasks with sequential dependencies — agent B can't start until A finishes
- Anything where global consistency matters more than local progress
The coordination patterns that work
Compare the options
| Pattern | How it works | Best for |
|---|---|---|
| Branch-per-agent | Each subagent works on its own git branch; merge at end | Independent feature work, parallel bug fixes |
| Lane-per-agent | Each agent owns specific paths (paths/A/* vs paths/B/*) | Codebase exploration, parallel module work |
| Producer-consumer | Agent A produces a plan or spec; Agent B implements | Plan-then-execute workflows |
| Scout-and-builder | Scouts read and summarize; one builder writes code | Large unfamiliar codebases |
| Reviewer pair | Builder writes; reviewer (different model) audits | Quality-critical features |
A real Claude Code subagent setup
Three subagents with different tool grants. Scout finds, builder builds, reviewer audits. Roles by permission, not by polite request.
# .claude/agents/scout.md
---
name: scout
description: Read-only codebase exploration
tools: [Read, Grep, Glob] # NO write/edit tools
---
Your job is to explore and summarize. Never edit files.
Return a Markdown report with file:line references.
# .claude/agents/builder.md
---
name: builder
description: Implementation
tools: [Read, Edit, Write, Bash]
---
Implement based on the plan provided. Run tests after each edit.
Never edit files in test/ or migrations/.
# .claude/agents/reviewer.md
---
name: reviewer
description: Read-only PR review
tools: [Read, Bash]
---
Review the diff. List bugs and risks. Never edit.Spawning them right
Sequenced parallelism. Some steps fan out, some serialize. The orchestrator (you, or the main session) decides.
# In Claude Code main session:
"Spawn a scout subagent. Have it explore src/auth/ and write a
Markdown plan for the refactor we discussed. Wait for its report."
# Once the plan exists:
"Spawn a builder subagent for each of the 4 plan steps in parallel,
with each one on its own branch named refactor/auth-step-1 through 4.
Do not start step 2-4 until step 1's branch passes CI."
# Then:
"Spawn a reviewer subagent for each PR. Aggregate the findings into one report."Merge conflict survival
- 1Branch-per-agent is the only safe pattern when changes touch shared code
- 2After all agents finish, merge serially — pick the most surgical first, rebase the rest on top
- 3When two agents propose conflicting changes, do not let a third agent resolve it; you do
- 4Use `git rerere` to remember conflict resolutions across rebases
- 5Run the full test suite after each merge, not just at the end
Communication between agents
Subagents in Claude Code don't share memory. They communicate via the orchestrator (the main session) or via files written to disk. A common pattern: each subagent writes a `.claude/scratch/<agent-name>.md` report; the orchestrator reads all of them and synthesizes. Files are the message bus.
When to NOT use multiple agents
- Tasks under 30 minutes — coordination overhead exceeds parallelism win
- Refactors touching shared types or core abstractions
- Anything you wouldn't comfortably hand to multiple junior engineers without coordination
- When you don't have CI green on the base branch — agents can't tell what their changes broke
“Ten agents in parallel is ten interns who never sleep. Ship the standards, not the code.”
Key terms in this lesson
The big idea: parallel agents are an organizational skill more than a technical one. Pick the coordination pattern that matches the work, scope each agent's tools and paths, branch aggressively, and serialize merges. Done well, you outpace the team. Done poorly, you create the kind of mess one engineer would never make alone.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Multi-Agent Coordination — When Subagents Step on Each Other”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 50 min
The Landscape: Copilot vs. Cursor vs. Windsurf vs. Claude Code
The AI coding tool market fragmented fast. Let's map the 2026 landscape honestly: who is for autocomplete, who is for agents, who wins on cost, and what the tradeoffs actually feel like.
Creators · 55 min
Red-Teaming Your AI-Generated Code
Agents ship working code that's also quietly insecure. Red-teaming means actively attacking your own code. Let's build the habits that catch real-world exploits before attackers do.
Creators · 45 min
Building With v0, Lovable, and Bolt (Fast App Prototyping)
AI app builders turn a prompt into a running app in minutes. Learn the strengths, the ceilings, and the moment you should eject to a real IDE.
