# What a subagent is and when to use one

> A subagent is a separate Claude with its own context, tools and prompt. What it gets, what it costs, and when to use subagents in Claude Code.

Section: Subagents
By: Ryan Cuff, https://ryancuff.com
Published: 2026-11-27
Updated: 2026-11-27
Source: https://agents.ryancuff.com/subagents/what-a-subagent-is-and-when-to-use-one

A subagent is a second Claude that the main one hands a job to. It starts with an empty context, its own instructions and its own tools, does the job, and sends back one report. Every entry on this site goes through three of them before I read it, so this is how they work and when they're worth it.

## What is a subagent in Claude Code?

When you talk to Claude Code you're talking to the main agent. It can hand a task to a subagent through a tool called `Agent`, which used to be called `Task`. The main agent writes a prompt describing the job, the subagent runs on its own, and when it's done the main agent gets back one final message. Everything the subagent read and tried along the way stays with the subagent.

So it's a lot like asking a coworker to go look into something. They don't hear the meeting you just had. They get your message, go do it, and come back with a summary.

## What does a subagent get and not get?

The docs are clear about this. "Each subagent starts with a fresh, isolated context window. It doesn't see your conversation history, the skills you've already invoked, or the files Claude has already read." A context window is everything the model can see at once, so a fresh one means it starts knowing nothing about your session.

What it does get is its own definition file as the system prompt, the delegation message from the main agent, your `CLAUDE.md` files, a snapshot of git status, and any skills listed for it. It also gets only the tools you give it. I lean on that last part a lot when I set mine up.

## When should you use subagents?

The first case is reading a lot to answer a little. If finding an answer means going through a dozen files or a pile of search results, a subagent can do all that reading in its own context and send back the answer. The main conversation stays clean.

The second is work that can run side by side. Background subagents run at the same time, up to 20 at once by default. That limit is set with `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS`. Research splits up really well this way. Code usually doesn't, and Anthropic says as much, that "most coding tasks involve fewer truly parallelizable tasks than research."

The third one is my own reasoning, not something from the docs. A subagent that only sees the code and not my conversation can review it without already agreeing with me. If the main agent has spent an hour talking itself into an approach, a fresh one hasn't.

## What do subagents cost?

A subagent only knows what's in its prompt. If the main agent writes a thin one, the subagent guesses. Anthropic's engineering team wrote that "without detailed task descriptions, agents duplicate work, leave gaps, or fail to find necessary information."

Then the report coming back is a summary, so detail gets dropped on the way out too. You can see subagents running in the subagent panel and in `/agents`, but you can't watch them think. Their transcripts get saved, so you can read them afterward.

where the transcripts go

```
~/.claude/projects/<project>/<sessionId>/subagents/
```

And it costs tokens. In the [post about their multi-agent research system](https://www.anthropic.com/engineering/multi-agent-research-system), Anthropic says multi-agent systems use about 15 times more tokens than chats. So I don't reach for one when the job is a couple of file reads I could just do.

## How do you define a subagent?

A subagent is a markdown file with some YAML frontmatter on top. YAML is the block of settings between the two `---` lines. Put it in `.claude/agents/` for one project or `~/.claude/agents/` for every project. Only `name` and `description` are required. The rest of the file is the subagent's system prompt.

The description matters more than it looks. The docs say "Claude uses each subagent's description to decide when to delegate tasks." If it's vague, Claude never picks it. You can also call one yourself with `@agent-name` or just by naming it.

The `tools` field is the one to be careful with. If you leave it out, the subagent inherits every tool, so it isn't restricted at all. Fields with typos also get ignored without any error, which is an easy way to think you set something you didn't. `model` is optional too and defaults to whatever the main agent is using.

## Can a subagent start its own subagents?

Yes, as of version 2.1.172 in June 2026. By default a subagent can start more subagents, up to three layers below the main conversation. `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` sets the limit and setting it to 1 turns nesting off. A subagent only gets this if its tools include `Agent`, or if it has no tools field at all.

## How I use subagents for this site

Every entry here goes through three subagents in `.claude/agents`. This one did too. Here's the top of the researcher.

.claude/agents/entry-researcher.md

```
---
name: entry-researcher
description: Researches the topic of a new Agents entry before anything is written. Use it first in the new-entry workflow, or any time an entry needs facts checked. Returns a research brief with sources. Never writes site copy.
tools: Read, Grep, Glob, WebSearch, WebFetch
---
```

There's no `Write` in that list, so it can look things up but it can't touch the site. It returns a brief and that's it. There's also no `Agent`. I don't give any of the three the Agent tool, so none of them start anything of their own.

The writer gets the editing tools and drafts in my voice. It's told never to invent my experience, so where it needs something only I know it leaves a note for me instead.

.claude/agents/entry-writer.md

```
---
name: entry-writer
# description left out here to keep it short
tools: Read, Write, Edit, Grep, Glob
---
```

The voice editor gets the same tools minus `Write`, plus `Bash` so it can run `npm run check:voice`, a script that flags words and symbols I don't use. It fixes grammar and strips out anything that sounds like AI wrote it.

.claude/agents/voice-editor.md

```
---
name: voice-editor
# description left out here to keep it short
tools: Read, Edit, Grep, Glob, Bash
---
```

A skill called `new-entry` runs them in order. A skill is a set of instructions Claude loads when the task matches. Running them one after another means I can read each step before the next one starts.

When I had five entries to write, I ran five researchers in parallel. Then five writers, and each one only touched its own body file. Then one editor across all five. That way no two agents ever edited the same file at the same time.
