Home › Rules › Claude Code subagents examples

Claude Code subagents examples: 7 beginner-safe subagents to copy (and how they work)

Built from Anthropic's, Cursor's and OpenAI's own docs, checked Oct 26, 2026. Sources below.

Short answer: a subagent is a helper Claude hands a side job to, like reviewing your changes or running the tests. It works in its own context window, with its own instructions and its own list of allowed tools, and sends back only a summary, so your main chat doesn't fill up with logs and search results. Each one is a Markdown file with a short YAML header, saved in .claude/agents/ (one project) or ~/.claude/agents/ (all your projects). Claude reads each subagent's description to decide when to use it.

Subagents vs skills vs hooks vs CLAUDE.md vs agent teams

What it isUse it for
CLAUDE.mdInstructions Claude reads every sessionHow you want things done: style, commands, project notes
SkillsReusable instructions that run in your main conversationA repeatable workflow where Claude keeps your chat's context
HooksShell commands that run automatically at set momentsThings that must happen every time, like formatting after edits
SubagentsA separate helper with its own context, prompt and toolsSelf-contained jobs that make a lot of output and can return a summary
Agent teamsSeveral Claude Code sessions that message each other (experimental, off by default)Bigger parallel work where the helpers need to talk to each other

Anthropic's docs draw the lines this way. Stay in the main conversation for back-and-forth work, quick targeted changes, or when several steps share a lot of context. A subagent starts fresh and may need time to gather context. Use a subagent when the job makes verbose output you don't need to see, when you want to limit which tools it can use, or when the work can come back as a summary. Use a skill instead when you want a reusable prompt that runs in your main conversation. A skill can also run inside a subagent if you add context: fork to its frontmatter.

Agent teams are a different feature. They're experimental and turned off until you set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1. Subagents report back to the main chat. Teammates share a task list and message each other directly. Anthropic's comparison lists the token cost of subagents as lower and teams as higher, because each teammate is a separate Claude instance. For most beginners, subagents are the place to start.

Where subagent files go

FolderApplies toNotes
.claude/agents/This projectCommit it to git so your team gets the same subagents. Wins over a user subagent with the same name.
~/.claude/agents/All your projectsPersonal, only on your computer

Subagents can also come from managed settings (your organization), the --agents flag (one session only), and plugins. Claude Code scans both folders including subfolders, so agents/review/ is fine; only the name field identifies a subagent.

The easiest start is to ask Claude to write one: "Create a code-reviewer subagent in .claude/agents/ that reviews my changes. Make it read-only." Then open the file and check it. Or paste one of the files below. Claude Code picks up new and edited files within a few seconds. The one exception: if the agents folder didn't exist when the session started, restart Claude Code.

In current Claude Code versions, /agents just reminds you to ask Claude or edit those folders directly. On v2.1.197 and earlier it opened a menu for creating and editing subagents.

The file format

The basic shape of a subagent file
---
name: my-helper
description: When Claude should hand work to this subagent
tools: Read, Grep, Glob
model: inherit
---

The instructions for the subagent go here, in plain Markdown.
This part becomes its system prompt.

The part between the --- lines is the frontmatter (settings). Everything below it is the subagent's system prompt. A subagent gets only that prompt plus basic details like the working directory, not Claude Code's full system prompt. Only name and description are required. These are the fields beginners are most likely to use:

FieldWhat it does
nameRequired. A unique name, like code-reviewer. Can't contain : or start with -. The filename doesn't have to match.
descriptionRequired. When Claude should use it. Claude reads this to decide when to delegate, so be specific.
toolsWhich tools it may use, like Read, Grep, Glob. Leave it out and it gets every tool available to subagents.
disallowedToolsTools to take away from what it would otherwise get, like Write, Edit.
modelsonnet, opus, haiku, fable, a full model ID, or inherit (same as your main chat).
permissionModeWhich permission mode it runs in, like default or plan. Your main chat's mode can override it (see the docs).
maxTurnsStop after this many turns; the output comes back marked as partial.
skillsSkills to load into it at startup (the full skill, not just the description).
memoryuser, project or local: gives it a folder of notes that survives between sessions.
effortlow, medium, high, xhigh or max, depending on the model.
isolationworktree runs it in its own temporary git worktree, a separate copy of the repo.
colorDisplay color in the task list: red, blue, green, yellow, purple, orange, pink or cyan.

