Claude Code subagents: when they help and when they cost you

Subagents give a task its own context window, its own tool allowlist, and optionally its own model and permission mode. That isolation is the entire feature and the entire drawback, and which one you get depends on whether the task genuinely stands alone.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

A subagent is a Markdown file with YAML frontmatter in .claude/agents/ or ~/.claude/agents/. It defines a system prompt plus optional tool allowlist, model, permission mode, memory scope, and worktree isolation. Claude Code delegates matching work to it in a fresh context window and receives back only its summary. Only name and description are required, and model defaults to inherit, so a subagent saves nothing on model cost unless you say otherwise.

What you need to know
  • Each subagent gets a fresh context window. It cannot see your conversation.
  • Markdown plus YAML frontmatter in .claude/agents/. Only name and description are required.
  • model defaults to inherit, so delegation is not a saving until you set it.
  • You already use subagents: Explore, Plan, and general-purpose are built in.
  • The strongest reasons to define one are a narrow tool list and isolation: worktree.

The built-in ones you already use

Before you write a custom subagent, know what is already delegating. Claude Code ships built-in subagents it uses automatically, and most of the context saving people attribute to their own configuration is coming from these.

Built-in subagents as of August 2026.

NameModelUsed when
ExploreInherits the main conversation, capped at Opus on the Claude APISearching or understanding a codebase without changing it
PlanInheritsResearch during plan mode, before a plan is presented
general-purposeInheritsTasks needing exploration and modification, or several dependent steps
claudeInheritsCatch-all with every tool available to subagents

Explore used to run on Haiku unconditionally. As of Claude Code v2.1.198 it inherits the main conversation’s model instead, capped at Opus on the Claude API, so a session on a higher tier does not run exploration on a more expensive model than you chose. If you want exploration cheap again, define your own.

~/.claude/agents/Explore.md - a user subagent overrides the built-in and keeps its own model.
---
name: Explore
description: Searches and explains a codebase without changing it.
tools: Read, Grep, Glob
model: haiku
---

You answer questions about a codebase by reading it. Never edit a file.
Return a short summary with exact file paths and line references, not
a transcript of what you looked at.
Or turn delegation off, in .claude/settings.json.
{
  "permissions": {
    "deny": ["Agent(Explore)", "Agent(my-custom-agent)"]
  }
}

Defining one

01

Create the file

Put it in .claude/agents/<name>.md for the project or ~/.claude/agents/<name>.md for yourself. Subdirectories are fine; identity comes from the name field, not the path.

02

Write the description as a trigger

Describe when to delegate, not what the subagent is. Claude routes on this text alone.

03

Narrow the tools, then set the model

Omitting tools inherits everything, which defeats the main reason to define one. Set model explicitly, because it defaults to inherit.

04

Verify it took effect

Files are watched, so an edit applies within a few seconds. If Claude cannot find a brand new user subagent, restart: a running session does not detect a ~/.claude/agents/ directory that did not exist at launch.

.claude/agents/test-writer.md
---
name: test-writer
description: Writes unit tests for existing code. Use when asked to add test coverage for a file that already works.
tools: Read, Write, Bash
model: haiku
maxTurns: 20
---

You write unit tests for code that already exists and works.

Rules:
- Match the existing test style in the repository. Read a neighbouring
  test file first; do not invent a new convention.
- Test behaviour through the public interface, never private internals.
- Cover the error paths, not only the happy path.
- Never modify the implementation. If it looks wrong, say so and stop.
- Run the tests you wrote before reporting done.

The frontmatter fields worth knowing. Only name and description are required.

FieldPurpose
nameIdentifier. Lowercase and hyphens; a : is rejected because it is the plugin namespace separator
descriptionHow Claude decides to delegate. This is the routing logic, so write it as a precise trigger
toolsAllowlist. Omit to inherit every tool available to subagents, which is usually wrong
disallowedToolsDenylist, applied after the inherited or specified list
modelsonnet, opus, haiku, a full model ID, or inherit. Defaults to inherit
permissionModedefault, acceptEdits, auto, dontAsk, bypassPermissions, or plan
maxTurnsHard cap on agentic turns before it stops
effortlow to max, overriding the session effort level
skillsSkills preloaded into its context at startup, in full, not just the description
memoryuser, project, or local. Gives this subagent its own persistent notes
isolationSet to worktree to run it in a temporary git worktree
backgroundtrue to always run detached. Claude already backgrounds subagents by default
mcpServersMCP servers available to this subagent only
hooksLifecycle hooks scoped to this subagent

Scope, precedence, and where files live

Definition sources, highest precedence first. As of August 2026.

SourceAvailable inCommit?
Managed settings .claude/agents/Whole organisationDeployed by IT
--agents CLI flag (JSON)That session onlyNo
.claude/agents/The projectYes
~/.claude/agents/All your projectsNo
  • Both directories are scanned recursively, so agents/review/ and agents/research/ are fine. Identity comes only from the name field, never the path.
  • Project subagents are discovered by walking up from the working directory, so every .claude/agents/ between there and the repo root is scanned. When two nested directories define the same name, the one closest to the working directory wins.
  • Two files in the same directory sharing a name is undefined: Claude Code loads one by filesystem read order. /doctor reports the clash.
  • Files are watched, so an edit takes effect within a few seconds with no restart. The exception: if ~/.claude/agents/ did not exist when the session started, you have to restart.

What isolation actually costs

The pitch for subagents is that they keep your main context clean. That is true and it is only half the picture.

