Claude Code Subagents: How to Use Them (Tested on Claude Code 2.1.332)

Last updated: 3 December 2026

A long Claude Code session gets heavy. Every file read, every tangent explored, every half-finished thought stays in the context window, slowing responses and driving up token costs. Anthropic’s own guide on subagents opens with exactly that problem, and its answer is to move side work out of the main conversation: a subagent is an isolated Claude instance with its own context window. It takes a task, does the work, and returns only the result.

That sounds like free parallelism, and it is not. Each subagent starts from nothing, rebuilds its own context, spends from the same usage pool as your main conversation, and hands you back a summary of work you cannot see. Used well, subagents keep a long session clean and finish independent work faster. Used by reflex, they triple the bill and return a confident summary of something you never inspected.

This guide covers both halves: how to use subagents on Claude Code 2.1.332, and when not to. The file format, the invocation routes, and the debug-log behaviour were checked on a real install for this guide, with the exact log lines quoted. The parallel timings and the cost incidents come from two independent guides that ran them on their own projects, and the guide says which is which. One comparison the plan for this article wanted — the same feature built sequentially and in parallel, with elapsed time and /usage figures — could not be run here, because there is no authenticated session in this guide’s test environment. That gap is stated plainly below, with the exact steps to close it.

Testing status, stated plainly: Claude Code 2.1.332 was installed with npm on 30 November 2026 (Linux, Node 24.22.1) and a real custom subagent, reviewer, was written and placed in a test project at /tmp/claude-code-test/subagent-proj/.claude/agents/reviewer.md. Four claude --debug runs were made on it, plus a broken variant with a misspelled field and a variant with no description, and claude plugin validate was run on the agents directory. All of those outputs are quoted verbatim below. What was NOT run: no authenticated session. There is no Anthropic API key and no Claude subscription available to this guide, so every claude -p run stopped at Not logged in · Please run /login and no model call was made. That means the /agents listing, the @reviewer typeahead, any live delegation, and the sequential-vs-parallel timing comparison were not captured here — the guide tells you exactly how to run those checks yourself, and says so where each one appears, instead of presenting them as outputs from this run. The version in the title, 2.1.332, is the version actually installed and tested.

How this guide was researched

This guide was researched from primary and independent sources on 30 November 2026. The reproduction (the reviewer agent file, the YAML check, the four claude --debug runs, and the plugin validate run) was run the same day on Linux. The definition, the five use cases, the invocation routes, and the “when not to” list come from Anthropic’s own subagents guide, published 7 April 2026. The parallel-build walkthrough, the orchestrator pattern, and the timings come from a dev.to guide that built a six-tool self-hosted project, NEXUS, with subagents. The cost rules, the three failure incidents, and the delegation checklist come from Rough Works’ guide, published 18 November 2026, written from daily use of Claude Code. The frontmatter reference, the skip rules, the tool filters, and the concurrency limit come from the official Claude Code subagents docs, read the same day. Where a claim rests on the official docs or another guide rather than on a run in this guide, the guide says so. Prices are not involved in this guide; there is nothing to buy.

What a subagent is — and what it is not

A subagent is a second Claude that your session starts for one task. The official docs describe it this way: each one “runs in its own context window with a custom system prompt, specific tool access, and independent permissions.” It does the work, then returns a summary to the conversation that started it. Anthropic’s guide puts it as the browser tabs of a Claude Code session: a place to chase a tangent without losing the main thread.

Three facts follow from that definition, and most confusion about subagents comes from missing one of them. Rough Works states them plainly, and they are worth keeping in mind for everything that follows.

It starts cold. A subagent does not see your conversation. It gets its own system prompt, basic environment details such as the working directory, and the task prompt Claude writes for it. Whatever you worked out over the last hour is not there unless it is in that brief. The one exception is a fork, which inherits the whole conversation — more on that below.

You see the summary, not the work. The file reads, searches, and command output stay in the subagent’s context. That is the benefit — your main conversation stays clean — and it is also the risk. A subagent can return a confident summary of work you cannot inspect, and the only way to check it is to re-derive the finding yourself, which costs what you saved.

It spends from the same pool. The docs are explicit that a subagent “sends its own requests, which count toward the same usage limits as your main conversation.” Subagents save context. They do not save tokens. Anthropic’s guide says the same in its “when shouldn’t you use subagents” section: each one spins up its own context, consumes tokens, and adds a layer of indirection. They are worth that cost when context isolation, parallelism, or a fresh perspective actually helps — and not otherwise.

A subagent is also not a skill. A skill is a set of instructions loaded into the conversation you are already in; a subagent is a separate worker with a separate context window. Rough Works’ rule of thumb: if your problem is “Claude keeps doing this step wrong,” you want a skill. If it is “this search buried my conversation,” you want a subagent. The two combine — a subagent definition can preload skills through its skills field — but they solve different problems. Article 34 of this site covers skills in detail, including the YAML bug that makes them load silently.

The built-in subagents you already use

You have probably been using subagents without defining any. Claude Code ships several, and Claude delegates to them on its own. As of November 2026 the documented set is:

