Sub-Agents â Delegate Large Work Without Losing Main Context
Why Sub-Agents Are Helpful
Sub-agents let you keep the main conversation focused while delegating a larger unit of work to a specialist.
This is most useful when:
- one task needs deep focus (migration, refactor, incident triage)
- you want independent reasoning threads in parallel
- you need the main chat to stay concise and decision-focused
In practice, sub-agents reduce context clutter and improve throughput on bigger tasks.
Claude Code Sub-Agents
Claude Code supports built-in and custom sub-agents. Custom definitions can be project-scoped or personal:
- project:
.claude/agents/ - personal:
~/.claude/agents/
Helpful capabilities:
- route specialized tasks to purpose-built agent roles
- invoke by name for explicit delegation
- run multiple sub-agents in parallel for independent workstreams
OpenCode Sub-Agents
OpenCode also supports custom agents, with common locations:
- project:
.opencode/agents/ - global:
~/.config/opencode/agents/
This gives a similar delegation model: keep the main chat as coordinator, dispatch substantial tasks to specialized agents, then merge results.
Practical Delegation Pattern
- Keep the main chat for goals, constraints, and final decisions
- Delegate one clear deliverable per sub-agent
- Require each sub-agent to return three items: what changed, what was verified, and open risks/questions
- Merge results in main chat and decide next step
Good First Use Cases
- âRefactor module X and keep API compatibilityâ
- âAdd tests for changed files onlyâ
- âAudit this diff for security regressionsâ
- âDraft migration plan plus rollback checksâ
Common Mistakes
Vague delegation. âLook at thisâ is too broad; assign a concrete output.
No integration contract. Require output shape so results are mergeable.
Over-fragmentation. Too many sub-agents on tiny tasks adds overhead instead of speed.