Claude Code Sub Agent Best Practices: Parallel, Sequential, Background
Configure your central Claude thread to automatically choose the right sub-agent execution pattern. Master parallel, sequential, and background delegation.
Problem: Your main Claude Code session (the "central AI") spawns sub-agents constantly, but it doesn't inherently know when to run them in parallel versus sequential chains versus background. Without explicit routing rules in your CLAUDE.md, it guesses - and often guesses wrong.
Quick Win: Add this routing decision framework to your CLAUDE.md:
Your central Claude thread reads these rules and makes smarter delegation decisions automatically.
Teaching Your Central AI to Delegate
Here's what most developers miss: Claude Code isn't one AI - it's an orchestration system. Your main chat session is the "central AI" that coordinates specialist sub-agents. The quality of your work depends on how well you've taught that central thread to delegate.
The Task tool supports three execution modes. Each serves different needs:
| Pattern | Central AI Uses When | Risk If Wrong Choice |
|---|---|---|
| Parallel | Independent domains, no file overlap | Merge conflicts, inconsistent state |
| Sequential | Dependencies exist, shared resources | Wasted time on serialized independent work |
| Background | Research while user continues working | Lost results if not checked |
Without explicit rules, your central AI defaults to conservative sequential execution - safe but slow.
Parallel: Domain-Based Splitting
The central AI should dispatch parallel sub-agents when work spans independent domains. Configure domain-based routing in your CLAUDE.md:
The critical rule: Parallel only works when agents touch different files. Your central AI needs to understand domain boundaries to route correctly.
Sequential: Dependency Chains
When output from one step feeds the next, the central AI must enforce ordering. Common chains:
| Chain | Why Sequential |
|---|---|
| Schema -> API -> Frontend | Data structure must exist before interfaces |
| Research -> Planning -> Implementation | Understanding before execution |
| Implementation -> Testing -> Security | Build, validate, then audit |
Add chain definitions to your CLAUDE.md so the central AI recognizes dependency patterns and doesn't parallelize work that must be serial.
Background: Non-Blocking Research
When the central AI spawns research tasks, it should background them automatically so you can continue working. Press Ctrl+B during any sub-agent execution, or configure automatic backgrounding:
Check /tasks anytime to see background agent progress. Results surface when complete. See async workflows for the full background execution guide.
The Invocation Quality Problem
Most sub-agent failures aren't execution failures - they're invocation failures. The central AI spawns a sub-agent with vague instructions, insufficient context, or unclear deliverables. The sub-agent does its best with bad input.
Bad invocation: "Fix authentication"
Good invocation: "Fix OAuth redirect loop where successful login redirects to /login instead of /dashboard. Reference the auth middleware in src/lib/auth.ts."
The difference is context density. Sub-agents have temporary context windows - they can't go back and ask clarifying questions. Your central AI needs rules for crafting complete invocations.
This is where most CLAUDE.md configurations stop. They handle routing but not invocation quality. Professional Claude Code setups include full invocation protocols that ensure sub-agents receive comprehensive context, explicit instructions, relevant file references, and clear success criteria with every dispatch.
Common Orchestration Mistakes
Over-parallelizing: Launching 10 parallel agents for a simple feature wastes tokens and creates coordination overhead. Group related micro-tasks.
Under-parallelizing: Running four independent analyses sequentially when they could parallelize. Look for domain independence.
Vague invocations: Sending sub-agents with "implement the feature" instead of specific scope, file references, and expected outputs.
Level Up Your Orchestration
The routing rules above will immediately improve how your central AI delegates work. But there's more to professional orchestration:
- Constitutional invocation requirements - ensuring every sub-agent dispatch includes the four essential components
- Agent routing tables - mapping task types to specialist agents by domain
- Context handoff protocols - preserving state across sequential agent chains
- Session-based coordination - tracking multi-phase implementations
For the complete sub-agent orchestration system used in ClaudeFast - including our full invocation protocol and specialist agent definitions - check out the Code Kit in the button by the table of contents.
Start with the routing rules. Add them to your CLAUDE.md today and watch your central AI make smarter delegation decisions. For deeper patterns, explore task distribution and agent fundamentals.
Last updated on