Built-inWhat it doesTools
ExploreFast codebase search and analysis. Claude asks for a thoroughness level: quick, medium, or very thoroughRead-only; Write and Edit are denied
PlanGathers context during plan mode before a plan is presentedRead-only
general-purposeMulti-step tasks that need both exploration and changesEvery tool available to subagents
claudeCatch-all when nothing more specific fitsEvery tool available to subagents
statusline-setup, claude-code-guideHelpers for configuring the status line and answering questions about Claude CodeNarrow

Two details matter. First, Explore and Plan start without your CLAUDE.md files, to keep research fast — other built-in and custom subagents load them, unless a custom definition sets omitClaudeMd: true. If you have rules in CLAUDE.md that a search agent appears to ignore, that is why. Second, a user or project subagent named Explore overrides the built-in and keeps its own model field, so you can define one with model: haiku to run exploration on a lower-cost model.

You can restrict the built-ins: add one to permissions.deny to block a specific type, deny the Agent tool itself to prevent Claude from delegating to any subagent, or set CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS=1 to remove only Explore and Plan (version 2.1.198 or later). In non-interactive mode and the Agent SDK, CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS=1 removes all built-in types so you can supply only your own.

A laptop screen showing a terminal with a list of running background tasks beside a notebook

How to use subagents: five routes, simplest first

Anthropic’s guide lists five ways to direct subagent usage, from a plain sentence to full automation. Start at the top and move down only when a pattern keeps recurring. Rough Works agrees, and adds the reason: they run no custom agent files on their own machine at all — everything they delegate goes to the built-in types with a carefully written brief, and a custom subagent only earns its place when the same kind of worker keeps getting spawned with the same instructions. Until then, the brief is the thing to get right.

1. Conversational invocation

The most flexible approach is simply asking Claude to use subagents in conversation. This works across all Claude Code interfaces: terminal, VS Code, JetBrains, the web, and desktop applications. Natural-language patterns that reliably invoke subagents, from Anthropic’s guide:

  • “Use a subagent to explore how authentication works in this codebase”
  • “Have a separate agent review this code for security issues”
  • “Research this in parallel. Check the API routes, database models, and frontend components simultaneously”
  • “Spin up subagents to fix these TypeScript errors across the different packages”

Being explicit matters. Specify the scope, request parallel execution when tasks are independent, and describe the desired output. Anthropic’s guide gives an effective prompt structure: clearly define the independent tasks, explicitly request parallel execution, and specify the output format. Its tips: scope tasks clearly (“Explore how payments work” beats “explore everything”); request parallelisation explicitly (“these can run in parallel”); specify what should be returned (summaries, specific findings, recommendations); and ask for fresh context when unbiased analysis matters (“Use a subagent that does not see our previous discussion”).

The dev.to walkthrough shows the same idea at larger scale. To build two features in parallel, the author wrote one prompt with a section per subagent, each with a complete spec, and a final line: “Report when both complete.” Claude Code launched both agents and managed them, showing output like “2 background agents launched (↓ to manage)” with each agent’s task listed beneath. The key detail from that walkthrough: each subagent gets its own context window, so they do not share state or interfere with each other — which is why parallel work is possible at all.

When a subagent is taking a while, Ctrl+B sends it to the background. The conversation can continue while it runs, and results surface automatically when it finishes. The /tasks command shows anything running in the background — and, on version 2.1.242 or later, names the model each subagent is running on. The dev.to guide adds a command this guide did not capture in a run: /btw, which asks for a status report on background agents without interrupting them — “how are the two background agents doing?” — and returns progress per agent while the agents keep running.

2. Custom subagents: one Markdown file

When the same kind of subagent keeps getting requested — a security reviewer, a test writer, a docs proofreader — define it once as a custom subagent. Claude then delegates to it automatically whenever a task matches its description, no prompting required. It can also be invoked by name: “Have the security-reviewer look at the staged changes.”

A custom subagent is a Markdown file with YAML frontmatter. The file location decides who gets it, and when two definitions share a name, the higher row wins:

LocationScopePriority
Managed settingsWhole organisation1 (highest)
--agents CLI flag (JSON)Current session only2
.claude/agents/Current project; commit it to share with the team3
~/.claude/agents/All your projects4
A plugin’s agents/ directoryWherever the plugin is enabled5 (lowest)

Project subagents are discovered by walking up from the current working directory, so every .claude/agents/ between there and the repository root is scanned; when more than one nested directory defines the same name, Claude Code uses the definition closest to the working directory. The docs also note that both directories are scanned recursively, so you can organise definitions into subfolders — the subdirectory path does not affect identity, because identity comes only from the name frontmatter field. The easiest way to create one is the /agents command, which walks through setup interactively; the file can also be written by hand. As of November 2026, /agents prints a reminder pointing at the two directories, where older versions opened a wizard — and it is unrelated to claude agents, the shell command that opens the background-session view.

Only name and description are required. The body of the file becomes the subagent’s system prompt — and the subagent does not receive the standard Claude Code system prompt, so anything it needs to know about how you work goes in the body or in CLAUDE.md. The full frontmatter reference, from the official docs:

