Loading learning content…
Loading learning content…
Parallel subagents, background tasks, fan-out pipelines, and multi-agent orchestration at scale.
Read through the lesson, mark it complete when the concept is clear, then move to the next lesson in the sequence or jump back to the module map.
AI-narrated from the written lesson.
At scale, Claude Code is an orchestrator, not just a coder. The main session plans, decides, and tracks progress; implementation work goes to subagents with focused briefs.
Key principle: keep the main session clean. Every file read and command output consumes context. Delegating bulk work to subagents keeps the orchestrating session sharp for decisions.
Claude Code can spawn subagents — separate sessions with their own context windows — to work on independent subtasks. Two patterns cover most real work:
Fan-out — dispatch several subagents in parallel on independent slices, then collect results. Classic for audits, bulk transforms, and multi-file analysis. Give each agent a non-overlapping file domain so two agents never edit the same code.
Pipeline — chain stages where each step feeds the next: research → spec → implement → review. Use when later stages depend on earlier outputs.
For parallel agents that write code, isolate each one in its own git worktree (git worktree add) so every agent works on its own branch without stepping on the others.
Long-running work — builds, test suites, batch jobs — can run in the background while you keep working. Start the task, continue in the session, and review the output when it completes. This is the difference between babysitting a ten-minute test run and getting on with the next task.
Claude Code also runs non-interactively (claude -p "your prompt"), which makes it scriptable: CI checks, scheduled jobs, batch processing over a task list. Define the tasks in a structured file, loop over them in a script, and review the results when you're back at your desk.
Every multi-agent system reduces to the same shape: a coordinator with a task queue, workers with execution authority over a bounded scope, and a reporting channel back to the coordinator.
Start small — one coordinator, two workers, non-overlapping scopes, and a review gate before any worker's output merges. The pattern scales to dozens of parallel agents, but the discipline (bounded scope, mandatory review) is what makes it safe at any size.