Sub-agents in Claude Code: when to use them
Dev.to AI
•
Generative AI
Claude Code can spawn sub-agents - separate Claude sessions that run a focused task and return results. This is different from running everything in one session. When sub-agents help Parallel independent work. If you have three unrelated tasks, running them as sub-agents in parallel is faster than doing them sequentially in one session. Each sub-agent has fresh context, no accumulation from previous tasks. Isolation for risky operations. If one task might go wrong and mess up session state, running it as a sub-agent contains the damage. Large codebases.