FieldWhat it does
nameUnique identifier, at most 256 characters. Cannot contain :, which is reserved for plugin-scoped names such as my-plugin:reviewer. The filename does not have to match
descriptionWhen Claude should delegate to this subagent. This is what Claude reads to decide — keep it short, because descriptions take up context; Claude Code warns at startup when the combined descriptions of your custom subagents pass 15,000 tokens
toolsAllowlist, as a comma-separated string or a YAML list. Inherits every tool available to subagents if omitted. If no entry resolves to a tool, the subagent usually fails to launch with an error naming the entries
disallowedToolsDenylist. Applied first when both are set. An entry with a specifier, such as Bash(git push *), still removes the whole Bash tool
modelsonnet, opus, haiku, fable, a full model ID, or inherit. Omit it and the subagent runs on the main conversation’s model
permissionModedefault, acceptEdits, auto, dontAsk, bypassPermissions, plan, or manual
maxTurnsMaximum agentic turns before the subagent stops. When the limit is reached, the output comes back marked as partial
skillsSkills to preload into the subagent’s context at startup — the full skill content is injected, not only the description
mcpServersMCP servers available to this subagent, by name or inline definition
hooksLifecycle hooks scoped to this subagent
memoryPersistent memory scope: user, project, or local
backgroundtrue keeps the subagent in the background even when Claude asks to wait for it
omitClaudeMdtrue starts the subagent without the CLAUDE.md files in its initial context
effortEffort level when this subagent is active: low, medium, high, xhigh, max
isolationSet to worktree to run the subagent in a temporary git worktree, giving it an isolated copy of the repository
colorDisplay colour in the task list and transcript
initialPromptAuto-submitted as the first user turn when this agent runs as the main session agent

Two traps in that table. First, field names are camelCase — maxTurns, disallowedTools — and Claude Code ignores a field it does not recognise, without an error. This guide reproduced that exact behaviour (see the reviewer test below). Second, a tools allowlist decides which tools exist, not what a tool is used for: a reviewer with Bash on its list can still write files through the shell. If you want a subagent that truly cannot change anything, give it Read, Grep, Glob and nothing else — which is exactly what this guide’s reviewer artefact does.

There are two more ways to invoke a custom subagent. Type @ and pick the agent from the typeahead, or type @agent-<name> — this tells Claude to run that subagent for the task. Or run the agent as the whole session: claude --agent code-reviewer starts a session where the main thread takes on that agent’s prompt, tools, and model, and setting "agent" in .claude/settings.json makes it the project default. A fork is the variant that inherits your full conversation: start one with /subtask, and Claude starts them itself while fork mode is on, which is the default. Forks skip the cold start and carry your whole context with them — which is also why they do not save context the way a normal subagent does.

3. CLAUDE.md instructions

Custom subagents define who the specialists are. CLAUDE.md files define the rules for when Claude should reach for them. If every code review should go through a read-only subagent, or every architecture question should trigger a research pass first, CLAUDE.md is where that policy lives. Claude reads it at the start of every conversation, so the behaviour stays consistent across sessions and teammates without anyone needing to remember to ask. CLAUDE.md is a good fit when code reviews should always use read-only subagents, when the project has specific research patterns, or when consistent behaviour is needed across team members. Note the caveat from the built-ins section: Explore and Plan start without your CLAUDE.md files, so a policy written there does not reach them.

4. Skills

For complex multi-step workflows that run repeatedly, skills provide a reusable interface. Define a skill once in .claude/skills/, then invoke it with /skill-name or let Claude load it automatically when a task matches its description. Skills differ from CLAUDE.md files in scope: CLAUDE.md files are always loaded and shape every interaction, while a skill is loaded on demand. A skill is a directory, not a single file — alongside SKILL.md it can hold templates, example outputs, or scripts Claude executes as part of the workflow. Anthropic’s guide gives a deep-review skill as the example: /deep-review triggers a three-part subagent analysis on demand, and because the description mentions reviewing staged changes before commits, Claude can also reach for it automatically. Article 34 on this site is the companion piece: it reproduces the YAML bug that makes a skill load silently, and the banana-test that proves the pipeline is alive.

5. Hooks

Hooks are user-defined shell commands, HTTP endpoints, or LLM prompts that execute automatically at specific points in Claude Code’s lifecycle, and they can automate subagent workflows based on events. They are the right tool when every commit should be reviewed automatically before it is created, when security checks should run without anyone remembering to ask, or when CI-like quality gates belong in the local development process. Anthropic’s example is a Stop hook that blocks Claude from ending its turn until a test suite passes. Hooks are the most automated approach; conversational invocation or CLAUDE.md instructions are the better starting point, and hooks come later, as workflows mature.

The reviewer test: what this guide actually ran

The plan for this article wanted a measured comparison — the same feature built sequentially and in parallel, with elapsed time and /usage token and cost figures — plus a downloadable custom subagent file. The file exists and was tested. The comparison was not run, for the reason stated in the Testing status: no authenticated session. This section records exactly what was run, verbatim, so the reader can tell the difference.

