Claude Code subagents: what they inherit and how to write one Claude Code subagents run in their own context window with their own system prompt, tool access and permissions, and return only their result to the main conversation, according to Anthropic's Claude Code subagents documentation. A custom subagent is a Markdown file placed in `.claude/agents/` for a project or `~/.claude/agents/` for a user, and a session runs at most 20 subagents at once by default. Subagents do not inherit conversation history, invoked skills or files Claude already read, and Claude Code warns at startup when the combined descriptions of custom subagents pass 15,000 tokens. Claude Code subagents: what they inherit and how to write one Claude Code subagents are specialized workers the agent delegates to: each runs in its own context window with its own system prompt, tool access and permissions, and returns only its result to the main conversation. Use one when a side task would flood your conversation with search results or logs you will not reference again. This post covers the built-in subagents, how to create subagents in Claude Code, what a subagent inherits — and what it does not — and where agent teams fit. The built-in subagents Claude Code ships three it uses on its own, per the subagents documentation https://code.claude.com/docs/en/sub-agents : | Subagent | Tools | Purpose | |---|---|---| | Explore | Read-only; Write and Edit denied | File discovery and code search | | Plan | Read-only; Write and Edit denied | Codebase research during plan mode | | general-purpose | Every tool available to subagents | Multi-step tasks that explore and modify | Explore and Plan start without your CLAUDE.md files and the git status snapshot, to keep research fast. By default a session runs at most 20 subagents at once; spawning another past that fails until one finishes. Writing your own A custom subagent is a Markdown file: project-level in .claude/agents/ , user-level in ~/.claude/agents/ . The frontmatter names it and says when to delegate; the body is its system prompt. One of the most copied Claude Code subagents examples is a read-only reviewer: --- name: code-reviewer description: Reviews a diff for correctness and missed edge cases. Use after a change is complete, before committing. tools: Read, Grep, Glob --- You review code changes. Read the diff, then the files it touches. Report findings by severity with file and line. Do not edit files. The description is what Claude reads to decide when to delegate, so write it as a trigger, not a biography. Descriptions cost context: when the combined descriptions of your custom subagents pass 15,000 tokens, Claude Code warns at startup. Keep them short and move detail into the body, which loads only when the subagent runs. What loads at startup A subagent starts fresh. It does not see your conversation history, the skills you invoked, or the files Claude already read — Claude writes a delegation message summarizing the task, and the subagent works from that. Its initial context holds: - Its own system prompt plus environment details, not the Claude Code system prompt. - The delegation task message. - The CLAUDE.md hierarchy the main conversation loads, including AGENTS.md read as project instructions — except for the built-in Explore and Plan agents, which skip it. - The git status snapshot. The frontmatter field omitClaudeMd: true narrows this further: the subagent loads only managed policy files. This is the core of Claude Code subagents best practices — a subagent follows the rules written in files it loads, and nothing else you said in the parent conversation. A rule you stated only in chat does not reach it. Permissions and tools Two layers fence a subagent. The tools and disallowedTools fields shape its tool pool; a disallowedTools entry with a specifier, such as Bash git push , removes the whole tool rather than the matching commands. For command-level limits, a deny rule in permissions.deny applies to the main conversation and to subagents alike — the permissions guide https://besydr.com/blog/claude-code-permissions-guide covers the rule format. The permissionMode field chooses the mode a subagent runs in, but the main conversation can override it. When the main conversation is in default or dontAsk mode, the subagent runs in the mode you set — except a request for bypassPermissions , which keeps the main conversation's mode instead. When the main conversation is in plan mode, the subagent stays in plan mode whichever permissionMode you set. Subagent files can also define their own PreToolUse , PostToolUse and Stop hooks in frontmatter; project-level ones run only after you trust the folder. Custom subagents Claude spawns from the main conversation start in the background by default, which is how Claude Code runs parallel agents without blocking your conversation. For foreground work, ask Claude to wait for the result. Subagents and agent teams Agent teams are the experimental step beyond subagents: teammates share a task list, claim work and message each other directly, instead of reporting back to one caller. They are disabled by default; to enable agent teams in Claude Code, set CLAUDE CODE EXPERIMENTAL AGENT TEAMS=1 in your environment or in the env block of settings.json. The agent teams documentation https://code.claude.com/docs/en/agent-teams has the full setup, including split-pane display under tmux or iTerm2. | | Subagents | Agent teams | |---|---|---| | Context | Own window; result returns to the caller | Own window; fully independent | | Communication | Report back to the caller | Teammates message each other | | Coordination | Main agent manages all work | Shared task list and self-coordination | | Token cost | Lower: summarized results | Higher: each teammate is a separate instance | | Best for | Focused tasks where only the result matters | Work that needs discussion and collaboration | Teams add real limits: one team per session, no nested teams, no session resumption of in-process teammates, and no teammate spawning in headless -p runs. For most work, subagents are the cheaper tool; reach for a team when parallel exploration genuinely needs to challenge itself. What supervision reaches a child A subagent's isolation cuts both ways: it keeps noise out of your conversation, and it keeps your stated rules out of the worker. Besydr say: besider , a program that runs beside a coding agent and learns from its sessions, documents exactly what reaches a child session in its client table https://besydr.com/docs/clients : Claude Code child hooks run the standing safety checks in the child's working directory, and only denial decisions return to the child. The request checklist, pinned rules and recalls stay with the parent; child compaction events do nothing, and SubagentStop is a parent lifecycle notification. The child's checks count toward the parent session's activity log. So a forbidden call can be denied inside the child, while the checklist that judges the finished work belongs to the parent request. On OpenCode a subagent runs as a session of its own and is reported as one; Codex reports child tool calls to the parent's standing checks. The local program is free with octomind and needs a licence https://besydr.com/pricing with Claude Code after a trial. Sources and method - Built-in subagents, file format, startup context, tools, permission modes and frontmatter hooks: the subagents page https://code.claude.com/docs/en/sub-agents , read 2026-11-30. - Agent teams: enabling, comparison and limits: the agent teams page https://code.claude.com/docs/en/agent-teams , read 2026-11-30. - The reviewer file is an example written for this post from the documented format, not a tested configuration. - Besydr's child-session behavior: the clients documentation https://besydr.com/docs/clients . - This post was drafted with AI assistance from these sources.