Kavvo Agents

Claude Subagents Explained

November 29, 2026 · 4 min read · By the Kavvo Agents team

What a subagent is

A subagent in Claude Code is a specialised AI assistant that the main Claude agent can delegate work to. Anthropic’s docs say subagents are specialised assistants that handle specific types of tasks, and that each one runs in its own context window with a custom system prompt, specific tool access, and independent permissions.

That separate context is the key idea. When the main conversation delegates a task to a subagent, the subagent works in its own window, so its detailed work does not fill up the main conversation. The main agent keeps the high-level goal, and the subagent returns a result. Claude uses each subagent’s description to decide when to delegate, so a clear description is what makes a subagent useful.

Claude Code includes built-in subagents that it uses automatically when appropriate, including Explore and Plan. You can also create your own for work you do again and again.

When to use one

Create a subagent when you keep spawning the same kind of worker with the same instructions. Good examples include a code reviewer that checks changes for quality and best practice, an explorer that searches a codebase to answer a question, a test writer that writes tests for new code, or a researcher that gathers information from files and the web.

Use a subagent when a task is focused, has a clear input and output, and benefits from its own context. A code review is a good fit: the reviewer needs to read many files, but the main conversation only needs the review summary. A task that needs the full conversation history, or that changes direction often, is usually better done in the main conversation.

How to set one up

Subagents are Markdown files with YAML frontmatter. You can ask Claude to write one for you, or write the file yourself. The file location decides who can use it: a file in .claude/agents/ is project-level and available only in the current project, and a file in ~/.claude/agents/ is user-level and shared across all projects on your machine. Managed settings and the --agents CLI flag have higher priority, and a plugin’s agents/ directory has the lowest priority, according to the docs.

To create a project-level subagent by hand:

  1. Create the folder .claude/agents/ in your project if it does not exist.
  2. Create a Markdown file in that folder, for example code-reviewer.md. The first line must be ---.
  3. Add frontmatter with two required fields: name, a unique identifier such as code-reviewer, and description, a single line that says when Claude should use it, for example: “Reviews code for quality and best practices. Use after code changes.”
  4. Optionally add tools to limit what the subagent can use, for example Read, Glob, Grep for a read-only reviewer, and model to choose which model powers it — an alias such as sonnet, opus, or haiku, a full model ID, or inherit to use the main conversation’s model.
  5. Below the closing ---, write the subagent’s instructions in plain language: its role, what to check, and what to return.
  6. Save the file. Claude Code picks up changes in an existing agents folder within seconds. If you created the folder during the session, restart Claude Code first.

The easiest way to create one, according to Anthropic’s academy, is to ask Claude to write it for you: describe the subagent you want and where to save it, and Claude writes the file with a name, description, and system prompt. The /agents wizard that older guides describe was removed in Claude Code v2.1.198, so check the current docs if a guide tells you to run /agents to create one.

How to use it

Claude will use a subagent automatically when its description matches the task, or you can invoke it explicitly by asking Claude to use it by name, or by typing @agent-name in your message — for example, @code-reviewer. Test it by making some code changes and asking Claude to review them, then read the result and fix the instructions where the review misses something or is too vague.

You can control subagents with permissions: to block a specific built-in type, add it to permissions.deny; to prevent Claude from delegating to any subagent, deny the Agent tool itself; and to remove only the built-in Explore and Plan subagents, set the environment variable CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTS=1, which requires Claude Code v2.1.198 or later, according to the docs.

Watch out for

A subagent inherits tools by default if you do not set the tools field, so a reviewer you meant to be read-only could edit files if you forget to limit it. Set tools explicitly for any subagent that should not change files. Choose the model for the job: Haiku is best for fast, lightweight tasks, Sonnet is a middle ground, and Opus is best for complex analysis, according to Anthropic’s academy. Keep descriptions short, test with a real task, and remember that Claude Code changes often — run claude update and check the current docs if something described here is missing.

Sources