The test project is a scratch directory, /tmp/claude-code-test/subagent-proj, containing a small Python file (app.py, three short functions) and the reviewer agent at .claude/agents/reviewer.md — the artefact attached to this article, 690 bytes:

---
name: reviewer
description: Reviews code changes for bugs, security issues, and style problems. Use when the user asks for a code review, asks to check recent changes, or wants a second opinion before committing.
tools: Read, Grep, Glob
model: haiku
maxTurns: 30
---

You are a code reviewer. You read code only — you never edit files.
...

One correction to the task brief, recorded honestly: the brief said Claude Code 2.1.332 was already installed in this environment. It was not — claude --version returned command not found, and no install existed in the global node modules or the home directory. It was installed fresh for this run with npm install -g @anthropic-ai/claude-code@2.1.332 (8 seconds), and claude --version then printed 2.1.332 (Claude Code).

CheckWhat was runResult, verbatim
YAML parse of the reviewer filePython yaml.safe_load on the frontmatterParses: {'name': 'reviewer', 'description': 'Reviews code changes ...', 'tools': 'Read, Grep, Glob', 'model': 'haiku', 'maxTurns': 30}
Layout auditfind .claude/agents -maxdepth 2 -iname "*.md" -printThree files listed: reviewer.md, broken-agent.md, nodescription-agent.md
Run 1: reviewer onlyclaude --debug -p "test"Stdout: Not logged in · Please run /login, exit 1
Run 2: reviewer + misspelled fieldclaude --debug -p "test" < /dev/nullStdout: Not logged in · Please run /login, exit 1; debug log line 45 (below)
Run 3: plus a file with no descriptionclaude --debug -p "test" < /dev/nullStdout: Not logged in · Please run /login, exit 1; debug log lines 46–47 (below)
Run 4: --agent reviewerclaude --debug --agent reviewer -p "test" < /dev/nullStdout: Not logged in · Please run /login, exit 1; no agent-named line in the debug log
plugin validateclaude plugin validate .claude/agents✔ Validation passed — even with the misspelled field present
/agents, @reviewer, live delegation—Not run — no authenticated session

Four findings from those runs, all from the debug logs at ~/.claude/debug/:

1. Custom agents load silently. In run 1, with only the reviewer file in place, the debug log confirms the directory is watched — [DEBUG] Watching for changes in skill/command directories: /tmp/claude-code-test/subagent-proj/.claude/agents... — and that the user and managed agents directories do not exist (Failed to stat directory /home/hatch/.claude/agents: ENOENT). But no line names the reviewer agent, and the startup line is only [STARTUP] Commands and agents loaded in 15ms. Compare that with skills, which get a Loaded 1 unique skills line in the same log format (Article 34). For agents there is no equivalent count. The reviewer file parses, and the directory is watched, so loading is inferred — but the log does not prove it. The definitive check is the /agents listing in a signed-in session, which this run could not make.

2. A misspelled field IS flagged — in the debug log, not on screen. Run 2 added broken-agent.md, identical in shape but with max_turns: 30 instead of maxTurns: 30. The debug log carries this warning, verbatim:

[WARN] Agent file /tmp/claude-code-test/subagent-proj/.claude/agents/broken-agent.md has a frontmatter key Claude Code does not recognize or apply: "max_turns" (did you mean "maxTurns"?)

That is the behaviour the official docs describe for version 2.1.296 and later: run claude --debug and search the debug log for does not recognize or apply, which names up to five unrecognised top-level fields with the likely intended name. It also proves the agent files in the project directory are parsed at startup even in a session that then stops at the login step — which is the strongest evidence this run has that reviewer.md was read too. Nothing appears on stdout; without the debug log you would never know the field was ignored.

3. A missing description is an error, and the file is skipped. Run 3 added nodescription-agent.md — a name with no description. The debug log, verbatim:

[ERROR] Agent file /tmp/claude-code-test/subagent-proj/.claude/agents/nodescription-agent.md: Missing required "description" field in frontmatter
[DEBUG] Failed to parse agent from /tmp/claude-code-test/subagent-proj/.claude/agents/nodescription-agent.md: Missing required "description" field in frontmatter

That matches the docs’ skip rules exactly. Claude Code skips a file in an agents directory when the frontmatter has no name (treated as documentation kept beside your agents), when the opening --- is not the file’s first line, when the name starts with -, contains :, or is longer than 256 characters, when there is a name but no description, or when the YAML does not parse — and writes the reason to the debug log in the last three cases.

4. plugin validate does not catch a misspelled field. Run 2’s claude plugin validate .claude/agents returned ✔ Validation passed with the max_turns file sitting in the directory. The docs say the command checks only the directory you name, and only for frontmatter that does not parse — it does not flag a file whose frontmatter parses but has an unknown field. Same lesson as Article 34’s skills finding: do not rely on plugin validate as a frontmatter check. Use the Python one-liner for YAML, and the debug log for unrecognised fields.

