Subagents are one of Claude Code's most powerful features. They let you delegate tasks to specialized agents running in parallel, protecting your main context and multiplying speed.
Advertisement
What is a subagent
A subagent is a Claude agent launched from the main agent to execute a specific task. It receives detailed description, operates with its own context, returns a result. The main agent doesn't get contaminated with the subagent's research details.
When to use subagents
- Wide investigations: "find all uses of this function" — Explore does the heavy lifting.
- Parallel tasks: review 3 independent files at same time.
- Second opinions: ask a code-reviewer for independent validation.
- Long work: leave a 10-min task running while you continue.
Built-in subagents
- general-purpose: catch-all.
- Explore: fast read-only for finding code.
- Plan: software architect for implementation plans.
- code-reviewer: reviews changes with structured findings.
How to invoke a subagent
In Claude Code, main agent decides when to delegate. You can ask explicitly.
How to create your own subagent
Subagents live in .claude/agents/*.md:
---
name: copy-reviewer
description: Specialist in reviewing marketing copy.
model: sonnet
tools: [Read, Grep, Write]
---
# Instructions
You are a senior copy reviewer with 10 years experience...
Best practices
- Specific descriptions.
- Minimum tools.
- Structured output.
- Don't abuse: if task is simple, main agent solves faster.
Advertisement
Useful ecosystem subagents
- db-migrator: validates DB migrations before applying.
- security-scanner: reviews diff for OWASP vulns.
- test-writer: generates unit tests for a function.
- doc-generator: creates docs from commented code.
Conclusion
Subagents turn Claude Code from assistant to orchestrator. Well used, they change productivity from "I do things with AI" to "I coordinate agents that do things".