Skip to content

Claude Code Mastery5 / 12

Sub-Agents — The 11 Specialized Experts Inside Claude Code

Slash commands reuse prompts. Sub-agents reuse whole personas — code-reviewer, test-writer, migration-runner. Here is the team you should have on day one.

Most teams treat Claude Code as a single agent. That is half the value.

The real unlock is sub-agents — specialized personas with their own system prompts, allowed tools, and rules. You don't talk to "Claude." You talk to code-reviewer, then to test-writer, then to migration-runner. Each one stays in its lane and does one thing well.

Here are the 11 sub-agents I run on every serious codebase, what they own, and the .claude/agents/<name>.md definitions that make them work.

Why sub-agents at all?

A monolithic agent is a generalist. Generalists are great when the problem is small. On a real codebase you want:

  • A reviewer that only reviews and never writes code.
  • A test-writer that never modifies application code.
  • A migration runner that only runs migrations and stops.

The constraint is the feature. Each sub-agent is bound by a system prompt and a tool allowlist. That bounding is what makes them reliable.

The 11 I keep on every project

1. code-reviewer

Owns: post-implementation review. Reads diffs, never writes them.

# system
You review diffs. You do not modify files. You output:
1. Bugs (with file:line)
2. Risk areas (security, perf, breaking changes)
3. Style/convention violations against CLAUDE.md
4. A 1-line verdict: SHIP, FIX-FIRST, or REWRITE.

# tools
allow: ["git diff *", "rg *", "cat *"]
deny:  ["edit", "shell-write"]

2. test-writer

Writes new tests. Never edits production code. If the test fails, it reports the failure — it does not "fix" it.

3. test-fixer

The mirror image. Reads failing tests, modifies production code to make them pass, never edits the test itself unless the test is provably wrong.

4. migration-runner

Runs DB migrations. Allowed: pnpm db:migrate, psql -c "...". Denied: every other shell command.

5. dependency-auditor

pnpm outdated, pnpm audit, npm-check-updates. Outputs a markdown table of upgrades + risk. Does not run upgrades unsupervised.

6. release-bot

Generates changelogs, version bumps, tags. Never pushes — push is human-only.

7. docs-writer

Touches README.md, docs/, JSDoc comments. Forbidden from src/ and app/.

8. refactor-surgeon

Pure refactors. Constraint: zero behaviour change, all tests must pass before and after. If a test fails, the refactor was not pure — back out.

9. incident-responder

The one you only summon during an outage. Reads logs, writes a postmortem skeleton, suggests rollback commands. Never runs production commands.

10. architect

Read-only. Looks at the codebase, produces an ADR (architecture decision record) draft when you ask "should we add X?"

11. ci-fixer

Reads .github/workflows/, the failing CI logs, and proposes minimal changes. Allowed to push branches, never to push to main.

What goes in .claude/agents/<name>.md

Each agent is one file. Here's the canonical shape:

---
name: code-reviewer
model: claude-sonnet-4
---

# system
<persona + scope + output format>

# tools
allow: [...]
deny: [...]

# CLAUDE.md respect
Read project CLAUDE.md before acting.

That is it. Commit this folder; everyone on the team gets the same crew.

How they collaborate (without being called "multi-agent")

This is not yet multi-agent pipelines (that is Article 7). It is the simpler choreography:

You → /agents → pick test-writer → "write tests for lib/cache.ts"
  → /agents → pick test-fixer    → "make them pass"
  → /agents → pick code-reviewer → "review the diff"
  → /release-notes

Each step is bounded. Each step is reviewable. You never have a single agent that "wrote the tests, fixed the code, reviewed itself, and pushed to main." That kind of self-review is exactly the failure mode you want to design out.

The naming rule

Sub-agents are named after roles, not tools. code-reviewer, not claude-with-rg. migration-runner, not psql-runner. Roles compose; tools don't.

When a new teammate joins, they read .claude/agents/ once and immediately understand the operating model. That is documentation by configuration.

A live example: shipping a feature with the crew

