
To run claude code agent teams, you enable the experimental multi-agent orchestration architecture by setting CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in your environment or configuration settings. This architecture allows a primary Claude Code instance to act as an automated team lead that spawns autonomous teammates, maintains a centralized task board, and facilitates direct inter-agent messaging. In this guide, we explain the mechanics of agent teams, compare them to standard subagents, and walk through a complete hands-on example to coordinate security auditing, performance optimization, and automated testing across parallel sessions.
Prerequisites
Before launching an agent team, verify that your workstation meets these prerequisites:
- Claude Code CLI: A working installation of the official CLI tool with active authentication. If you are setting up your workspace on Windows, review our step-by-step tutorial on how to install Claude Code on Windows or follow the native installer for macOS and Linux.
- Up-to-Date Release: Agent teams require modern CLI features and protocol handlers. Ensure your CLI binary is running the latest channel by following the instructions in how to update Claude Code.
- Interactive Terminal: Agent teams require an interactive terminal session to spawn teammates. Headless execution modes (using the
-pargument) execute tasks linearly and cannot spawn interactive team instances. - Multiplexer (Optional for Split Panes): If you want each teammate displayed in its own dedicated window pane, install
tmuxon Linux/macOS or set up theit2tool inside iTerm2. If you prefer to manage multiple coding agents across independent git worktrees outside Claude Code, compare your workflow with Orca IDE.
Subagents vs. Agent Teams: Architectural Differences
While both subagents and agent teams run tasks in isolated context windows, their coordination models differ fundamentally:
| Feature | Standard Subagents | Agent Teams |
|---|---|---|
| Context Window | Isolated turn; results summarize directly back to caller | Independent, persistent context window per teammate |
| Communication | Hierarchical: reports only to the parent session | Direct peer-to-peer messaging via local JSON mailboxes |
| Work Coordination | Main session directs every individual sub-task | Shared task list with atomic, lock-based task claiming |
| Display Mode | Single terminal prompt with inline progress notifications | In-process agent switcher panel or native split panes (tmux/iTerm2) |
| Ideal Use Case | Focused data gathering, deep file reading, test suite execution | Complex multi-file refactoring, competitive debates, security reviews |
Standard subagents are ephemeral: they execute a specific task, report back, and terminate. Teammates remain active, register in ~/.claude/teams/{team-name}/config.json, exchange messages through mailboxes in ~/.claude/teams/{team-name}/inboxes/{agent-name}.json, and claim tasks from ~/.claude/tasks/{team-name}/.
Step 1: Enabling and Configuring Agent Teams
Agent teams are experimental and disabled by default. You can enable them globally or per project.
To enable the feature permanently for all your projects, add the experimental flag and your preferred display mode to your ~/.claude/settings.json file:
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
},
"teammateMode": "auto"
}
The teammateMode configuration key controls how agent interfaces are rendered on your display:
"auto": Teammates automatically spawn in separate split panes if Claude Code detects an activetmuxoriTerm2session. If running inside a standard terminal shell, it defaults to the in-process panel."in-process": All teammates run inside your active terminal window. You navigate between teammate sessions using keyboard shortcuts in the status panel."tmux": Forces teammates to launch in a backgroundtmuxsession, allowing you to connect and observe output in a separate terminal screen viatmux attach."iterm2": Integrates directly with the iTerm2 Python API to split your graphical window dynamically.
Alternatively, you can export the environment variable directly in your shell session before launching the CLI:
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
claude
Step 2: Hands-on Example – Spawning a Collaborative Refactoring Team
Consider a realistic scenario: auditing and refactoring an authentication and database module. Instead of running sequential passes in a single session, you deploy a team of three specialized engineers to work simultaneously.
Launch Claude Code in your project directory and provide a prompt defining the team structure and objectives:
claude "I am refactoring our user session and authentication service in src/auth/ and src/db/.
Spawn three teammates using Sonnet:
1. 'security-auditor': Audit src/auth/ for session token leakage and missing revocation checks.
2. 'perf-optimizer': Analyze database queries and connection handling in src/db/.
3. 'qa-engineer': Write integration tests in tests/auth/ that validate token expiration edge cases.
Coordinate the work using a shared task board and report findings before modifying code."
Once submitted, the team lead executes the following sequence autonomously:
1. Team Registration and Task Generation
The lead generates a team identifier (such as session-a8f3b12c) and decomposes your objective into actionable items on the task board:
- Task #1: Map authentication routes and JWT verification routines.
- Task #2: Audit PostgreSQL query execution plans and pool limits in
src/db/. - Task #3: Draft unit tests for revoked session tokens.
2. Autonomous Task Claiming
Teammates read the task directory and use file locking to claim assignments without race conditions. When security-auditor claims Task #1, its status updates across the team view from pending to in_progress.
3. Direct Inter-Agent Collaboration
Teammates communicate directly using the SendMessage protocol. If security-auditor finds plaintext tokens in a database table, it alerts perf-optimizer directly:
SendMessage(to="perf-optimizer", message="Found plaintext session tokens in the users table. If we add bcrypt hashing, check how query latency impacts database connection limits.")
The perf-optimizer receives this context on its next turn automatically.
Step 3: Interacting and Steering Teammates in Real Time
While the team lead coordinates the overall backlog, you retain direct interactive control over any teammate:
- Up / Down Arrow Keys: Cycle through the list of active and idle teammates in the terminal status panel.
- Enter: Open the selected teammate’s real-time transcript to type commands or additional instructions directly into their session.
- Escape: Return to the primary team lead prompt, or interrupt an active agent turn.
- Ctrl+T: Toggle the interactive task list to inspect completed, running, and blocked items.
- x: Stop a selected teammate immediately.
Step 4: Graceful Shutdown and Team Teardown
When work completes, the lead presents a consolidated summary. To terminate teammates cleanly, instruct the lead:
Ask the security-auditor and perf-optimizer teammates to shut down.
The lead sends a shutdown protocol signal. Teammates complete active operations and exit cleanly. Temporary team directories at ~/.claude/teams/{team-name}/ are removed automatically, while task histories stay archived in ~/.claude/tasks/.
Typical Errors and Troubleshooting
When implementing agent teams, you may encounter three common configuration or operational issues:
1. Teammates Fall Back to Ordinary Subagents
Symptom: Claude Code announces it is starting an agent, but no teammate panel appears, and operations execute sequentially.
Root Cause: The environment variable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is either missing, set to 0, or overridden by a local profile. Alternatively, the session was launched in non-interactive mode using the -p argument.
Fix: Ensure you are running an interactive terminal session and confirm that echo $CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS returns 1. Verify your configuration settings in ~/.claude/settings.json.
2. Split Panes Fail to Open in Terminal
Symptom: Teammates spawn in-process even though teammateMode is set to "tmux" or "auto".
Root Cause: The tmux binary is not found in your system’s PATH, or you are running inside a nested multiplexer session without socket permissions.
Fix: Verify your tmux installation by running which tmux in Linux/macOS. If you use iTerm2 on macOS, verify that the Python API is enabled under Preferences > General > Magic.
3. Blocked Tasks Due to Stalled Teammates
Symptom: A dependent task remains in a blocked state because a preceding teammate halted after encountering a tool error.
Root Cause: If a teammate encounters an unhandled exception or an ambiguous permission prompt, it may idle without clearing its task lock.
Fix: Select the stalled teammate in the agent panel using arrow keys, press Enter to inspect the error, and provide corrective instructions. Alternatively, instruct the team lead: Reassign task #2 to qa-engineer and mark task #1 completed.
Conclusion
Claude Code agent teams turn terminal-based AI development into a coordinated engineering unit. By splitting complex codebase modifications across autonomous teammates with shared task tracking and peer-to-peer messaging, you shorten review cycles and handle large refactoring jobs with clean contextual isolation.
Frequently Asked Questions
How do Claude Code agent teams differ from standard Claude Code subagents?
Standard subagents are temporary workers that perform a single query or task and report their summary back to the parent conversation before closing. In contrast, agent teams establish persistent teammates that collaborate simultaneously, claim tasks from a shared backlog, and communicate directly with each other via local message queues.
Can I assign different Claude models to individual teammates in an agent team?
Yes. You can explicitly specify the model for each teammate directly in your spawn prompt (for example, assigning Claude 3.5 Sonnet to an architectural reviewer and Claude 3.5 Haiku to a quick linting teammate). You can also configure the default teammate model using the CLAUDE_CODE_SUBAGENT_MODEL environment setting.
What happens when a teammate encounters a permission prompt?
In default security mode, teammate permission prompts bubble up to your primary terminal window, where you can inspect and approve or deny the request. If you want teammates to perform routine file edits without interruption, you can launch the session in acceptEdits mode or pre-approve common tool operations in your permission settings.
Hi, I’m Mark, the author of Clever IT Solutions: Mastering Technology for Success. I am passionate about empowering individuals to navigate the ever-changing world of information technology. With years of experience in the industry, I have honed my skills and knowledge to share with you. At Clever IT Solutions, we are dedicated to teaching you how to tackle any IT challenge, helping you stay ahead in today’s digital world. From troubleshooting common issues to mastering complex technologies, I am here to guide you every step of the way. Join me on this journey as we unlock the secrets to IT success.


