Claude Code Mastery
20 partsTL;DR
Claude Code subagents let you split coding work across specialized assistants with their own context, tools, and instructions. The trick is using them for bounded work, not theatrical agent swarms.
Claude Code subagents are the first Claude Code feature that made "AI pair programmer" feel too small.
Anthropic's Claude Code now supports sub agents - specialized AI workers you can deploy for specific development tasks. Instead of cramming every instruction into a single system prompt, you build a team of focused agents, each with its own expertise, tools, and context. The better framing is: Claude Code can act like a lead developer coordinating a small set of specialists. One agent investigates failing tests. Another reviews a diff. Another reads docs. Another edits a bounded feature area. The main session keeps the plan and integrates the results.
That is powerful, but it is easy to overdo. Subagents are not magic workers you throw at every problem. They are a context-isolation and delegation tool. Use them when work is separable, reviewable, and scoped.
Last updated: June 27, 2026
| Topic | Official source |
|---|---|
| Claude Code subagents | Sub-agents docs |
| Claude Code overview | Claude Code overview |
| MCP integration | Claude Code MCP |
| Claude Code settings | Settings reference |
| Claude Code skills | Skills docs |
| Claude Code CLI | CLI reference |
For the broader Claude Code foundation, start with what Claude Code is and why Claude Code won. This post focuses on the subagent layer: when to use it, how to configure it, and how to keep parallel AI development from turning into merge chaos.
Claude Code subagents are specialized assistants with their own context window, system prompt, description, and tool access. The main Claude Code session delegates a bounded task to a subagent, waits for the result, and then decides what to do with it.
The official docs describe subagents as a way to create task-specific AI assistants. In practice, they solve three concrete problems:

That is why subagents sit next to agent teams, multi-agent coordination, and parallel merge discipline. The model matters, but the architecture around the model decides whether the work stays legible.
Subagents are configured as markdown files. Project agents live under .claude/agents/ in the repo. Global agents live in your user-level Claude configuration. The /agents command helps create and edit them.
A useful subagent definition has three parts:

The tool set is the part teams underuse. A research agent may need docs and web access but not file writes. A reviewer may need read-only code inspection and git diff but not deploy commands. A test agent may need shell access but should stay inside the repo and report exact commands.
For the security side of that choice, read Claude Code permissions settings and permissions, logs, and rollback for coding agents. Subagents are more useful when their authority is explicit.
Newsletter
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools, delivered free every week.
From the archive
Subagents are best when the task naturally splits into independent lanes.
Good fits:
Bad fits:

The rule is simple: use subagents when separation reduces complexity. Do not use them because "multi-agent" sounds advanced.
The strongest subagents are not theatrical personas. They are boring workflow units.
Test runner. Runs the relevant test suite, captures failures, identifies likely files, and returns exact command output plus a minimal diagnosis.
Code reviewer. Reads the diff, checks project rules, flags missing tests, and refuses to rewrite the feature unless asked.
Docs researcher. Fetches current docs for a library or API, summarizes only the relevant primitives, and links the exact sources.
Frontend QA reviewer. Checks responsiveness, layout stability, keyboard paths, focus states, and visual regressions against the design system.
Security reviewer. Looks for secret exposure, unsafe shell commands, permission expansion, prompt-injection surfaces, and dependency risk.
These are the same patterns behind agent eval receipts and long-running agent harnesses. A good subagent does not just say "done." It returns evidence a human or main agent can verify.
Subagents are not a replacement for git hygiene.
If two agents edit the same file, one of them will probably waste work. If one agent changes the API contract while another updates the UI against the old contract, the final integration step gets harder. If every subagent writes broad changes, the main agent becomes a conflict resolver instead of a coordinator.
The fix is to define lanes before dispatch:
app/api/.components/checkout/.For larger work, pair subagents with Claude Code worktrees or git worktrees for parallel agents. Worktree isolation gives each agent a clean branch-like workspace, then you merge only the candidates worth keeping.
MCP expands what subagents can do, but it also expands what they can reach.
A GitHub-connected reviewer can inspect issues and PRs. A Linear-connected planner can read product tasks. A database-connected investigator can inspect schema and logs. A docs-connected researcher can avoid stale API guesses.
That is useful, but each connected tool changes the trust boundary. Do not hand every MCP server to every subagent. Give the specialist the tool it needs for the job, and keep risky tools behind approval.
For MCP setup and selection, use the complete MCP server guide and the MCP picker. For agent security, connect this to prompt injection in open source repos, because untrusted content plus broad tools is where small mistakes get expensive.
If you are new to subagents, start with four.
docs-researcher
Reads current docs and returns concise source-backed notes. No code edits.
test-debugger
Runs targeted tests, explains failures, and proposes a minimal fix path. Shell allowed, file edits optional.
diff-reviewer
Reads git diff, checks project rules, flags risks, and asks for tests when missing. Read-only by default.
frontend-qa
Checks layout, accessibility, responsive behavior, and visible regressions. Browser or screenshot tools allowed, deploy tools denied.
That team covers most real workflows without turning your repo into an agent circus. Once those are useful, add domain specialists for your stack: billing, auth, data model, design system, mobile, or docs.
Claude Code subagents are valuable because they make agent work narrower.
The main agent should own the plan and integration. Subagents should own bounded tasks with scoped tools and explicit output receipts. If you keep that shape, parallel AI development becomes faster and easier to review. If you ignore it, subagents just multiply context drift.
The winning pattern is not "more agents." It is better delegation.
Claude Code subagents are specialized assistants the main Claude Code session can delegate to. Each subagent can have its own prompt, description, context window, and tool permissions, making it useful for focused work like research, testing, review, docs, or frontend QA.
Use the /agents command in Claude Code, then choose whether the agent should be project-specific or global. Project-specific subagents are stored as markdown files under .claude/agents/ so they can be reviewed and versioned with the repo.
Use subagents when work is separable: research while coding, review after implementation, test debugging in a separate context, or independent frontend/backend lanes. Avoid subagents for tiny one-file fixes or tasks where multiple agents need to edit the same lines.
Yes, subagents can be configured with tool access, including MCP-connected tools where appropriate. The safer pattern is to give each subagent only the MCP servers and core tools it needs for its role.
They can be safe when tool permissions are scoped, repo instruction files are reviewed, risky commands require approval, and each subagent returns auditable evidence. A subagent with broad write, shell, network, and MCP access should be treated as a powerful automation surface.
No. Subagents split cognitive work. Worktrees isolate filesystem changes. For serious parallel implementation, use both: each implementation agent gets its own worktree, while review or research agents can stay read-only.
Read next
Claude Code is Anthropic's AI coding agent for terminal, IDE, desktop, and browser workflows. Learn what it does, how it works, pricing, setup, MCP, skills, hooks, and subagents.
15 min readAnthropic brought git worktrees to Claude Code. Spawn multiple agents working on the same repo simultaneously - no merge conflicts, no context pollution, and your main branch stays clean.
6 min readThe definitive collection of Claude Code tips - sub-agents, hooks, worktrees, MCP, custom agents, keyboard shortcuts, and dozens of hidden features most developers never discover.
25 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Mac app for running parallel Claude Code, Codex, and Cursor agents in isolated workspaces. Watch every agent work at onc...
View ToolOpen-source AI coding agent for terminal, desktop, and IDE. Works with 75+ LLM providers including Claude, GPT, Gemini,...
View ToolAnthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolAI coding platform built for large, complex codebases. Context Engine indexes 500K+ files across repos with 100ms retrie...
View ToolUnlock pro skills and share private collections with your team.
View AppPro hooks for Claude Code. Private bundles, team sync, one-click install.
View AppEvery coding agent in one window. Stop alt-tabbing between Claude, Codex, and Cursor.
View AppA complete, citation-backed Claude Code course with setup, prompting systems, MCP, CI, security, cost controls, and capstone workflows.
ai-developmentIsolated git worktrees for parallel Claude Code sessions.
Claude CodeConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI Agents
Leveraging Anthropic's Subagent for Claude Code: A Step-by-Step Guide In this video, we explore Anthropic's newly released subagent feature for Cloud Code, which allows developers to create...

Open Design: Open-Source n8n App That Turns Any Website into a Brand Kit, Design System, HTML + Images The video introduces Open Design, an MIT-licensed full-stack template that combines AI and n8n a

Nimbalyst Demo: A Visual Workspace for Codex + Claude Code with Kanban, Plans, and AI Commits Try it: https://nimbalyst.com/ Star Repo Here: https://github.com/Nimbalyst/nimbalyst This video demos N

Claude Code is Anthropic's AI coding agent for terminal, IDE, desktop, and browser workflows. Learn what it does, how it...

Anthropic brought git worktrees to Claude Code. Spawn multiple agents working on the same repo simultaneously - no mer...

The definitive collection of Claude Code tips - sub-agents, hooks, worktrees, MCP, custom agents, keyboard shortcuts, an...

AI-generated interfaces tend to look the same - gradient-heavy, emoji-laden, and generic. The style guide method gives y...

A practical guide to using Claude Code in Next.js projects. CLAUDE.md config for App Router, common workflows, sub-agent...

From Claude Code to Gladia, the ten CLIs every AI-native developer should know. Install commands, trade-offs, and when t...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.