The Technique: Teaching Your Central AI to Delegate
Your main Claude Code chat session isn't just one AI—it's an orchestration system. This "central AI" coordinates specialist sub-agents, and the quality of your work depends entirely on how well you've taught it to delegate. Without explicit routing rules in your CLAUDE.md, it defaults to conservative sequential execution—safe but slow.
Why It Works: Matching Execution Patterns to Task Dependencies
Claude Code's Task tool supports three execution modes, each serving different needs:
Parallel Execution works when tasks span independent domains. The central AI should dispatch parallel sub-agents when work touches different files or unrelated code sections. Without domain-based routing rules, it won't recognize these boundaries.
Sequential Execution is necessary when output from one step feeds the next. Common chains include: refactoring → testing, API design → implementation, or data model changes → migration scripts. Without chain definitions, your central AI might parallelize work that must be serial.
Background Execution keeps your main session responsive during research tasks. When the central AI spawns documentation lookups, codebase exploration, or performance profiling, it should background them automatically so you can continue working.
How To Apply It: CLAUDE.md Routing Framework
Add this decision framework to your project's CLAUDE.md:
## Sub-Agent Execution Rules
### Parallel Execution (Domain-Based Splitting)
Run in parallel when tasks involve:
- Different files or modules
- Independent features/components
- Separate API endpoints
- Unrelated bug fixes
Example: "Add user authentication and implement payment processing" → spawn two parallel agents.
### Sequential Execution (Dependency Chains)
Run sequentially when tasks depend on:
- Refactoring → testing
- API design → implementation
- Data model changes → migration scripts
- Core logic → UI integration
Example: "Redesign database schema and update all queries" → single agent completes both steps.
### Background Execution Rules
Run in background automatically:
- Web research and documentation lookups
- Codebase exploration and analysis
- Security audits and performance profiling
- Any task where results aren't immediately needed
Press Ctrl+B during any sub-agent execution to force background mode.
Check `/tasks` anytime to see background agent progress.
Advanced Configuration: Model Selection and Persistent Agents
Beyond routing rules, you have direct control over sub-agent behavior:
Choose the Sub-Agent Model by setting CLAUDE_CODE_SUBAGENT_MODEL in your environment. This is one of the most impactful optimizations for cost and speed:
# Run main session on Opus, sub-agents on Sonnet
export CLAUDE_CODE_SUBAGENT_MODEL=claude-3-5-sonnet-20241022
This pattern cuts costs significantly without sacrificing quality on well-scoped sub-agent work.
Define Persistent Agents in .claude/agents/ as Markdown files with YAML frontmatter. These specialist agents are available to Claude's orchestrator automatically:
---
name: security-auditor
description: Specializes in security vulnerability scanning
model: claude-3-5-sonnet-20241022
auto_background: true
---
I am a security specialist who examines code for vulnerabilities...
Project agents (.claude/agents/) are specific to your repository and shareable with your team. User agents (~/.claude/agents/) are available across all your projects.
The Result: Smarter, Faster Development
With these routing rules configured, your central AI makes delegation decisions based on your project's actual structure and dependencies. Parallel execution accelerates independent work, sequential chains maintain integrity for dependent tasks, and background research keeps your main session responsive.
Check /tasks regularly to monitor sub-agent progress, and remember that Ctrl+B is always available to manually background any task that's blocking your workflow.