If a change made things worse, the agent folder is just files. Delete the file, or git checkout -- .claude/agents, and the agent is gone. Nothing outside that folder changed.

Hands on a keyboard beside a monitor showing a simple checklist document

Patterns that work

Anthropic’s guide and the dev.to walkthrough agree on four patterns, and the walkthrough adds a fifth — explicit orchestration — that matters once the work gets big.

Research before implementing. When adding a feature to unfamiliar code, delegating research to a subagent first keeps the implementation discussion informed rather than exploratory. A synthesised summary arrives instead of twenty files of raw context, and the implementation discussion starts from a solid foundation. Anthropic’s signal: gathering context requires reading dozens of files. The dev.to author used the same shape with a context header — a block at the top of each subagent’s brief giving it exactly what it needs without the whole CLAUDE.md: which service it works on, the project path, key facts (ports, colours, formats), and what not to touch. For subagents with narrow scope, targeted context is more efficient than full project context.

Parallel modifications. When the same pattern needs updating across multiple files, parallel subagents finish faster and maintain focus. Anthropic’s example: three subagents working in parallel complete in roughly the time one would take, each focused on its file without context from the others creating confusion. The dev.to walkthrough is the concrete version: two agents, one fixing and extending a Security tool and one building a new Log Center, launched in a single prompt with a complete spec per agent. The work that would have taken 3–4 sequential hours took under 45 minutes, and the two agents finished at different times — 8 minutes 12 seconds for the simpler scope, 19 minutes 44 seconds for the larger one — without blocking each other. Those timings are the author’s, from the NEXUS project, not this guide’s run.

Independent review. After implementing something complex, verification from a subagent that has not been influenced by the implementation journey catches what familiarity obscures. The review subagent evaluates the code without knowing what tradeoffs were considered, what approaches were rejected, or what assumptions were made. This is the pattern this guide’s reviewer artefact is built for — and the one place where Rough Works draws a sharp line, in the next section.

Pipeline workflow. When a task has distinct phases — design, then implement, then test — each stage benefits from focused attention, with explicit handoffs between phases. The design subagent is not distracted by implementation concerns, the implementation subagent works from a clean spec, and the testing subagent evaluates the result independently.

The orchestrator pattern. For complex multi-service projects, the dev.to author found explicit orchestration most effective: one agent that reads the full context and coordinates, specialists that implement. The orchestrator prompt reads CLAUDE.md completely, reads the files that describe the current state, plans the work and splits it into parallel tracks, launches sub-agents with specific complete specs, waits for all to complete, and runs a final integration check. The orchestrator reads everything first, makes the architectural decisions, then delegates implementation to specialists who do not need to understand the full picture. The ceiling on what one person can build has moved, the author writes — but the orchestration decisions, the architectural choices, and the review are still yours. Subagents execute. You direct.

What makes parallel agents faster is not magic, the walkthrough argues: no context-switching cost (each agent’s context is already loaded with the right files), no sequential dependencies when the work is designed correctly, and model specialisation (a security-auditor on Sonnet is tuned differently from a general implementer). The failure mode is creating false dependencies: if you ask Agent 2 to “use the pattern that Agent 1 will establish”, Agent 2 has to wait. Design parallel tasks to be genuinely independent.

The measured comparison this guide could not run

The plan for this article asked for the gap the official page leaves open: a measured comparison, one task sequential versus parallel, with time and token cost. That comparison needs a signed-in session, and this guide has none — so it is stated here as the procedure to run, not as a result.

On a signed-in PC, the run is: pick one bounded feature with two genuinely independent halves — the dev.to walkthrough’s shape, two modules that share no files. Build it once in the main conversation, sequentially, and note the elapsed time and the /usage figures. Then build the same feature again with two subagents in parallel, one per half, and note the same two numbers. Compare wall-clock time, total tokens, and cost. The dev.to author’s numbers for a comparable shape — 3–4 sequential hours against under 45 minutes parallel, with per-agent completion times of 8m 12s and 19m 44s — are the only measured figures this guide can cite, and they are the author’s, from the NEXUS project. Until the PC run exists, this guide makes no claim of its own about how much time parallel subagents save, or what they cost.

The same applies to the /agents listing and the live delegation: start Claude Code in the test project in a signed-in session, type /agents and confirm reviewer is listed, type @reviewer and confirm the typeahead offers it, then ask “Have the reviewer look at app.py” and confirm the review comes back read-only. A fix is only accepted when the agent appears in /agents, the @-mention resolves, the review returns findings with quoted lines, and no file was edited — the tools: Read, Grep, Glob line is the enforcement, not the prompt text.

When not to delegate

Anthropic’s guide is blunt about the overhead, and the two independent guides agree. The short version from Rough Works: delegate large, independent, parallel work. Do everything else in the main conversation, including checking your own work.

Sequential, dependent work. When step two needs the full output of step one, and step three needs both, a single session handling the chain is usually cleaner than a relay of subagents passing state through files.

