Loading learning content…
Loading learning content…
Orchestrate parallel work with Claude Code's agent system — dispatch subagents for independent tasks and synthesize results.
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.
Claude Code can spawn subagent instances to work on independent tasks in parallel. The main agent orchestrates high-level decisions; subagents execute focused subtasks. This dramatically speeds up complex work.
Use subagents when tasks are:
Examples:
Spawn a subagent to: audit src/lib/auth.ts for security issues.
Report back with a ranked list of findings.
The subagent receives a fresh context, executes the task, and returns results to the main agent.
Send the same task to multiple specialized subagents:
Dispatch three subagents in parallel:
1. Security reviewer — analyze the API routes for vulnerabilities
2. Performance reviewer — identify N+1 queries and slow operations
3. Type safety reviewer — find any use of 'any' or missing types
Each agent focuses on its specialty. You get three expert analyses simultaneously.
After subagents complete, ask the main agent to synthesize:
Combine the three review reports into a prioritized action list,
grouping related issues and ordering by severity.
Subagents don't share context with the main agent by default. This is a feature — it prevents one agent's confusion from polluting another's work. Be explicit about what context a subagent needs:
Spawn a subagent with this context: [paste relevant background].
Task: write a comprehensive test suite for the payment module.
Each subagent uses tokens. For expensive operations, estimate cost first:
Before spawning, estimate how many tokens this audit will use and
whether it's worth doing as a subagent vs. sequential analysis.