Claude Code Sub-agents Guide -- Knowledge Bank
Authoritative guidance for configuring and using Claude Code sub-agents, extracted from
Anthropic's official documentation. Covers built-in agents, custom agents, agent teams,
cost management, and troubleshooting.
Source Authority
This skill draws from:
- Official Claude Code documentation at code.claude.com/docs/en/sub-agents
- Official Claude Code documentation at code.claude.com/docs/en/agent-teams
- Official Claude Code documentation at code.claude.com/docs/en/costs
- Official Claude Code documentation at code.claude.com/docs/en/model-config
Reference files are the primary source. Community intel is opt-in via
/newsroom:investigate -- see Community Perspective below.
Community Perspective (Opt-In)
This skill does NOT maintain a community intel cache. It can hand off to
/newsroom:investigate for live community signal when the user wants real-world examples.
Auto-detect these signals -- if the user's question contains any of these, offer to
run community research:
- "what are people doing with subagents", "how are others using agents"
- "has anyone", "examples in the wild", "inspiration"
- "community", "Reddit", "what's trending"
- "real-world examples", "cool agent setups"
- "best agents", "popular agents"
When detected:
- Answer from reference files first (the official answer)
- Then invoke
/newsroom:investigate with a tailored query
- Present both: "Here's what the docs say" followed by "Here's what the community is doing"
Do NOT auto-invoke research for standard doc questions.
Step 1: Classify the Question
Parse the user's question into one or more intent categories.
| Intent |
Trigger Signals |
Reference File |
| Getting Started |
what is a subagent, how do subagents work, Task tool, built-in agents, Explore agent, Plan agent, general-purpose agent, when to use subagent |
fundamentals.md |
| Configuration |
create agent, custom agent, agent frontmatter, agent YAML, tools field, disallowedTools, permissionMode, maxTurns, agent hooks, persistent memory, memory scope, preload skills, mcpServers, agent file, .claude/agents/, --agents flag |
configuration.md |
| Agent Teams |
agent team, teammate, delegate mode, shared task list, team lead, spawn teammate, parallel sessions, team coordination, in-process mode, split panes, tmux |
agent-teams.md |
| Costs & Models |
agent cost, agent tokens, pricing, model selection, haiku, sonnet, opus, CLAUDE_CODE_SUBAGENT_MODEL, prompt caching, auto-compaction, reduce cost, token usage, context window |
costs-and-models.md |
| Patterns |
best practices, when to use, subagent vs skill, subagent vs agent team, parallel research, chain agents, isolate output, permission scoping, foreground, background, resume agent |
patterns-and-best-practices.md |
| Troubleshooting |
agent not working, agent not spawning, subagent error, permission denied, MCP not available, background agent failed, agent stuck, orphaned session, team not appearing |
troubleshooting.md |
Step 2: Read Reference Files
Read the relevant reference file(s) based on the classification. For multi-intent
questions, read all relevant files.
Step 3: Synthesize Answer
Response Structure
Every response should follow this structure:
- Direct answer -- one-line answer, no preamble
- Minimal example -- copy-paste ready YAML config, agent file, or command
- Why it works -- brief explanation of the design decision
- Verify step -- how to test it ("run /agents", "check agent appears")
- Common failure -- what goes wrong and how to fix it
- Source -- reference file cited
For Getting Started Questions
- Show the three execution models (subagents, agent teams, skills)
- List the built-in agents with model/tools/purpose
- Show a minimal custom agent file
- Link to configuration.md for full setup
For Configuration Questions
- Show the exact YAML field and its purpose
- Show a minimal agent file with the field in context
- Note constraints (scope priority, naming rules)
- Cross-reference related fields
For Agent Teams Questions
- Compare with subagents (communication, context, coordination, cost)
- Show how to enable and start a team
- Include display mode options
- Note experimental status and limitations
For Cost Questions
- Show official cost numbers ($6/dev/day average)
- Present model selection guidance (haiku/sonnet/opus)
- Show CLAUDE_CODE_SUBAGENT_MODEL env var
- Note agent team cost multiplier (~7x)
For Pattern Questions
- Show the decision matrix (when to use what)
- Provide the complete pattern with example
- Explain trade-offs (cost, latency, context)
- Include gotchas
For Troubleshooting Questions
- Match symptoms to common causes
- Provide debug steps in order of likelihood
- Include exact commands or settings to verify
- Note known limitations
Response Guidelines
- Always cite the reference file you draw from
- Provide copy-paste agent configs -- users should be able to use them immediately
- Show YAML frontmatter for agent definitions
- Be direct -- answer first, then context
- Tables for comparisons -- subagent vs team vs skill, built-in agents, model costs
- Warn about limitations -- no nesting, no MCP in background, experimental features
- Link to sibling skills when the question crosses into hooks, skills, or MCP territory
Examples
Example 1: Getting Started
User: What are subagents in Claude Code?
Skill: [Reads fundamentals.md]
Subagents are isolated AI workers that run in their own 200k context window.
They handle a task and return a summary to your main conversation.
Three built-in subagents:
| Agent | Model | Tools | Purpose |
|-------|-------|-------|---------|
| Explore | Haiku | Read-only | Codebase search |
| Plan | Inherits | Read-only | Research during plan mode |
| General-purpose | Inherits | All | Complex multi-step tasks |
You can also create custom agents as Markdown files in .claude/agents/:
---
name: code-reviewer
description: Reviews code for quality. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a code reviewer. Analyze code for quality, security, and best practices.
Test: ask "What agents are available?" or invoke /agents.
Source: fundamentals.md
Example 2: Configuration
User: How do I restrict which tools a subagent can use?
Skill: [Reads configuration.md]
Use the `tools` field (allowlist) or `disallowedTools` field (denylist):
---
name: safe-researcher
description: Research agent with restricted capabilities
tools: Read, Grep, Glob, Bash
disallowedTools: Write, Edit
---
For finer control, use PreToolUse hooks to validate operations conditionally
(e.g., allow Bash but only for SELECT queries).
Verify: run /agents and check the agent's tool list.
Common failure: omitting the tools field entirely means the agent inherits ALL
tools from the main conversation.
Source: configuration.md
Example 3: Cross-Domain
User: Should I use a subagent or a skill for my code review workflow?
Skill: [Reads patterns-and-best-practices.md]
Use a subagent if the review reads many files and you want to keep verbose
output out of your main context. Use a skill if the review is quick and you
want results inline with your conversation.
| | Subagent | Skill |
|---|---------|-------|
| Context | Isolated 200k window | Main conversation |
| Output | Summary returned | Full output inline |
| Best for | Verbose, self-contained tasks | Reference knowledge, quick workflows |
| Cost | Higher (separate context) | Lower (shared context) |
For a comprehensive code review across many files, a subagent with
model: sonnet and read-only tools is the better choice.
Source: patterns-and-best-practices.md
Example 4: Community Perspective
User: What are people building with custom agents?
Skill: [Detects community signal -> "what are people building"]
Skill: [Reads patterns-and-best-practices.md for official patterns first]
Here's what the official docs cover for agent patterns:
[brief summary of patterns from patterns-and-best-practices.md]
Let me check what the community is building...
Skill: [Invokes /newsroom:investigate "Claude Code custom agents subagents examples"]
From the community (last 30 days):
[research results with engagement metrics]
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: nathanvale-side-quest-plugins-subagents-guide3description: Claude Code Sub-agents Guide -- Knowledge Bank4---56# Claude Code Sub-agents Guide -- Knowledge Bank78Authoritative guidance for configuring and using Claude Code sub-agents, extracted from9Anthropic's official documentation. Covers built-in agents, custom agents, agent teams,10cost management, and troubleshooting.1112## Source Authority1314This skill draws from:15- Official Claude Code documentation at code.claude.com/docs/en/sub-agents16- Official Claude Code documentation at code.claude.com/docs/en/agent-teams17- Official Claude Code documentation at code.claude.com/docs/en/costs18- Official Claude Code documentation at code.claude.com/docs/en/model-config1920Reference files are the primary source. Community intel is opt-in via21`/newsroom:investigate` -- see Community Perspective below.2223## Community Perspective (Opt-In)2425This skill does NOT maintain a community intel cache. It can hand off to26`/newsroom:investigate` for live community signal when the user wants real-world examples.2728**Auto-detect these signals** -- if the user's question contains any of these, offer to29run community research:30- "what are people doing with subagents", "how are others using agents"31- "has anyone", "examples in the wild", "inspiration"32- "community", "Reddit", "what's trending"33- "real-world examples", "cool agent setups"34- "best agents", "popular agents"3536**When detected**:371. Answer from reference files first (the official answer)382. Then invoke `/newsroom:investigate` with a tailored query393. Present both: "Here's what the docs say" followed by "Here's what the community is doing"4041**Do NOT auto-invoke research** for standard doc questions.4243## Step 1: Classify the Question4445Parse the user's question into one or more intent categories.4647| Intent | Trigger Signals | Reference File |48|--------|----------------|----------------|49| **Getting Started** | what is a subagent, how do subagents work, Task tool, built-in agents, Explore agent, Plan agent, general-purpose agent, when to use subagent | [fundamentals.md](references/fundamentals.md) |50| **Configuration** | create agent, custom agent, agent frontmatter, agent YAML, tools field, disallowedTools, permissionMode, maxTurns, agent hooks, persistent memory, memory scope, preload skills, mcpServers, agent file, .claude/agents/, --agents flag | [configuration.md](references/configuration.md) |51| **Agent Teams** | agent team, teammate, delegate mode, shared task list, team lead, spawn teammate, parallel sessions, team coordination, in-process mode, split panes, tmux | [agent-teams.md](references/agent-teams.md) |52| **Costs & Models** | agent cost, agent tokens, pricing, model selection, haiku, sonnet, opus, CLAUDE_CODE_SUBAGENT_MODEL, prompt caching, auto-compaction, reduce cost, token usage, context window | [costs-and-models.md](references/costs-and-models.md) |53| **Patterns** | best practices, when to use, subagent vs skill, subagent vs agent team, parallel research, chain agents, isolate output, permission scoping, foreground, background, resume agent | [patterns-and-best-practices.md](references/patterns-and-best-practices.md) |54| **Troubleshooting** | agent not working, agent not spawning, subagent error, permission denied, MCP not available, background agent failed, agent stuck, orphaned session, team not appearing | [troubleshooting.md](references/troubleshooting.md) |5556## Step 2: Read Reference Files5758Read the relevant reference file(s) based on the classification. For multi-intent59questions, read all relevant files.6061## Step 3: Synthesize Answer6263### Response Structure6465Every response should follow this structure:66671. **Direct answer** -- one-line answer, no preamble682. **Minimal example** -- copy-paste ready YAML config, agent file, or command693. **Why it works** -- brief explanation of the design decision704. **Verify step** -- how to test it ("run /agents", "check agent appears")715. **Common failure** -- what goes wrong and how to fix it726. **Source** -- reference file cited7374### For Getting Started Questions75761. Show the three execution models (subagents, agent teams, skills)772. List the built-in agents with model/tools/purpose783. Show a minimal custom agent file794. Link to configuration.md for full setup8081### For Configuration Questions82831. Show the exact YAML field and its purpose842. Show a minimal agent file with the field in context853. Note constraints (scope priority, naming rules)864. Cross-reference related fields8788### For Agent Teams Questions89901. Compare with subagents (communication, context, coordination, cost)912. Show how to enable and start a team923. Include display mode options934. Note experimental status and limitations9495### For Cost Questions96971. Show official cost numbers ($6/dev/day average)982. Present model selection guidance (haiku/sonnet/opus)993. Show CLAUDE_CODE_SUBAGENT_MODEL env var1004. Note agent team cost multiplier (~7x)101102### For Pattern Questions1031041. Show the decision matrix (when to use what)1052. Provide the complete pattern with example1063. Explain trade-offs (cost, latency, context)1074. Include gotchas108109### For Troubleshooting Questions1101111. Match symptoms to common causes1122. Provide debug steps in order of likelihood1133. Include exact commands or settings to verify1144. Note known limitations115116## Response Guidelines117118- **Always cite the reference file** you draw from119- **Provide copy-paste agent configs** -- users should be able to use them immediately120- **Show YAML frontmatter** for agent definitions121- **Be direct** -- answer first, then context122- **Tables for comparisons** -- subagent vs team vs skill, built-in agents, model costs123- **Warn about limitations** -- no nesting, no MCP in background, experimental features124- **Link to sibling skills** when the question crosses into hooks, skills, or MCP territory125126## Examples127128### Example 1: Getting Started129130```text131User: What are subagents in Claude Code?132133Skill: [Reads fundamentals.md]134135Subagents are isolated AI workers that run in their own 200k context window.136They handle a task and return a summary to your main conversation.137138Three built-in subagents:139140| Agent | Model | Tools | Purpose |141|-------|-------|-------|---------|142| Explore | Haiku | Read-only | Codebase search |143| Plan | Inherits | Read-only | Research during plan mode |144| General-purpose | Inherits | All | Complex multi-step tasks |145146You can also create custom agents as Markdown files in .claude/agents/:147148 ---149 name: code-reviewer150 description: Reviews code for quality. Use proactively after code changes.151 tools: Read, Grep, Glob, Bash152 model: sonnet153 ---154 You are a code reviewer. Analyze code for quality, security, and best practices.155156Test: ask "What agents are available?" or invoke /agents.157158Source: fundamentals.md159```160161### Example 2: Configuration162163```text164User: How do I restrict which tools a subagent can use?165166Skill: [Reads configuration.md]167168Use the `tools` field (allowlist) or `disallowedTools` field (denylist):169170 ---171 name: safe-researcher172 description: Research agent with restricted capabilities173 tools: Read, Grep, Glob, Bash174 disallowedTools: Write, Edit175 ---176177For finer control, use PreToolUse hooks to validate operations conditionally178(e.g., allow Bash but only for SELECT queries).179180Verify: run /agents and check the agent's tool list.181182Common failure: omitting the tools field entirely means the agent inherits ALL183tools from the main conversation.184185Source: configuration.md186```187188### Example 3: Cross-Domain189190```text191User: Should I use a subagent or a skill for my code review workflow?192193Skill: [Reads patterns-and-best-practices.md]194195Use a subagent if the review reads many files and you want to keep verbose196output out of your main context. Use a skill if the review is quick and you197want results inline with your conversation.198199| | Subagent | Skill |200|---|---------|-------|201| Context | Isolated 200k window | Main conversation |202| Output | Summary returned | Full output inline |203| Best for | Verbose, self-contained tasks | Reference knowledge, quick workflows |204| Cost | Higher (separate context) | Lower (shared context) |205206For a comprehensive code review across many files, a subagent with207model: sonnet and read-only tools is the better choice.208209Source: patterns-and-best-practices.md210```211212### Example 4: Community Perspective213214```text215User: What are people building with custom agents?216217Skill: [Detects community signal -> "what are people building"]218Skill: [Reads patterns-and-best-practices.md for official patterns first]219220Here's what the official docs cover for agent patterns:221[brief summary of patterns from patterns-and-best-practices.md]222223Let me check what the community is building...224225Skill: [Invokes /newsroom:investigate "Claude Code custom agents subagents examples"]226227From the community (last 30 days):228[research results with engagement metrics]229```230231---232> Converted and distributed by [TomeVault](https://tomevault.io/claim/nathanvale) — claim your Tome and manage your conversions.233<!-- tomevault:4.0:skill_md:2026-04-16 -->