The docs list a few more (mcpServers, hooks, background, omitClaudeMd, autoCompactWindow, initialPrompt, experimental). Field names are camelCase and must match exactly: Claude Code ignores a field it doesn't recognize without any error, so disallowed-tools silently does nothing.

Read-only subagents: give them tools: Read, Grep, Glob. Without Edit and Write they can't change files. If you add Bash (for example so a reviewer can run git diff), keep in mind Bash can run any command. To block a specific command but keep Bash, add a deny rule like Bash(git push *) to permissions.deny in your settings. Putting Bash(git push *) in disallowedTools removes Bash entirely.

What a subagent can and can't see

How subagents get used

When it works, you'll see a row like code-reviewer(Review recent changes) in the transcript. Subagents Claude starts from your main chat run in the background by default, so you can keep working. If one needs a permission, the prompt shows up in your main session with the subagent's name. Run /tasks to see running subagents and the model each one is using.

Picking a model

Set model in the frontmatter. The aliases, as Anthropic's model docs describe them:

If you leave model out, Claude Code picks the model in this order: a model Claude passes when it starts the subagent, then the subagent's model field, then the CLAUDE_CODE_SUBAGENT_MODEL environment variable, then your main chat's model. Anthropic lists "control costs by routing tasks to faster, lower-cost models like Haiku" as one reason to use subagents. A simple way to apply that: put read-only search and summary jobs on haiku, and keep review and debugging on inherit.

Run every subagent on Haiku: add to ~/.claude/settings.json
{
  "env": {
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku",
    "CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1"
  }
}

While the force setting is on, the model field in your subagent files is ignored. Your organization's model allowlist can also swap a blocked model for another one; Claude Code shows a warning when it does.

Matching kit: Codebase Fixer Agent ($8)

The free rules set the boundaries. The Codebase Fixer Agent adds the process for an app that already exists: a read-only audit, safety-net tests, one fix at a time with a commit after each, then a review of the whole diff.

See the Codebase Fixer Agent ($8) →

Instant download. 7-day refund, no questions asked.

7 subagents to copy

Examples 2 and 5 are taken from Anthropic's and Cursor's docs. The others follow the patterns in those docs, adjusted for beginners. Save each file under the path shown, then ask Claude to use it by name once to check it works. Each one has a single job, and the read-only ones have no Edit or Write tool.

1. Code reviewer (read-only)

.claude/agents/code-reviewer.md
---
name: code-reviewer
description: Reviews recent code changes for bugs, security problems and readability. Use proactively after writing or changing code.
tools: Read, Grep, Glob, Bash
model: inherit
---

You are a careful code reviewer. You never edit files.

When invoked:
1. Run git diff to see what changed
2. Read the changed files
3. Start the review right away

Check for:
- Code that is hard to read or badly named
- Missing error handling
- Secrets or API keys in the code
- User input that isn't validated
- Changes with no tests

Report by priority:
- Must fix
- Should fix
- Nice to have

For each item, name the file and line and show how to fix it.
Explain everything in plain English.

Reviews what changed and reports by priority. It can't edit files. It has Bash so it can run git diff, the same as the reviewer in Anthropic's docs. For a strictly read-only version, delete Bash from the tools line and it will read the files instead. Try it: Have the code-reviewer subagent look at my recent changes.

2. Debugger

.claude/agents/debugger.md
---
name: debugger
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
tools: Read, Edit, Bash, Grep, Glob
---

You are an expert debugger specializing in root cause analysis.

When invoked:
1. Capture error message and stack trace
2. Identify reproduction steps
3. Isolate the failure location
4. Implement minimal fix
5. Verify solution works

For each issue, provide:
- Root cause explanation
- Evidence supporting the diagnosis
- Specific code fix
- Testing approach

Focus on fixing the underlying issue, not the symptoms.

This is Anthropic's example, slightly trimmed. Unlike the reviewer, it has Edit, because fixing a bug means changing code. You still get the normal permission prompts unless your main chat is in a mode that skips them.