Same-file edits. Two subagents editing the same file in parallel is a recipe for conflict. Keep tightly coupled changes in one context window. The dev.to guide says the same about shared state: if both agents are writing to the same store or modifying the same Docker compose file, one agent’s changes will overwrite the other’s.

Small tasks. For a quick fix or a focused question, the overhead of delegation outweighs the benefit. Just prompt or ask in the main conversation. Rough Works’ checklist opens with the same question: could I finish this in a few tool calls? Then do it here.

Too many specialist agents. It is tempting to define a custom subagent for everything, but flooding Claude with options makes automatic delegation less reliable. Most teams settle on a handful of well-scoped agents rather than a sprawling roster. And remember the description budget: when the combined descriptions of your custom subagents pass 15,000 tokens, Claude Code warns at startup.

Work that needs agents to coordinate with each other. Subagents report back to the main conversation but cannot talk to one another. For tasks where subagents need to communicate, Anthropic points to agent teams — separate sessions that coordinate across a shared task list. The docs mark agent teams as experimental and off by default (enable with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), warn of known limitations around session resumption, task coordination, and shutdown, and say teams “use significantly more tokens than a single session.” Rough Works has not run agent teams in production and would exhaust subagents first; this guide has not run them at all.

Do not use a subagent to check your own work. This is Rough Works’ sharpest rule, and it cuts against the most tempting use. Verification belongs in the main conversation, where the evidence is. A reviewer that has not seen how the code was written is a different and legitimate thing — that is the independent-review pattern, and the reviewer artefact. A second pass over an answer you just produced is not.

Rough Works’ delegation section opens with the sentence that frames all of this: “Subagents multiply cost and latency — each one re-establishes context, re-explores, reports back, and then you re-read the report.” Four rules follow it: delegate only large, independent, parallel work; do not use a subagent to check your own work; if one subagent can do it, use one, and brief it precisely the first time — launch, wait, re-brief is the expensive pattern; and once you delegate, commit to it, and do not redo the subagent’s work while it runs. Each rule has an incident behind it, all from Rough Works’ own use:

  • Nine research agents, one usage window. Nine agents ran in parallel for about ninety minutes, hit the usage limit together, and exactly one partial notes file had reached disk. The work was not gone — every search, fetch, and file read is recorded in each agent’s task transcript, and the team scripted the extraction, recovering 1,410 sources and about 5 MB of text — but the lasting rules are to tell any long-running research agent to write its notes file before its first web call and re-save after each section, and to prefer many small-context agents to a few that grow huge.
  • Ten agents, zero bytes free. A ten-agent run doing image-heavy work, alongside video encoding and a headless browser, pushed memory into swap on an 18 GB laptop; free space went from 7.9 GB to nothing and the shell stopped responding until the run was stopped. Before a wide fan-out, check free disk space and current swap use, and cap concurrency when there is less than about 10 GB free.
  • Two screens that passed alone. Two agents each built one screen of an interface against their own test page. One passed 483 checks. Mounted in the same document, the header of one was garbled by the other’s stylesheet, which used bare class names such as .cell and .title. The brief now says to root every selector at the component’s own class, and the first check after integration is a scripted walk of the combined page. Results from separate harnesses do not transfer.

None of this argues against subagents. A fan-out has a budget: tokens, memory, disk, and your attention when the reports come back.

Model and tool rules

Model. A subagent with no model line runs on whatever your session runs on — a sensible default, and an expensive one if the job is counting imports. Set the field to an alias (sonnet, opus, haiku, fable), a full model ID, or inherit. When several things set a model, Claude Code takes the first of these: the model parameter Claude passes when it starts the subagent; the model field in the definition; the CLAUDE_CODE_SUBAGENT_MODEL environment variable; then the main conversation’s model. To force one model onto every subagent, set CLAUDE_CODE_SUBAGENT_MODEL and CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 (version 2.1.257 or later) — while the force flag is on, Claude Code ignores the model field in definitions. The official best-practices page is blunt about what you get from a smaller model: by default it is “the same model (or a smaller one) on the same task. You get parallelism or a fresh pair of eyes out of it, but not a smarter answer.” This guide’s reviewer runs on Haiku because counting imports and quoting lines does not need the session’s model. Check which model a subagent is running on with /tasks while it runs.

Tools. tools allows, disallowedTools denies, and if you set both, the denylist is applied first. Three behaviours that are not obvious, from Rough Works: a disallowedTools entry with a specifier, such as Bash(git push *), removes the whole Bash tool, not just that command — to block specific commands and keep the shell, add a deny rule to permissions.deny in settings, which applies to the main conversation and to subagents; MCP servers are addressed by prefix, so mcp__github__* in tools grants one server’s tools and mcp__* in disallowedTools withholds all of them; and background subagents get a smaller built-in tool set than foreground ones, and background is the default — the same definition can resolve to different tools depending on how it runs. The docs add the filter lists: every subagent loses Agent at the depth limit, AskUserQuestion, EndConversation, EnterPlanMode, ExitPlanMode (unless the permission mode is plan), propose_skills, ScheduleWakeup, WaitForMcpServers, and Workflow; a background subagent keeps Read, Grep, Glob, Bash, Edit, Write, and the rest of the documented set, and other built-in tools are removed without an error unless it leaves the tools list resolving to nothing.

