Subagents and Agent Teams

All plans1 min read
Agent TypeCapabilitiesBest For
ExploreRead, Glob, Grep, WebSearchFile search, Read code, Answer codebase questionsQuick exploration, finding patterns
PlanRead, Glob, Grep, WebSearchDesign strategies, Identify files, Consider trade offsArchitecture planning, complex task scoping
BashBash onlyRun commands, Git operations, Process managementBuild, test, deploy, git workflows
General PurposeAll toolsFull capability, Multi-step tasksComplex research, implementation tasks
CustomConfigurableWhatever you define in the agent fileDomain specific tasks, team workflows

0

Built-in agent types

0x

Faster with parallel agents

0

Extra cost (uses same API)

When to use subagents

Subagents shine when you have independent tasks that can run in parallel. If you need to search three different directories, research an API, and check test coverage all at once, subagents can do all of that simultaneously. They also protect your main conversation context: a subagent doing deep research won't fill up your context window with intermediate results.

Creating a custom agent

Custom agents are markdown files in ~/.claude/agents/. Each file has YAML frontmatter defining the agent's identity and a system prompt body. Here is a simplified example:

---
name: code-reviewer
description: "Reviews code for quality, security, and best practices"
model: opus
tools: Read, Grep, Glob
---

You are a senior code reviewer. When given code or a PR diff:
1. Check for security vulnerabilities (OWASP top 10)
2. Identify performance issues
3. Flag code style violations
4. Suggest concrete improvements with examples

Once saved, this agent becomes available to Claude Code and can be invoked automatically when a task matches its description, or manually through the Task tool.

No extra cost for subagents

Subagents use the same API credits or subscription quota as the main Claude Code session. Launching five parallel Explore agents costs the same total tokens as running those five searches sequentially. The benefit is speed (parallel execution) and context cleanliness (results stay in the subagent's context until summarized back), not cost savings.