claude-subagent-reference
SOURCE: https://code.claude.com/docs/en/sub-agents (accessed 2026-09-24)
Claude Code Subagents — Reference
Subagents are specialized AI assistants that run in their own context window with custom system prompts, specific tool access, and independent permissions. Use one when a task would flood your main conversation with output you won't reference again; the subagent does the work in its own context and returns only a summary.
Subagents help you:
- Preserve context by keeping exploration and implementation out of your main conversation
- Enforce constraints by limiting which tools a subagent can use
- Reuse configurations across projects with user-level subagents
- Control costs by routing tasks to faster, cheaper models like Haiku
Subagents can spawn nested subagents up to three layers below the main conversation by default. Set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH; 1 disables nesting. At the limit Claude Code withholds Agent, except forks retain it and receive an error. Interactive launchers wait for background children; non-interactive launchers report late child results to the main conversation. A fork cannot spawn another fork.
SOURCE: https://code.claude.com/docs/en/sub-agents#let-subagents-spawn-their-own-subagents (accessed 2026-09-24)