Agent Teams and Parallel Work
One worker returning a summary is simple. Several workers that run at once, share a task list and message each other is a different tool, with different costs. This chapter climbs the ladder from one subagent to a full agent team, runs the part of it that can be run non-interactively, and is plain about the part that was not run.
From One Helper to a Team
Before reaching for a team, Anthropic's own guidance is to check whether a lighter option does the job: subagents inside one session, or separate sessions that you run yourself and that pass findings between them (Source 1). The difference is in who talks to whom.
| Subagents | Agent teams | |
|---|---|---|
| Context | Own window; result returns to the caller | Own window; fully independent sessions |
| Communication | Report to the caller (named ones can also message each other) | Teammates message each other directly |
| Coordination | The main agent manages everything | Shared task list plus messages |
| Best for | Focused jobs where only the result matters | Work that needs discussion and challenge |
| Token cost | Lower: results are summarised back | Higher: every teammate is a separate Claude instance |
The table is Anthropic's comparison (Source 1), condensed. Notice that it gives no numbers for cost, and neither does this chapter: the documentation says only that teams use significantly more tokens and that usage scales with the number of active teammates.
Parallel Subagents, Run for Real
Agent teams cannot be run the way the other samples in this guide were, and section 03 explains why. What can be run non-interactively is the step below the team: two subagents from Chapter 20 working at the same time on different files. I asked a small, cheap main model (haiku) to coordinate, and let the two agents' own files choose their models:
Real run AG-03: prompt, every step, and the answer (Checked)
| # | Who | Event | Content (shortened) |
|---|---|---|---|
| 1 | Main session | Agent call | subagent_type=sql-reviewer |
| 2 | Main session | Agent call | subagent_type=api-reviewer |
| 3 | Subagent | Glob call | {"pattern": "**/*.java", "path": "<project>"} |
| 4 | Main session | Bash call | {"command": "sleep 1", "description": "Wait briefly for background reviewers"} |
| 5 | Subagent | Grep call | {"pattern": "class BookController|class ApiExceptionHandler", "path": "<project>", "output_mode": "files_with_matches"} |
| 6 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookService.java"} |
| 7 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookController.java"} |
| 8 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/Book.java"} |
| 9 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/ApiExceptionHandler.java"} |
| 10 | Main session | Text | The two reviewers are still running in the background. I'll share the combined list once both have reported back. |
| 11 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookRepository.java"} |
| 12 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/Author.java"} |
| 13 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookDto.java"} |
| 14 | Subagent | Glob call | {"pattern": "src/main/java/com/example/bookshelf/*.java", "path": "<project>"} |
| 15 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/CreateBookRequest.java"} |
| 16 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookDto.java"} |
| 17 | Subagent | Read call | {"file_path": "<project>/src/main/java/com/example/bookshelf/BookService.java"} |
| 18 | Subagent | Text | **Finding: `findById` runs two SELECTs for one book. It's a minor N+1 on a single row, not a correctness bug.** - **File and line:** `<proj… |
| 19 | Subagent | Grep call | {"pattern": "problemdetails|error\\.|ProblemDetail|ResponseEntityExceptionHandler", "path": "<scratch>", "output_mode": "content", "-n": true, "glob": |
| 20 | Subagent | Text | **Finding: validation failures on `POST /api/books` bypass ProblemDetail.** - **Where:** `<project>/src/main/java/com/example/bookshelf/Boo… |
| 21 | Main session | Grep call | {"pattern": "problemdetails", "path": "<project>", "output_mode": "content", "-n": true} |
| 22 | Main session | Text | Both reviewers finished. Here is one combined list, with the most important finding from each. 1. **BookService: `findById` triggers an ext… |
What the log shows, and what it does not:
- Parallel: the main session issued both
Agentcalls in a row before either reviewer had finished, and the table interleaves the reviewers' own calls. Their results arrived separately. - Mixed models: the log lists both
claude-haiku-5-5andclaude-sonnet-5-5. I did not trace which step used which. - A messy edge: the main session first answered "still running in the background", then produced a combined answer after the reviewers reported. The log contains three result events, and the cost shown is the sum of all three. The second repeats the first, so the figure is slightly high. If you script around
claude -pand subagents, expect more than one result and do not assume the first is final. - Checked: both findings were verified against the code and by measurement (see the author's check). The combined answer was properly cautious about what the reviewers had not run.
Turning Teams On
claude -p, including SDK sessions) Claude does not spawn teammates, and a subagent that Claude names runs as an ordinary subagent even with teams enabled (Source 1). Every sample in this guide is captured with -p, so I had no honest way to record a team session, and I did not fake one. Treat the rest as documentation read and organised, plus prompts I wrote and did not execute.The facts, from Anthropic's page:
- It is off by default. Set the environment variable
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMSto1in your shell or insettings.jsonunderenv. Without it no team is set up and Claude does not propose teammates. - Enabling it changes ordinary delegation. While it is on, a subagent that Claude gives a name to launches as a teammate, so a team can form even when you did not ask for one. Setting the variable to
0turns that back off. - You describe the team in plain words. The lead session creates the shared task list, spawns teammates and synthesises results. You can ask for specific names and models ("use Sonnet for each teammate").
- Two display modes. In-process (the default; all teammates inside your terminal, with arrow keys and Enter to open a teammate's transcript) or split panes, which need tmux or iTerm2 and are not supported in VS Code's integrated terminal, Windows Terminal or Ghostty. The
teammateModesetting and an experimental--teammate-modeflag choose between them. - Roles can be reused. You can name a subagent definition when spawning a teammate, so a
sql-reviewerfile works both as a delegated subagent and as a teammate. The definition'stoolsandmodelapply and its body is added to the teammate's instructions. Itsskillsare not applied, andmcpServersapplies only to split-pane teammates.
Team Prompts for the Bookshelf Project
Anthropic's page recommends starting with research and review, which have clear boundaries and avoid the file-conflict problems of parallel coding, and says the strongest cases are research and review, new modules, competing-hypothesis debugging and work that spans layers. These three prompts follow that advice for bookshelf. They are the author's, written for this chapter and not executed. They are patterns, not recorded results.
The documentation's reasoning for this shape is that a single investigator tends to stop at the first plausible explanation, while several investigators trying to disprove each other are less anchored (Source 1). That is the documented mechanism, not something shown here.
Controlling a Team
| Part | How it works (documented) |
|---|---|
| Task list | Tasks are pending, in progress or completed, and may depend on others. A blocked task is not self-claimed. Claiming uses file locking so two teammates cannot take the same task |
| Assigning | The lead assigns, or a teammate claims the next unassigned, unblocked task itself |
| Messaging | Each agent has a mailbox file; messages arrive automatically. You can open a teammate and message it directly |
| Permissions | Teammates start with the lead's permission mode, except dontAsk, which they do not inherit. Their permission prompts appear in the lead's session |
| Messages are not approval | A message from another agent never counts as your consent, and a teammate cannot relay a denied action to another teammate |
| Quality gates | Hooks TeammateIdle, TaskCreated and TaskCompleted: exit with code 2 to send feedback and keep the teammate working or block the task action |
| Shutdown | Ask the lead to shut a teammate down; the teammate can approve or refuse. The team's config directory is removed when the session ends; the task list stays on disk for the cleanup period |
The hook rows are the practical lever. They are how you stop a teammate marking a task done while the build is red. The hooks lab in Chapter 22 covers the whole contract; the short version: exit code 2 is the "block and tell Claude" signal in Claude Code's hook system.
What Teams Cost and Where They Break
The documented limitations are worth reading as a checklist before you start, because several are about losing work:
- No session resumption for in-process teammates.
/resumeand/rewinddo not restore them; the lead may try to message teammates that no longer exist. - Task status can lag. Teammates sometimes do not mark tasks complete, which blocks dependent tasks. You may need to nudge or update status by hand.
- One team per session, no nested teams, fixed lead. Teammates cannot spawn teams, and a teammate cannot become the lead.
- The lead can finish early or start doing the work itself. The page suggests telling it to wait for teammates.
- Split panes need tmux or iTerm2, and orphaned tmux sessions can remain after a session ends.
On size: the documentation suggests starting with three to five teammates and about five or six tasks per teammate, and says token cost scales linearly with the number of active teammates. A team is a bet that parallel exploration is worth that multiple. For routine work, a single session or a subagent is the better bet, which is the same answer the comparison table gave.
Key Takeaways, Exercises and Sources
- Climb the ladder one rung at a time: a single session, then subagents, then forks or your own parallel sessions, then a team.
- Parallel subagents are the cheap 80%. They work non-interactively, and the log shows both agents' calls.
- Teams are for debate and shared state: competing hypotheses, multi-lens review, owned modules.
- Experimental and interactive-only. Teams are off by default and are not spawned under
claude -p. - Own the files, gate the tasks. Give each teammate separate files and use hooks to enforce quality.
Exercise 1 Beginner
Take a review you would normally do in three passes (security, performance, tests). Run it as three parallel subagents in one prompt. Compare the time and the quality with doing it as one long prompt, and note which findings only one lens produced.
Learning outcome: feel the value and cost of parallelism without a team.
Exercise 2 Intermediate
Enable agent teams in a throwaway project and run Prompt A against a bug you already understand. Open each teammate's transcript. Did the debate change the answer, or did one teammate simply win? Write down what you saw before you read any summary.
Learning outcome: judge a team on evidence, not on the narrative.
Exercise 3 Advanced
Write a TaskCompleted hook that runs your test command and exits with code 2 when it fails. Then deliberately break a test, ask a teammate to finish a task, and check that completion is refused. Read the hooks reference first for the input format; do not guess it.
Learning outcome: enforce quality gates mechanically.
- Anthropic, Orchestrate teams of Claude Code sessions — status and enabling, comparison with subagents, display modes, task list and mailbox architecture, subagent definitions as teammates, permissions, hooks, token usage, best practices and limitations. The page was read in full.
- Anthropic, Create custom subagents — used for the subagent side of the comparison and for forks.
Only AG-03 (parallel subagents) was executed, on 2026-10-31. No agent team was started, and no output from one appears anywhere in this guide. The three team prompts are the author's and are labelled illustrative.