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:
Sub-agents inherit parent permissions by default. When
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: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
The body of the Markdown file becomes the agent’s system prompt.
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:
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.