Isolation gives youIsolation costs you
A clean main conversationThe subagent cannot see your discussion
A separate context budgetContext has to be re-established from scratch
Narrow tool permissionsMore configuration to maintain
A cheaper model for cheap workA handoff summary that can lose nuance
A worktree the main branch cannot seeA worktree the main session cannot see either

A subagent receives its own system prompt plus basic environment details such as the working directory. It does not receive the full Claude Code system prompt, and it does not receive the main conversation’s auto memory. The one exception is a fork, which inherits the parent conversation and system prompt.

Two context windows side by side: the main conversation holding the discussion, files and decisions, and a subagent window holding only its system prompt and the task, with the task passing right and a summary coming back left TWO CONTEXT WINDOWS only two things cross the gap main conversation everything you built up · the discussion so far · files read together · decisions and dead ends · CLAUDE.md, auto memory the subagent a window opened just now · its own system prompt · the task, as you wrote it and nothing else no conversation, no auto memory the task a summary kept for the whole session discarded when it returns Delegate what stands alone: everything on the left is re-derived on the right.

Where they earn their keep

TaskWhy it suits a subagent
Writing tests for a finished fileStands alone; the file is the whole context
Reviewing a diffA fresh reader is genuinely better than a tired one
Mechanical migration across many filesRepetitive, and a cheaper model handles it
Searching a large codebaseReturns a summary instead of filling your context
A risky refactor you want quarantinedisolation: worktree keeps it off your checkout
Generating documentation from codeSelf-contained input
TaskWhy it does not
Debugging something you are mid-way throughAll the value is in the context it will not have
Anything needing your earlier decisionsSame reason
Small editsThe handoff costs more than the edit
Exploratory workThe point is accumulating context, not discarding it

The review subagent is still the best one

A reviewer with read-only tools, a fresh context, and an instruction to be sceptical is the highest-value subagent most repositories can have. It catches things the agent that wrote the code cannot, because it has none of the investment in the approach.

.claude/agents/reviewer.md - note the read-only tool list and the explicit model.
---
name: reviewer
description: Reviews a diff for bugs before it is committed. Use after changes are complete.
tools: Read, Grep, Glob, Bash
model: opus
effort: high
---

You review diffs for defects. You did not write this code and you have
no attachment to the approach.

Report only:
- Bugs that will actually occur, with the input that triggers them.
- Security issues with a concrete exploit path.
- Broken error handling.

Do not report style, naming, or preferences. If you find nothing real,
say so plainly. A short honest review is worth more than a long one.

Worktree isolation, for anything you would not run on your checkout

Setting isolation: worktree gives the subagent a temporary git worktree, branched by default from your default branch rather than the parent session’s HEAD. Its Bash commands run inside that worktree, and Claude Code blocks commands that try to redirect git back at your main checkout. The worktree is cleaned up automatically if the subagent made no changes.

.claude/agents/migrator.md
---
name: migrator
description: Applies a mechanical codemod across many files. Use for framework or API migrations.
tools: Read, Edit, Write, Grep, Glob, Bash
model: haiku
isolation: worktree
permissionMode: acceptEdits
maxTurns: 60
---

Apply the requested migration across every matching file.

Do not change behaviour. If a file needs a judgement call, skip it and
list it at the end rather than guessing. Run the build before reporting
done and report the file count you changed.

The cost model

A subagent runs a full agent loop with its own context, so it is not free. Whether it saves money depends almost entirely on the model field.

  • Inherited model, small task: more expensive. You paid to re-establish context and gained nothing.
  • Cheaper model, mechanical task: substantially cheaper. This is the real win, and it requires the model field.
  • Expensive model, review of a finished diff: worth it. Catching one real bug pays for a lot of reviews.
  • Search that would have filled your main context: cheaper, because context cost compounds across every later turn.

Questions people ask

Named configurations with their own system prompt, tool allowlist, and optionally their own model, permission mode, and git worktree. Claude Code delegates matching tasks to them in a fresh context window and receives back a summary rather than the full transcript.

Markdown files with YAML frontmatter in .claude/agents/ for a project, or ~/.claude/agents/ for all your projects. Both are scanned recursively, and identity comes from the name field rather than the path.

Only when you set the model field. It defaults to inherit as of August 2026, so a subagent on the same model for a small task costs more than doing the work inline, because context has to be re-established. Routing mechanical work to a cheaper model is the reliable saving.

It could not see your conversation. Subagents start with a fresh context and receive only their own system prompt plus basic environment details, so any task whose value lies in the reasoning that preceded it is a poor fit for delegation.

As of Claude Code v2.1.198, running /agents prints a reminder rather than opening the interactive creation wizard. Ask Claude to write the file, or create it in .claude/agents/ yourself. The file format and locations are unchanged.

From the description field. Write it as a precise statement of when the subagent applies, because that text is the routing logic. A vague description produces random delegation.

Yes. Set isolation: worktree in the frontmatter. The subagent gets a temporary worktree branched from your default branch, its shell commands run inside it, and the worktree is cleaned up automatically if it made no changes.

Add Agent(name) to permissions.deny in settings.json to block one, deny the bare Agent tool to block all delegation, or set CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS=1 to remove only the built-in Explore and Plan agents.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Claude Code: create custom subagents
  2. Claude Code permissions reference
  3. Claude Code settings reference
Try it

Did it actually
save anything?

Continuum attributes spend per model and per session, so delegation strategies can be checked rather than assumed.

free app · your subscriptions · local-first