Limits. Two limits bound all of this, both adjustable by environment variable. By default 20 subagents can run at once in a session — spawning another with the Agent tool fails with Concurrent subagent limit reached, and the error tells Claude not to retry; change the limit with CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS. Subagents can nest up to three layers below the main conversation, because a subagent can spawn its own subagents, such as a reviewer that dispatches one verifier per finding. A nested subagent runs on its parent’s model by default.

Cost check. Running /usage shows what share each subagent type is taking. That is the number to watch before a wide fan-out, not after it.

Subagents vs skills vs agent teams

The docs list several ways to run work in parallel, and these three get confused most:

SubagentSkillAgent team
What it isA worker Claude starts for one taskInstructions Claude followsA lead session supervising peer sessions
ContextIts own windowThe conversation you are inEach teammate has its own
Who it reports toThe conversation that started itNobody; it is the conversationTeammates message each other and share a task list
Status, November 2026StandardStandardExperimental, off by default
Use it whenOutput would flood your context, or you want enforced tool limitsYou want your procedure followed with full contextWorkers need to discuss and coordinate

Use a subagent when only the result matters. Use a skill when you want Claude to follow your procedure with everything it already knows about the task. For work that outgrows a handful of subagents, the documented next step is a dynamic workflow, where a script holds the plan.

When it goes wrong

SymptomCheckFix
Agent never appears in /agentsIs there a file at .claude/agents/<name>.md with name and description?Add the missing field; a file with no name is treated as documentation, a name with no description is skipped with an error in the debug log
Agent is listed but Claude never delegates to itRead the description — does it name trigger conditions?Rewrite it around user phrasings and the work it handles, as with a skill description
A different version runs than the one you editedAnother copy with the same name in a higher-priority locationCheck managed settings, --agents, project, user, and plugin scopes in that order; edit or delete the winning copy
The agent ignores a field you setIs the field spelled in camelCase — maxTurns, not max_turns?Run claude --debug and search the debug log for does not recognize or apply; this guide reproduced the warning verbatim
plugin validate passes but the agent misbehavesValidation checks frontmatter that does not parse, not unknown fieldsCheck the YAML with the Python one-liner and the debug log; do not trust the validator alone
The agent stops halfwayDid it hit maxTurns?The output comes back marked as partial; raise maxTurns or narrow the task
Everything slows down and usage spikesHow many subagents are running, and on which model?Run /usage, cap the fan-out, put simple jobs on Haiku, and check free disk space before a wide run
You just added it and nothing changedDid the agents directory exist when the session started?Restart the session; Claude Code watches both agents directories and picks up changes within a few seconds, except when the directory did not exist at startup

A checklist before you delegate

Rough Works’ checklist, which this guide adopts in full:

  • Could I finish this in a few tool calls? Then do it here.
  • Is the task independent? If it needs back-and-forth with you or shares files with other work, keep it in the main conversation or isolate it in a worktree.
  • Is the brief complete on its own? Goal, files to read, what is already ruled out, the format of the answer. The subagent knows nothing else.
  • Have I asked for a short report? Twenty long reports fill your context as surely as doing the work would have.
  • Does it need this model? Simple collection jobs belong on a smaller one.
  • Are the tool limits in the file? A limit in a prompt is a request. A limit in tools is enforced.
  • Will its notes survive a crash? Long research writes to disk as it goes.
  • Is there room to run it? Check usage headroom, memory, and disk before a wide fan-out. Running /usage shows what share each subagent type is taking.

Frequently asked questions

What is a Claude Code subagent?

A subagent is a worker that Claude Code starts inside your session to handle one task in its own context window. It gets its own system prompt, its own tool list and, optionally, its own model, does the work, and returns a summary to the main conversation. The point is context: a wide search or a long test run stays in the subagent’s window, not yours. Its requests still count toward the same usage limits as the main conversation, so a subagent saves context, not tokens.

How do I create a subagent in Claude Code?

Create a Markdown file with YAML frontmatter in .claude/agents/ inside a project, or in ~/.claude/agents/ to have it in every project. Only name and description are required; the body of the file becomes the subagent’s system prompt. You can also ask Claude to write the file for you, or use the /agents command. As of November 2026, Claude Code picks up new and edited files within a few seconds, except when the agents directory did not exist when the session started, in which case you restart once. The reviewer.md attached to this article is a complete working example.

How do I use subagents in parallel?

Describe the parallel work in one prompt, with a complete spec per subagent, and say explicitly that the tasks can run in parallel. Claude Code launches the agents and manages them; you see “2 background agents launched” with each task listed, and results surface as each finishes. The tasks must be genuinely independent — if Agent 2 needs the pattern Agent 1 will establish, they are not parallel, and the results will be inconsistent.

Do subagents cost extra?

