Home / Blog / Claude Code subagents: build your AI dev team
Updated: 2026-11-20 · 12 min read · Vladyslav Koshelyev

Claude Code subagents: build your AI dev team

TL;DR: a subagent is a separate helper with its own role, model, tools and its own context window. The main agent hands it a task — run tests, review a diff, research a question — and gets back only the result. That saves context and usage, and lets cheaper models do the grunt work. Here’s how to set them up, plus 8 subagents ready to drop in.

Claude Code subagents: build your AI dev team
🤖
8 Claude Code subagents (ZIP, 6 KB)code-reviewer, test-runner, debugger, security-auditor, docs-writer, researcher, refactor-planner, copywriter
Download

Why subagents

Ask Claude to run your tests and 2,000 lines of output land in your conversation: context fills up, and the next answer is pricier and worse. A subagent does the same job in a separate context window and returns three lines: “214 passed, 2 failed, here’s why”.

How the main agent delegates work to subagents
The main conversation sends a task and gets a short summary back — the noisy output stays with the subagent
  1. Clean context. Noisy work — test runs, logs, searching hundreds of files — stays out of your main thread.
  2. The right model for each job. Haiku for test runs, Opus for architecture plans, Sonnet for reviews.
  3. Least privilege. A security auditor can be read-only — it physically can’t change your code.

Subagent, skill or hook?

Skill vs subagent vs hook in Claude Code
Three tools for different jobs — and they combine well

Rule of thumb: a skill is “how to do it” instructions in your current conversation; a subagent is a separate worker with an isolated context; a hook is something that must always happen. Skills can even run inside a subagent with context: fork.

Built-in subagents

  • Explore — fast, read-only code search;
  • Plan — read-only research in plan mode;
  • general-purpose — a capable helper with all tools.

Your own subagents add project-specific roles on top.

Create a subagent

A subagent is a Markdown file with YAML frontmatter in .claude/agents/ (project, shared via git) or ~/.claude/agents/ (all your projects):

---
name: test-runner
description: "Runs the test suite or specific tests and reports only failures with their likely cause. Use when tests need to be run."
tools: Bash, Read, Grep, Glob
model: haiku
---

You run tests and summarise results. Find the right test command
in package.json, pyproject.toml, Makefile or CLAUDE.md.
Report: passed / failed / skipped; for each failure — test name,
file:line, the error in 1-3 lines and the likely cause.
Do not paste full logs. Do not modify code.

Only name and description are required; the body is the subagent’s system prompt. Note that a subagent does not see your conversation or Claude Code’s system prompt — only these instructions and the task — so make them self-contained.

Lesson learned: quote the description. An unquoted colon breaks the YAML and the file is silently skipped — I hit exactly this while building the pack.

Key settings

FieldWhat it does
descriptionwhen to use it — Claude delegates based on this. Add “Use proactively…” to have it invoked automatically
toolsallowed tools; omit to inherit all. Reviewers and planners: Read, Grep, Glob
modelhaiku, sonnet, opus, a full model ID, or inherit (default)
permissionModee.g. plan for research-only agents
maxTurnscap the number of steps
memorythe subagent’s own memory: user, project or local
isolation: worktreework in a separate git worktree so edits never collide with yours
skills, mcpServers, hooksper-subagent skills, MCP servers and hooks

Restart Claude Code if a new subagent doesn’t show up. To force one model for all subagents, set CLAUDE_CODE_SUBAGENT_MODEL.

Invoking subagents

> Run the tests with the test-runner subagent
> Use code-reviewer to check my changes before I commit
> Ask security-auditor to review the payments module
> Have researcher compare 3 job-queue libraries for Node.js

Claude also delegates on its own when a task matches a subagent’s description. See running tasks and their models with /tasks.

The 8 subagents in the pack

SubagentModelToolsJob
code-reviewersonnetread + gitreviews the diff by severity
test-runnerhaikubash, readruns tests, reports only failures
debuggerinheritread, edit, bashroot cause, fix and regression test
security-auditorsonnetread-onlysecurity audit table
docs-writersonnetread, writeREADME and API docs from real code
researchersonnetread + websourced answers, library comparisons
refactor-planneropusread-onlystep-by-step refactoring plan
copywritersonnetread, write, webmarketing copy without invented claims

Install: unzip and copy the files into your project’s .claude/agents/ or ~/.claude/agents/.

Workflows that work

  • Feature end to end: you describe it → main agent codes → test-runner runs tests → code-reviewer reviews the diff → main agent addresses the comments.
  • Pre-release: security-auditor + docs-writer for README and changelog.
  • Big refactor: refactor-planner drafts the plan → you approve → the main agent executes step by step.

Common mistakes

  • Vague descriptions — Claude can’t tell when to delegate.
  • Every tool for everyone — grant the minimum, especially for reviewer roles.
  • Opus everywhere — slow and expensive. Haiku handles routine work well.
  • Too many subagents per task — each one costs tokens. Two or three specialists beat ten generalists.

Wrap-up

Start with test-runner and code-reviewer — you’ll notice shorter conversations, lower usage and better quality on day one. Then add roles that match your process. See also hooks, skills and MCP.

Want subagents, skills and hooks designed around your team’s workflows — engineering through marketing? I build and roll them out end to end, directly or via Upwork. Learn more.

FAQ

What is a subagent in Claude Code?

A separate AI helper with its own role, model, tools and context window. The main agent delegates a task to it and receives only the result.

Where do subagents live?

In .claude/agents/ inside the project (shared with the team) or ~/.claude/agents/ for all your projects. Each subagent is a Markdown file with YAML frontmatter.

What’s the difference between a subagent and a skill?

A skill is instructions that run in your current conversation. A subagent is a separate worker with its own context and model that returns only its result.

Which model should a subagent use?

Haiku for routine work (tests, search), Sonnet for reviews and writing, Opus for complex planning. By default a subagent inherits the main agent’s model.

Let’s talk about your project

Describe the task in a couple of sentences — I reply within one business day. Free and no obligation.

Telegram   Discuss a project

AI assistants for your industry

Services