3. Test runner

.claude/agents/test-runner.md
---
name: test-runner
description: Runs the test suite and fixes failing tests. Use proactively after code changes or when tests fail.
tools: Read, Edit, Bash, Grep, Glob
---

You run tests and report back briefly.

When invoked:
1. Find how this project runs its tests (package.json scripts, Makefile or README)
2. Run the tests
3. If any fail: read the failure, find the cause, and fix the code
   while keeping what the test checks
4. Run the tests again

Never delete a test or weaken it just to make it pass.

Report:
- How many tests passed and failed
- Only the failing tests, with their error messages (not the full log)
- What you changed to fix them

Running tests is the kind of job Anthropic's docs suggest for a subagent: lots of output, and you only need the failures. The "never delete a test" line is there because a quick way to make a failing test pass is to remove it.

4. Security checker (read-only)

.claude/agents/security-checker.md
---
name: security-checker
description: Security checker for auth, payments, user data and API keys. Use when that kind of code is added or changed.
tools: Read, Grep, Glob
model: inherit
---

You check code for security problems. You never edit files.

When invoked:
1. Find the security-sensitive code: login, payments, user data, API routes
2. Look for hardcoded secrets, API keys and passwords
3. Look for common holes: injection, XSS, missing auth checks
4. Check that user input is validated and cleaned

Report findings by severity:
- Critical (fix before you deploy)
- High (fix soon)
- Medium (fix when you can)

For each one, name the file, explain the risk in plain English,
and say what to change.

Based on the security auditor in Cursor's docs, with Claude Code tool limits added. Read, Grep and Glob only, so it reports and you decide. Pairs with our vibe coding security checklist. It's a second pair of eyes, not a security audit.

5. Verifier: "is it really done?"

.claude/agents/verifier.md
---
name: verifier
description: Validates completed work. Use after tasks are marked done to confirm implementations are functional.
tools: Read, Grep, Glob, Bash
---

You are a skeptical validator. Your job is to verify that work
claimed as complete actually works. You never edit files.

When invoked:
1. Identify what was claimed to be completed
2. Check that the implementation exists and is functional
3. Run relevant tests or verification steps
4. Look for edge cases that may have been missed

Report:
- What was verified and passed
- What was claimed but incomplete or broken
- Specific issues that need to be addressed

Do not accept claims at face value. Test everything.

This is Cursor's verification agent. Cursor's docs describe the problem it solves: the AI marks a task done when the work is incomplete or broken. We added the tools line and "never edit files" so it checks and reports instead of patching things.

6. Docs writer

.claude/agents/docs-writer.md
---
name: docs-writer
description: Writes and updates README and docs files after features change. Use when asked to document something.
tools: Read, Grep, Glob, Edit, Write
model: sonnet
---

You write documentation for beginners.

When invoked:
1. Read the code that changed and the existing README and docs
2. Update only Markdown files (.md). Don't change code.
3. Write short sentences. Show the exact commands to run.
4. Keep the existing structure; add a section rather than rewriting everything

When done, list the files you changed and one line about each.

This one has Edit and Write so it can update the README. "Only Markdown files" is an instruction, not a hard limit. Check its list of changed files when it's done. It's set to sonnet, which Anthropic's model docs describe as the everyday coding model.

7. A cheaper Explore (on Haiku)

~/.claude/agents/Explore.md
---
name: Explore
description: Fast, read-only search of the codebase. Use to find files, code or how something works without changing anything.
tools: Read, Grep, Glob
model: haiku
---

Search the codebase and return the relevant file paths and short code snippets.
Don't suggest edits. Keep the answer short.

Claude Code has a built-in read-only Explore subagent it uses for searching your code. By default it runs on your main chat's model (in some setups, on Opus). Anthropic's docs say a user or project subagent named Explore replaces the built-in one and keeps its own model field, so this file moves code searches to Haiku. Keep the name exactly Explore. If the results get worse, delete the file to go back to the built-in one.

Tell Claude about them

Subagents get picked by their description, but you can also say how you want them used in CLAUDE.md:

Add this to your CLAUDE.md
## Subagents
- This project has subagents in .claude/agents/: code-reviewer, test-runner, security-checker.
- After you change code, use the code-reviewer subagent before you tell me you're done.
- When tests fail, hand them to the test-runner subagent and show me only its summary.

Subagents in Cursor

Cursor has subagents too, in the editor, the CLI and Cloud Agents. Cursor also reads .claude/agents/ and ~/.claude/agents/ (its docs call this Claude compatibility), next to its own .cursor/agents/ and ~/.cursor/agents/. If two have the same name, the .cursor/ one wins, and project subagents win over user ones.

.cursor/agents/security-checker.md
---
name: security-checker
description: Security checker for auth, payments, user data and API keys. Use when that kind of code is added or changed.
model: inherit
readonly: true
---

You check code for security problems. Report findings by severity
(critical, high, medium) with the file and a plain-English fix.

Claude Code ignores frontmatter fields it doesn't know, so a readonly: true line won't break a file Claude Code also reads. It won't make the file read-only in Claude Code either; that still takes the tools line.

Subagents in OpenAI Codex

Codex runs subagents in the ChatGPT desktop app, the Codex CLI and the IDE extension. It delegates when you ask directly ("spawn two agents", "use one agent per point") or when your AGENTS.md or a skill tells it to. In the CLI, /subagents lets you look at and switch between agent threads. Built-in agents are default, worker and explorer.

Custom agents are TOML files, not Markdown: ~/.codex/agents/ for personal ones, .codex/agents/ for a project. Each needs name, description and developer_instructions. Here's the reviewer from OpenAI's docs, lightly trimmed and without the model lines, so it uses the parent session's model:

.codex/agents/reviewer.toml
name = "reviewer"
description = "PR reviewer focused on correctness, security, and missing tests."
developer_instructions = """
Review code like an owner.
Do not edit files.
Prioritize correctness, security, behavior regressions, and missing test coverage.
Lead with concrete findings and avoid style-only comments unless they hide a real bug.
"""

One difference matters. Codex custom agents inherit the parent session's permissions and sandbox, and a custom agent file can't override them. OpenAI's docs say "do not edit files" in the instructions doesn't create a separate read-only sandbox. OpenAI also notes that subagent runs use more tokens than one agent doing the same work.

Best practices from the docs

Subagent not showing up or not being used? Check these

Next step for Claude Code: Agent Skills

Skills are folders your AI coding agent loads only when the job comes up, and Claude Code, Cursor and OpenAI Codex all read the same SKILL.md format. The Vibe Coder Skills Pack ($9) is 6 ready-to-copy SKILL.md skills (fix-one-bug, stop-the-loop, leak-check, ship-check, explain-project, builder-handoff) for Claude Code, Cursor and OpenAI Codex. Also included in the 6-kit bundle.

Get the Skills Pack for $9 on Gumroad → See what's inside

One .zip of skill folders plus one markdown file. 7-day refund, no questions asked.

Best value

All 6 kits for $29 — or $20.30 with code WELCOME30 (through Nov 30)

Subagents split up the work. The kits tell your AI what to build, step by step: a small game, a Discord bot, an email-triage agent, an MVP, or a cleanup of messy code.

Get all 6 kits for $29 → See what's in each kit

$29 instead of $48 for the six kits bought separately; WELCOME30 takes 30% off that at checkout ($20.30). Instant download from Gumroad. 7-day refund, no questions asked.

Related

Sources

Checked Oct 26, 2026. These tools change often; if something here no longer matches, tell us at [email protected].

Get a free starter kit: the Discord Bot Builder ($6)

  • The Discord Bot Builder kit, free (it's $6 on Gumroad): from the Discord Developer Portal to a running bot, an agent brief (AGENTS.md / CLAUDE.md) with token-safety rules, a starter bot with /roll and /ping, and six feature prompts. Emailed with your download link.
  • Bonus: the whole rules library in one zip: 137 ready-to-use rules files (AGENTS.md, CLAUDE.md, Cursor .mdc rules, Lovable/Bolt Project Knowledge) for 30 projects.

After that, an occasional email when we publish a new guide, rules file or kit.

Free. No spam. Unsubscribe anytime. See our privacy note.