Five copy-paste .claude/agents YAML files for Claude Code — a code reviewer, test runner, repo explorer, security reviewer, and docs researcher — plus what the frontmatter fields actually do.
Manager, Architect Technology at Cognizant
A Claude Code subagent is a Markdown file with YAML frontmatter that sits in .claude/agents/ and tells Claude Code to hand off a specific job to a separate context window with its own tools, its own model, and its own system prompt. You write the file once, commit it to the repo, and every teammate who clones the project gets the same code reviewer or test runner without having to explain anything.
Subagents shipped for Claude Code in July 2025. The /agents command and custom subagent files rolled out that month, confirmed in launch posts from the Claude Code team account. Anthropic followed up in September 2025 by pairing subagents with hooks and checkpoints so Claude Code could "work more autonomously," per Anthropic's announcement. Since then the frontmatter schema has grown a lot (model aliases, permission modes, persistent memory, skill preloading), and most "getting started" posts out there still show the 2025 three-field version. This one covers what's actually in the official subagents docs today, plus five agents you can paste into a project and use this afternoon.
The short version: a subagent is isolation. When your main Claude Code conversation is three hours into a refactor, you don't want to dump 400 lines of grep output into that same context just to check whether a function has a test. You delegate it. The subagent reads the files, does the grunt work in its own window, and reports back a summary. The noisy part never touches your main thread.
Builder.io's write-up on subagents frames this well: subagents are for "noisy, bounded" work, not for small tasks that are faster to just do inline, and not for tightly-coupled work where handing context back and forth costs more than it saves. Repo exploration, documentation lookups, test runs, code review, and security review are the five jobs the post calls out as good fits, and that's basically the list below.
A subagent file needs exactly two frontmatter fields: name and description. Everything else is optional. The easiest path is typing /agents inside Claude Code and asking it to scaffold one. Claude Code will write the file for you and let you edit it interactively. But for a team repo, it's faster to just drop the file straight into .claude/agents/ yourself:
---
name: code-reviewer
description: Reviews code for correctness bugs, security holes, and missed edge cases. Use proactively after any non-trivial change.
tools: Read, Grep, Glob
model: sonnet
---
You are a code reviewer. Read the changed files and the surrounding
context they touch. Flag correctness bugs, security issues, and edge
cases the author likely missed. Be specific: cite the file and line,
and explain the failure scenario, not just "this could be improved."
Save that as .claude/agents/code-reviewer.md, commit it, and every clone of the repo has the same reviewer from then on.
Claude Code checks five places, in priority order: organization-managed settings (highest), the --agents CLI flag for a single session, .claude/agents/ for the project, ~/.claude/agents/ for everything you personally work on, and plugin agents/ directories last. Project-scoped files are the ones worth committing: that's how a reviewer or test runner becomes a team default instead of a personal habit.
The description field matters more than its name suggests — the docs call it the delegation trigger. Claude Code reads it against your current task and decides whether to route to that subagent automatically, so vague descriptions like "helps with code" get ignored and specific ones like "reviews code for correctness bugs, use proactively after any change" get used. Beyond that:
tools: an allowlist, comma-separated (Read, Grep, Glob). Leave it off and the subagent inherits everything the main session has.disallowedTools: a denylist instead, useful when you want "everything except Bash."model: sonnet, opus, haiku, fable, inherit, or a full model ID. Cheap, mechanical jobs (grepping a repo, listing files) don't need your most expensive model.permissionMode: default, acceptEdits, plan, bypassPermissions, auto, or dontAsk. One catch worth knowing: if your main conversation is already running in bypassPermissions, acceptEdits, or auto mode, the subagent inherits that mode and ignores whatever you set here.skills and mcpServers: preload a skill or connect an MCP server at startup instead of relying on the subagent to discover it mid-task.memory: user, project, or local, for a subagent that should remember review preferences or corrections across sessions instead of starting fresh every time.You can invoke a subagent three ways once it exists: let Claude Code route to it automatically based on the description, name it directly ("have the code-reviewer subagent check my changes"), or run it as the whole session with claude --agent code-reviewer.
These cover the jobs that eat the most context in a normal day: reading code you didn't write, running tests, checking for security holes, and looking things up. Tool access is deliberately tight on all of them: a subagent that can only read files can't accidentally break something while it's "just checking."
Already shown above. Read-only (Read, Grep, Glob, no Write or Edit), running on Sonnet since review quality matters more than speed here. Run it after any PR-sized change, before you ask for a human review.
---
name: test-runner
description: Runs the project's test suite for changed files and explains failures. Use proactively after code changes, before committing.
tools: Read, Grep, Glob, Bash
model: sonnet
---
Run the relevant test command for whatever changed (check package.json
or the project's docs for the right script). If tests fail, read the
failure output, trace it back to the change that likely caused it, and
suggest a fix — don't just paste the stack trace back at the user.
This one needs Bash, so it's the least locked-down agent on the list. Scope it to a single project, not a shared ~/.claude/agents/ file, unless every project you touch uses the same test command.
---
name: repo-explorer
description: Maps an unfamiliar codebase — entry points, data flow, likely risk areas. Use when starting work in a repo you haven't touched before.
tools: Read, Grep, Glob
disallowedTools: Write, Edit, Bash
model: haiku
---
Find the application's main entry points, trace the core data flow,
and flag areas that look fragile or under-tested. Report back a short
map: what the thing does, how it's structured, where you'd be nervous
making a change.
Haiku is the right call here: this is a search-and-summarize job, not a reasoning-heavy one, and you'll run it often enough that the cost difference adds up.
---
name: security-reviewer
description: Checks authentication, secret handling, and input boundaries for vulnerabilities. Use before merging anything touching auth, user input, or external APIs.
tools: Read, Grep, Glob
model: sonnet
---
Review the changed code for OWASP-style issues: injection, broken auth,
secrets committed to the repo, missing input validation at trust
boundaries. For each finding, state the concrete input or scenario
that triggers it — not a generic "this could be a vulnerability."
Treat this as a second opinion, not a replacement for a real audit. For anything shipping to production, pair it with Claude Code's built-in security review workflow rather than relying on one subagent alone.
---
name: docs-researcher
description: Looks up official docs, changelogs, and release notes for a library or API. Use when the task needs current, version-specific information.
tools: WebSearch, WebFetch, Read
model: sonnet
---
Search for the official documentation or changelog for whatever is
being asked about. Prefer primary sources (official docs, GitHub
releases) over blog posts and forums. State the version the answer
applies to, and flag it clearly if you can't find an authoritative
source.
Handy for any project that pulls in fast-moving dependencies (which, per AGENTS.md-style project instructions, is most of them these days).
Two limits are worth knowing before you build a whole fleet of agents. Claude Code caps concurrent subagents at 20 by default (CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS), and subagent nesting at 3 layers below the main conversation (CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH, set to 1 to turn nesting off entirely). Neither matters for the five agents above (you'd have to be running a genuinely large fan-out to hit either one), but it's good to know the ceiling exists before you design something that depends on 30 agents running at once.
The other thing: subagents start with fresh context every time, minus forked sessions. That's the whole point, but it means a subagent can't remember what the main conversation already figured out unless you give it the memory field or feed it the relevant context in the task description. Don't expect a repo-explorer run to "know" about a decision you made five turns ago in the main thread.
If you're also setting up hooks or connecting MCP servers, subagents are the natural next layer on top: hooks fire automatically on tool events, subagents handle the bigger, bounded jobs a hook can't. And if you want multiple agents actually working a problem together rather than one at a time, that's a different pattern worth reading about separately in how agent teamwork works in practice.
New AI tools, automation workflows, and course drops — straight to your inbox. Join 2,400+ builders.
A step-by-step guide to writing SKILL.md for Claude Code: required frontmatter, instructions, scripts, testing, and the spec vs Claude Code differences.
lot-map is a free Claude Code plugin that draws a live map of tool calls, subagents, hooks and context usage beside your chat. Here's how to install and use it.
Google Antigravity's /teamwork needs a paid plan and can flood your folder with files. Claude Code subagents are cheaper but need manual orchestration. Here's which wins for long projects.
Comments