The Agent tool
The primary mechanism for multi-agent work is theAgent tool (wire name Task for backward compatibility). When Claude calls this tool it spawns a sub-agent with its own conversation context, tool access, and (optionally) an isolated git worktree.
The tool accepts the following parameters:
| Parameter | Description |
|---|---|
description | A short (3–5 word) label for the task |
prompt | The full task prompt for the sub-agent |
subagent_type | Optional: the type of specialized agent to use |
model | Optional: "sonnet", "opus", or "haiku" — overrides the agent definition’s model |
run_in_background | Set true to run without blocking; Claude is notified on completion |
isolation | "worktree" — runs the agent in an isolated git worktree |
cwd | Absolute path to run the agent in, overriding the working directory |
name | Name for the agent, making it addressable by other agents |
isolation: "worktree" is set, the agent receives a fresh git worktree so its filesystem changes don’t interfere with the parent.
Background tasks
Whenrun_in_background: true is passed, the sub-agent runs asynchronously. Claude receives a notification when it completes. Background tasks auto-activate after 120 seconds of non-interaction when CLAUDE_AUTO_BACKGROUND_TASKS is set or the corresponding feature flag is enabled. You can disable background tasks entirely with CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1.
Background tasks are visible and manageable with the /tasks command (also aliased as /bashes).
Built-in agents
Claude Code ships several built-in agents that are always available:| Agent type | Purpose |
|---|---|
| General purpose | Default agent for most delegated tasks |
| Explore | Read-only exploration of the codebase (one-shot; no follow-up messages) |
| Plan | Produces a structured plan (one-shot; no follow-up messages) |
| Statusline setup | Configures the terminal status line |
| Claude Code Guide | Guides users through Claude Code features (non-SDK only) |
| Verification | Verifies plan execution (when feature-flagged) |
Built-in agents can be disabled for SDK use by setting
CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS=1 (only effective in non-interactive/SDK mode).Custom agents
You can define custom agents in Markdown files placed in the.claude/agents/ directory. Claude Code loads agents from:
- Project agents:
.claude/agents/— scoped to the current project - User agents:
~/.claude/agents/— available in all projects - Managed agents: loaded from managed settings (enterprise/MDM)
- Plugin agents: provided by installed plugins
Agent frontmatter fields
| Field | Description |
|---|---|
description | What the agent does and when to use it (required) |
tools | Allowlist of tools the agent may use |
disallowedTools | Tools explicitly blocked for this agent |
model | Model to use (inherit to match the parent model) |
effort | Effort level (maps to thinking budget) |
permissionMode | Permission mode for the agent |
maxTurns | Maximum agentic turns before the agent stops |
mcpServers | MCP servers available to the agent (name reference or inline config) |
hooks | Session-scoped hooks registered when the agent starts |
skills | Skill names to preload |
memory | Persistent memory scope: "user", "project", or "local" |
background | true — always run as a background task when spawned |
isolation | "worktree" — always run in an isolated git worktree |
initialPrompt | Text prepended to the first user turn (slash commands work) |
Agent definition types
requiredMcpServers—agents that declare required MCP servers are hidden from the selector when those servers are not configured.
Agent teams and swarms
Agent teams are an experimental feature. Enable them with
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 or the --agent-teams CLI flag. A remote feature gate must also be active.Coordinator mode
SettingCLAUDE_CODE_COORDINATOR_MODE=1 replaces the standard built-in agent list with coordinator-specific agents designed to manage a pool of worker agents.
Team parameters (Agent tool)
When agent teams are enabled, theAgent tool gains additional parameters:
| Parameter | Description |
|---|---|
name | Name for the spawned teammate, making it addressable via SendMessage({to: name}) |
team_name | Team name for spawning; uses current team context if omitted |
mode | Permission mode for the spawned teammate (e.g., "plan") |
Use cases
Parallel test execution
Parallel test execution
Spawn one agent per test suite. Each runs in an isolated worktree so filesystem side-effects do not conflict.Claude will use
Agent with run_in_background: true and isolation: "worktree" for each suite, then wait for all to complete.Large refactors
Large refactors
Delegate independent modules to separate agents. The coordinator collects their diffs and resolves conflicts.
Explore then implement
Explore then implement
Use the built-in
Explore agent to map the codebase, then spawn an implementation agent with the exploration results as context.