The complete guide to Claude Code setup (Opus 4.6, Sonnet 4.6, Haiku 4.5). 1M token context window. 100+ hours saved. 25 hook events. Agent teams and task management. Production-tested patterns for skills, hooks, and MCP integration.
Agent teams are an experimental Claude Code feature that enables a lead agent to coordinate multiple teammate agents working in parallel. Enabled via CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, teams share a task list and mailbox for inter-agent communication. This guide covers team setup, natural team groupings, hook events for teams, and when to use teams vs standard subagents.
Purpose: Coordinate multiple agents working in parallel on complex tasks Source: Anthropic Claude Code documentation (agent teams research preview) Status: Experimental (requires feature flag) Difficulty: Advanced Time: 1 hour to design first team
Agent Teams extend the subagent system (Chapter 36) by enabling a lead agent to coordinate multiple teammates working in parallel with a shared task list and mailbox system.
Key distinction:
Task(). Agents can’t spawn other agents.Subagents (Current): Agent Teams (Experimental):
Main Conversation Lead Agent (main thread)
├── Task(agent-a) ├── Teammate A (parallel)
├── Task(agent-b) ├── Teammate B (parallel)
└── Task(agent-c) └── Teammate C (parallel)
Shared: task list + mailbox
# Set the environment variable
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
# Run Claude Code in agent mode
claude --agent
Warning: This is a research preview feature. Token usage is significantly higher because each teammate receives full context.
The main thread agent acts as coordinator:
Independent agents that:
Agents coordinate through:
TeammateIdle and TaskCompleted for lifecycleCreate team definitions in .claude/agent-teams/:
# Deployment Team
## Lead: deploy-agent
Coordinates the deployment pipeline.
## Teammates
### test-engineer
Runs pre-deployment tests and validates test coverage.
### monitoring-agent
Monitors logs and health checks after deployment.
## Workflow
1. Lead receives deployment request
2. test-engineer runs test suite in parallel
3. Lead deploys after tests pass
4. monitoring-agent watches logs for 10 minutes
5. Lead reports final status
Based on production patterns, these team compositions work well:
| Team | Lead | Teammates | Use Case |
|---|---|---|---|
| Deployment | deploy-agent | test-engineer, monitoring-agent | Multi-step deployments |
| Data Integrity | database-agent | data-validator, accuracy-checker | Gap detection + healing |
| AI Quality | ai-agent | debug-specialist, prompt-engineer | AI pipeline debugging |
| Code Review | reviewer-lead | security-agent, style-checker | Comprehensive PR review |
Two additional hook events support team coordination:
| Hook | Trigger | Use For |
|---|---|---|
TeammateIdle |
Teammate finishes its task | Assign new work |
TaskCompleted |
Shared task marked done | Check dependencies |
{
"hooks": {
"TeammateIdle": [
{
"hooks": [
{ "type": "command", "command": ".claude/hooks/team-coordinator.sh" }
]
}
],
"TaskCompleted": [
{
"hooks": [
{ "type": "command", "command": ".claude/hooks/task-tracker.sh" }
]
}
]
}
}
| Scenario | Use Subagents | Use Teams |
|---|---|---|
| Simple parallel tasks | Yes | No |
| Tasks need inter-agent communication | No | Yes |
| Cost-sensitive work | Yes | No |
| Complex multi-phase workflows | Maybe | Yes |
| Single coordinator needed | Yes | Yes |
| Agents need to share state | No | Yes |
Rule of thumb: Start with subagents. Only move to teams when you need agents to communicate with each other.
Agent teams use significantly more tokens:
Cost control strategies:
haiku model for simple teammatesmaxTurns on all team membersWhen teammates edit overlapping files, use isolation: worktree (see Chapter 36) to give each teammate its own git worktree. This prevents merge conflicts during parallel execution and returns isolated branches that the lead agent can reconcile.
Even without enabling teams, prepare your agent infrastructure:
This groundwork makes team adoption seamless when the feature stabilizes.
Previous: 36: Agents and Subagents