Yes, in tokens. Each subagent sends its own requests, which count toward the same usage limits as the main conversation, and each one rebuilds context from nothing. Subagents save context, not tokens. Put simple jobs on Haiku, ask for short reports back, and check /usage before a wide fan-out. The Rough Works incidents in this guide — nine agents hitting a usage limit together, a ten-agent run filling the disk — are what happens when the fan-out has no budget.

Why is my subagent not showing up?

Usually the file is missing a required field, or it is in the wrong place. A file with no name is treated as documentation; a name with no description is skipped, and the reason is written to the debug log as an [ERROR] line — this guide reproduced both the skip and the log line. Run claude --debug, open the newest log in ~/.claude/debug/, and search for the filename. Note that a valid agent produces no confirmation line in that log at all, so if the file parses and the directory is watched, the definitive check is the /agents listing in a signed-in session.

Subagents vs skills: which should I use?

A skill is a set of instructions loaded into the conversation you are already in. A subagent is a separate worker with a separate context window. Use a skill when you want Claude to follow your procedure with everything it already knows about the task. Use a subagent when the work would flood the conversation with output you will not need again, or when you want enforced limits such as read-only tools. They combine: a subagent definition can preload skills through its skills field.

How this guide was researched

This guide was researched from primary and independent sources on 30 November 2026. The reproduction — Claude Code 2.1.332 installed with npm (the brief’s claim that it was already installed was wrong; it was not on PATH and was installed fresh in 8 seconds), the reviewer agent file at /tmp/claude-code-test/subagent-proj/.claude/agents/reviewer.md, the Python YAML check, the four claude --debug runs, and the claude plugin validate run — was run the same day on Linux (Node 24.22.1), in a scratch project at /tmp/claude-code-test/subagent-proj. The definition, the five use cases, the invocation routes, the four patterns, and the “when shouldn’t you use subagents” list come from Anthropic’s subagents guide, published 7 April 2026. The parallel-build walkthrough, the marketplace setup, the orchestrator pattern, the per-agent context header, the mistakes list, and the timings (3–4 sequential hours against under 45 minutes; per-agent completion at 8m 12s and 19m 44s) come from the dev.to guide, run on the author’s NEXUS project. The cold-start facts, the built-in table, the link-checker example, the model and tool rules, the four invocation routes, the cost rules, the three failure incidents, and the delegation checklist come from Rough Works’ guide, published 18 November 2026, written from daily use of Claude Code. The scope-priority table, the frontmatter reference, the skip rules, the “does not recognize or apply” debug message, the tool filters, and the 20-concurrent limit come from the official Claude Code subagents docs, read the same day. The /agents listing, the @reviewer typeahead, any live delegation, and the sequential-vs-parallel timing comparison are the official documented checks and the plan’s requested measurement; they were not captured in this guide’s run, because the run had no authenticated session, and the guide says so wherever they appear. No test output in this guide was invented: every quoted log line, exit code, and validation result is from the runs described above, and every claim taken from another guide names its source.

Sources

  1. Anthropic — “How and when to use subagents in Claude Code” — https://claude.com/resources/articles/subagents-in-claude-code — accessed 30 November 2026; published 7 April 2026. Definition, five use cases, invocation routes, four patterns, when not to delegate, agent teams pointer.
  2. Alvarito1983 (dev.to) — “Claude Code Part 2: How I use Sub-agents to build entire features in parallel” — https://dev.to/alvarito1983/claude-code-part-2-how-i-use-sub-agents-to-build-entire-features-in-parallel-aj3 — accessed 30 November 2026. NEXUS parallel build, marketplace setup (wshobson/agents), orchestrator pattern, per-agent context header, mistakes, timings (3–4 hours → under 45 minutes; 8m 12s / 19m 44s).
  3. Rough Works — “Claude Code subagents: when to delegate and when not to” — https://roughworks.ca/blog/claude-code-subagents/ — accessed 30 November 2026; published 18 November 2026. Cold-start facts, built-in table, link-checker example, model and tool rules, invocation routes, cost rules, three failure incidents, delegation checklist, subagents vs skills vs agent teams.
  4. Claude Code official docs — “Create custom subagents” — https://code.claude.com/docs/en/sub-agents — accessed 30 November 2026. Scope-priority table, frontmatter reference, skip rules, “does not recognize or apply” debug message (v2.1.296+), tool filters, 20-concurrent limit (CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS), /tasks model display (v2.1.242+).
  5. Claude Code 2.1.332 — installed with npm, 30 November 2026, Linux, Node 24.22.1. claude --version output: 2.1.332 (Claude Code). This guide’s own run: reviewer agent file (YAML parse, layout audit), four claude --debug runs (reviewer only; + misspelled max_turns field; + missing-description file; --agent reviewer), claude plugin validate .claude/agents — all stopping at Not logged in · Please run /login, exit 1. Debug logs in ~/.claude/debug/.
Avatar photo
M.R. Vale

M.R. Vale writes practical guides on AI coding agents, workflows and tools, researched from primary sources, for AI Tech Bench. The focus is on clear limitations and useful real-world examples rather than hype or unverified claims.

Articles: 37

Leave a Reply

Your email address will not be published. Required fields are marked *