Loading learning content…
Loading learning content…
Spawn subagents for parallel work, keep main context clean, and coordinate complex tasks.
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 subagents — separate Claude instances that run a focused task and return a result. This keeps your main session context clean and enables parallel work.
Subagents are launched via the Task tool internally, or you can orchestrate them explicitly by asking Claude to "spawn a subagent to handle X."
Long sessions accumulate context. As your conversation grows, Claude's reasoning quality can degrade. Subagents reset the context for each task, giving you full capability on every job.
Use subagents for:
You can direct Claude to spawn a subagent with a structured instruction:
"Spawn a subagent to audit all API routes for missing authentication. It should read each file in
src/app/api/, check for auth middleware, and return a list of unprotected routes."
The subagent completes its task and returns the output to your main session.
For truly independent tasks, spawn multiple subagents simultaneously:
"Spawn three subagents in parallel:
- Review
src/lib/auth/for security issues- Check
src/app/api/for missing input validation- Audit
src/lib/db/for N+1 query patterns"
All three run concurrently and return results for you to review.
Subagents don't automatically inherit main session context. Provide them with explicit file paths and instructions. The more precise your subagent brief, the better the output.
Think of subagents like a PM delegating to engineers: clear scope, defined deliverable, no ambiguity.