**Short version:** a subagent is a specialist with a clean desk. Claude hands it a task, it works in its own context window — reading files, running tests, grepping logs — and only a summary comes back. Your main conversation stays small and focused. All details below are from Anthropic's subagents documentation.
Why subagents exist: context isolation
Every subagent starts with a fresh context window. It does not see your conversation history or files you already read; Claude writes it a delegation message instead. Verbose output — test runs, logs, file contents — stays inside the subagent, and only the relevant summary returns. That is the whole point: a 4,000-line test log never touches your main context.
This is also a cost lever. If your sessions balloon, routing noisy work to subagents pairs well with the fixes in our token usage guide.
Where subagent files live

| Location | Scope | Priority |
|---|---|---|
| Managed settings | Organisation-wide | 1 (highest) |
--agents CLI flag | Current session | 2 |
.claude/agents/ | Current project | 3 |
~/.claude/agents/ | All your projects | 4 |
A plugin's agents/ folder | Where the plugin is enabled | 5 (lowest) |
When two subagents share a name, the higher-priority location wins. Project subagents can be committed so your whole team gets them.
A working example
This is the example from Anthropic's docs — a read-only reviewer on a cheaper model:
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer. When invoked, analyze the code and provide
specific, actionable feedback on quality, security, and best practices.Only name and description are required. The useful optional fields:
tools/disallowedTools— omittoolsand the subagent inherits everything; list them to keep a reviewer read-onlymodel—sonnet,opus,haiku,fable, a full model ID, orinheritpermissionMode,maxTurns,skills,mcpServers,hooks,memory
Best practices that actually change results
- Write the description for delegation. Claude decides when to delegate from the task, each subagent's
description, and context. Phrases like "use proactively" encourage automatic delegation. - Keep descriptions short. When combined custom subagent descriptions exceed 15,000 tokens, Claude Code warns at startup.
- Give the minimum tools. A reviewer that can only Read, Glob and Grep cannot accidentally edit your code.
- Route by model. Search and summarising rarely need your most expensive model.
You can also call a subagent explicitly by naming it, @-mentioning it, or running a whole session as one with --agent. Subagents load CLAUDE.md files, except the built-in Explore and Plan agents, which skip them.
Subagents vs skills vs agent teams

- Skill — reusable instructions that run in the main conversation. Use when the result needs your full context.
- Subagent — a task in an isolated context that returns a summary. Use when the work is noisy.
- Agent team — several sessions Claude spawns and supervises. Use for genuinely parallel, multi-session work.
They combine: a subagent can preload skills through its `skills` field, and a skill can run in a subagent with `context: fork`. Subagents can also be packaged and shared inside Claude Code plugins.
**Related:** Claude Code vs Codex · Claude Code hooks examples