You: /agents test-writer
> Write vitest cases for lib/cache.ts covering TTL expiry and LRU eviction.
test-writer: <writes 2 tests, both fail, reports>

You: /agents test-fixer
> Make those tests pass without changing lib/cache.test.ts.
test-fixer: <implements TTL + LRU in lib/cache.ts, tests green>

You: /agents code-reviewer
> Review the diff.
code-reviewer: SHIP.

You: /release-notes
release-bot: <writes changelog>

You: git checkout -b feat/cache-lru && git commit && gh pr create

You wrote ~20 lines of natural language. Three different specialists wrote / verified / signed off the actual code. That is the workflow.

Building your own

Start with two: code-reviewer and test-writer. Use them on every PR for a week. You will discover where the friction is and add the third one organically — usually ci-fixer or migration-runner.

By month two, every team I've onboarded has 6-8 sub-agents committed in .claude/agents/, and they're treated like infrastructure.


Next article: Production Codebase Safety — permissions, guardrails, and the things you should never let any sub-agent touch unsupervised.

Share this article

#ClaudeCode #AgenticAI #AI #DevTools #SoftwareEngineering

LinkedInX / TwitterBlueskyThreadsRedditHacker NewsWhatsAppEmail

Series — Claude Code Mastery

  1. Part 01Claude Code vs ChatGPT vs Copilot vs AgentsMost developers are using the wrong AI tool for the wrong job. Here is why — and what to do instead.
  2. Part 02Installation + The Antigravity WorkflowInstalling Claude Code is a 30-second job. Setting up the workflow that makes the agent feel like it's doing the heavy lifting — that's the part nobody writes about.
  3. Part 03Writing Prompts That Work"Make it better" is not a prompt. "Refactor this for performance" is not a prompt. Here is the four-part structure that makes Claude Code actually finish what you asked.
  4. Part 04Slash Commands — Building a Project from A to Z/init, /agents, /compact and your own custom commands. The toolkit that lets you go from empty folder to running app without leaving the Claude prompt.
  5. Part 05Sub-Agents — The 11 Specialized Experts Inside Claude Codeyou are hereSlash commands reuse prompts. Sub-agents reuse whole personas — code-reviewer, test-writer, migration-runner. Here is the team you should have on day one.
  6. Part 06Production Codebase SafetyPermissions, guardrails, and what not to automate. The unsexy article that decides whether Claude Code becomes infrastructure or becomes the reason you got paged at 2 AM.
  7. Part 07Multi-Agent PipelinesChaining sub-agents, running them in parallel, and the patterns for 'review-while-coding' without losing your mind. Where Claude Code starts to feel like a small engineering org.
  8. Part 08Building Complete FeaturesFrom Linear ticket to merged PR with Claude Code. A real, honest walk-through — what the prompt looked like, what the agent got right, what I caught in review.
  9. Part 09Testing and DebuggingLetting Claude Code own the entire test loop. Including the parts that make engineers nervous: regressions, flakies, integration tests, and the stack-trace whisperer.
  10. Part 10Team WorkflowsHow engineering teams are actually integrating Claude Code today. The shared .claude/ folder, the review rituals, and the anti-patterns I keep seeing in the wild.
  11. Part 11Advanced Patterns — Hooks, MCP Servers, Custom Tools, System PromptsOnce you've outgrown the defaults: hooks for deterministic side effects, MCP servers for org-specific data, custom tools, and system-prompt surgery.
  12. Part 12The Future of Agentic DevelopmentWhere this is going in 2026 and beyond. What I'd bet on, what I would not, and the line where I get sceptical of the hype.

Keep learning

Skill in the catalogue

prompt-engineer

Transforms user prompts into optimized prompts using frameworks (RTF, RISEN, Chain of Thought, RODES, Chain of Density, RACE, RISE, STAR, SOAP, CLEAR, GROW)

Open the skill →

Course

The Claude Mastery course

12 modules · 5 languages · certificate · 3-day free trial.

See plans →
LinkedInX / TwitterBlueskyThreads