A single Claude Code session has one failure mode that shows up the moment a task gets big: it investigates one theory, finds a plausible answer, and stops. Ask it to review a pull request and it gravitates toward one kind of issue. Ask it to find a bug and it anchors on the first explanation that fits. The fix is not a better prompt. It is more agents — working in parallel, with different lenses, arguing with each other.

That is what agent teams do. One session acts as the team lead: it breaks the work down, hands out tasks, and synthesizes the results. The teammates are separate Claude Code instances, each with its own context window, coordinating through a shared task list and direct messages. The feature is experimental and off by default, which is why most Claude Code users have never seen it. This tutorial turns it on, builds a small demo app for the team to work on, defines three reusable teammate roles, and runs two real team workflows: a parallel code review and a parallel feature build.

Diagram of an agent team: one lead connected through a shared task list and mailbox to three teammates
AI-generated illustration

What you’ll need#

  • Node.js 18 or later. Claude Code installs through npm. This tutorial verified the install on Node 24.
  • Claude Code 2.1.32 or later. Agent teams need at least that version; this tutorial uses 2.1.337, verified below.
  • A way to pay for tokens. A Claude Pro or Max subscription, or an Anthropic API key (ANTHROPIC_API_KEY). Teams only spawn in interactive sessions — headless mode (claude -p) and Agent SDK sessions never spawn teammates.
  • tmux (optional). Only needed for split-pane mode, where each teammate gets its own visible pane. Check with tmux -V. In-process mode, the default, works in any terminal.
  • A project to work in. The tutorial builds a small demo app below, so you can follow along without touching your own code.

Prices in this article were checked against Anthropic’s pricing pages and release notes on December 5, 2026; plans change, so confirm before you budget around them.

1. Install Claude Code and check your version#

Install globally from npm and confirm the version:

npm install -g @anthropic-ai/claude-code
claude --version

Expected output, verified in a clean sandbox on December 5, 2026:

2.1.337 (Claude Code)

Then start it in your project and sign in when it asks — with your Claude subscription, or with an Anthropic API key:

cd /path/to/your/project
claude

Two install notes worth knowing. First, the flags you will use later are real: claude --help lists --agent, --agents, --settings, and --allowedTools. The --teammate-mode flag from step 8 does not appear in --help — it is experimental, and the docs say so. Second, if claude --version reports that the native binary is not installed, the optional native package did not download: reinstall with npm install -g @anthropic-ai/claude-code --include=optional, then run the postinstall step by hand with node $(npm root -g)/@anthropic-ai/claude-code/install.cjs. That exact recovery fixed the same error in this tutorial’s sandbox.

2. Turn agent teams on#

Agent teams are disabled by default. Enable them with one environment variable, either for a single terminal session:

export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
claude

Or persistently, in your user settings file at ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  }
}

Project-level settings work too — the demo app in step 3 carries the flag in its own .claude/settings.json, so anyone who clones the repo gets teams enabled for that project. To confirm it took, ask the lead directly once the session starts: “Are agent teams enabled?” It will confirm, and describe what it can spawn.

One behavior change to expect: enabling teams also changes ordinary delegation. When Claude names a subagent on its own, that subagent launches as a teammate instead, so teams can form even when you did not ask for one. To get subagents back, set the variable to 0 — Claude Code reapplies settings-file env values when you save, so the next subagent Claude names launches as a subagent again, with no restart.

3. Build the demo project the team will work on#

Teams need a codebase with separable pieces — one file per owner, so teammates do not overwrite each other. Build a tiny notes API in Node with no dependencies. Every file below was created and run in the sandbox for this tutorial; the test passes and the server answers.

Create the project:

mkdir -p notes-app/src notes-app/test notes-app/.claude/agents notes-app/.claude/hooks
cd notes-app
npm init -y

package.json — set the test script to node --test, which discovers the test files on its own:

{
  "name": "notes-app",
  "version": "1.0.0",
  "private": true,
  "type": "commonjs",
  "scripts": {
    "start": "node src/server.js",
    "test": "node --test"
  }
}

src/store.js owns persistence — a JSON file, nothing else:

const fs = require("node:fs");
const path = require("node:path");

const DATA_FILE = path.join(__dirname, "..", "data", "notes.json");

function load() {
  try {
    return JSON.parse(fs.readFileSync(DATA_FILE, "utf8"));
  } catch {
    return [];
  }
}

function save(notes) {
  fs.mkdirSync(path.dirname(DATA_FILE), { recursive: true });
  fs.writeFileSync(DATA_FILE, JSON.stringify(notes, null, 2));
}

function list() { return load(); }

function create(title, body) {
  const notes = load();
  const note = { id: notes.length + 1, title: String(title).slice(0, 200), body: String(body ?? ""), createdAt: new Date().toISOString() };
  notes.push(note);
  save(notes);
  return note;
}

module.exports = { list, create };

src/auth.js owns the API-key check. It is deliberately tiny — it exists so the security reviewer in step 5 has something real to inspect:

// Tiny token check for the demo: a shared secret in an env var.
// NOT production auth — it exists so the security reviewer has
// something real to inspect.
function checkAuth(req) {
  const expected = process.env.NOTES_API_KEY;
  if (!expected) return false;
  const given = req.headers["x-api-key"];
  return typeof given === "string" && given.length === expected.length && given === expected;
}

module.exports = { checkAuth };

src/server.js owns HTTP only — no business logic in the route handlers:

const http = require("node:http");
const { list, create } = require("./store");
const { checkAuth } = require("./auth");

const PORT = process.env.PORT || 3000;

const server = http.createServer((req, res) => {
  res.setHeader("Content-Type", "application/json");
  if (req.method === "GET" && req.url === "/notes") {
    res.end(JSON.stringify(list()));
    return;
  }
  if (req.method === "POST" && req.url === "/notes") {
    if (!checkAuth(req)) { res.statusCode = 401; res.end(JSON.stringify({ error: "unauthorized" })); return; }
    let raw = "";
    req.on("data", (chunk) => { raw += chunk; });
    req.on("end", () => {
      try {
        const { title, body } = JSON.parse(raw);
        if (!title) { res.statusCode = 400; res.end(JSON.stringify({ error: "title required" })); return; }
        res.statusCode = 201;
        res.end(JSON.stringify(create(title, body)));
      } catch {
        res.statusCode = 400;
        res.end(JSON.stringify({ error: "invalid JSON" }));
      }
    });
    return;
  }
  res.statusCode = 404;
  res.end(JSON.stringify({ error: "not found" }));
});

server.listen(PORT, () => console.log(`notes-app listening on http://127.0.0.1:${PORT}`));

test/store.test.js — one test, so the team has a suite to run and extend:

const test = require("node:test");
const assert = require("node:assert/strict");
const { list, create } = require("../src/store");

test("create then list returns the note", () => {
  const note = create("hello", "world");
  assert.equal(note.title, "hello");
  assert.ok(list().some((n) => n.id === note.id));
});

CLAUDE.md — the project instructions every teammate loads automatically:

# notes-app

A tiny notes API (Node stdlib only, no dependencies). Run it with
`npm start`, test it with `npm test`.

Conventions:
- `src/store.js` owns persistence (JSON file in `data/notes.json`).
- `src/auth.js` owns the API-key check; never log the key.
- `src/server.js` owns HTTP only — no business logic in route handlers.
- Every new endpoint needs a test in `test/` before it ships.

Verify the app before any agent touches it. The test passes, and the server behaves exactly as written:

npm test
PORT=3000 NOTES_API_KEY=demo-secret node src/server.js &
curl -s http://127.0.0.1:3000/notes
curl -s -X POST http://127.0.0.1:3000/notes \
  -H 'Content-Type: application/json' \
  -d '{"title":"first note","body":"hello"}'
curl -s -X POST http://127.0.0.1:3000/notes \
  -H 'Content-Type: application/json' -H 'X-Api-Key: demo-secret' \
  -d '{"title":"first note","body":"hello"}'

Expected output, verified verbatim on a fresh checkout:

[]
{"error":"unauthorized"}
{"id":1,"title":"first note","body":"hello","createdAt":"2026-12-05T23:27:03.467Z"}
[{"id":1,"title":"first note","body":"hello","createdAt":"2026-12-05T23:27:03.467Z"}]

GET returns the empty list, POST without a key returns 401, POST with the key returns 201 with the created note. (The createdAt value will differ on your run; everything else should match exactly.) One gotcha surfaced while verifying this: node --test test/ fails on Node 24 — it tries to load the directory as a module. Use bare node --test, as in the package.json above, and it discovers the tests fine.

4. Define reusable teammate roles as subagent files#

A teammate can be any subagent definition: name the type when you ask Claude to spawn it, and Claude Code applies the definition to the teammate. Define each role once in .claude/agents/, and it works both as a delegated subagent in a single session and as a teammate in a team. Check these files into git so the whole team shares them.

Subagent files are Markdown with YAML frontmatter. Only name and description are required. The description is how Claude decides when to delegate to the role, so write it as a when-to-use sentence, not a job title. Here is the security reviewer, in full:

---
name: security-reviewer
description: Reviews code changes for security issues — auth, injection, secrets, data exposure. Use for security review of a PR or diff.
tools: Read, Grep, Glob
model: sonnet
---

You are a security reviewer. Read the code or diff you are given and report
only concrete, evidenced findings: the file and line, what an attacker could
do, and the smallest fix. Ignore style. Do not edit files — report only.

The other two follow the same shape. The performance reviewer gets the same read-only tools on Sonnet:

---
name: performance-reviewer
description: Reviews code changes for performance issues — hot loops, N+1 reads, blocking I/O, memory growth. Use for performance review of a PR or diff.
tools: Read, Grep, Glob
model: sonnet
---

You are a performance reviewer. Read the code or diff you are given and report
only concrete, evidenced findings: the file and line, the cost (with numbers
where you can measure them), and the smallest fix. Ignore style. Do not edit
files — report only.

And the test runner gets Bash as well, on the cheapest model, because its job is to run things rather than reason about them:

---
name: test-runner
description: Runs the test suite, reads failures, and reports exactly which tests fail and why. Use to verify test coverage of a PR or diff.
tools: Read, Grep, Glob, Bash
model: haiku
---

You verify tests. Run `npm test` in the project root, read the output, and
report: how many tests passed and failed, the failing test names, and the
shortest reproduction for each failure. Do not edit source files — if a test
fails, report it; fixing is the lead's call.

Three details from the docs shape how these files behave as teammates. First, the tools list is a hard limit, and Claude Code adds SendMessage (plus the Task tools, in a session that has them) on top — so a read-only reviewer can still message the team and claim tasks, but cannot edit a file. Second, model accepts an alias (sonnet, opus, haiku, fable), a full model ID such as claude-opus-5-5, or inherit for the lead’s model. Third, the skills field in a definition is not applied to a teammate — the teammate loads skills from your project and user settings instead. The frontmatter in all three files above was parsed and validated in the sandbox; a misspelled field is silently ignored, so keep the field names exactly as shown.

5. Spawn your first team: a parallel PR review#

Start with review, not implementation. It is the lowest-risk team workflow — the teammates only read — and it is where parallel exploration pays off immediately: one reviewer gravitates toward one kind of issue, three reviewers cover three kinds at once. From the notes-app directory, with teams enabled, give the lead this prompt:

claude
Review the current diff as a team of three. Spawn security-reviewer,
performance-reviewer, and test-runner as teammates — call them sec, perf,
and tests. Each reviews only through its own lens and reports findings
with file and line. Do not edit anything. When all three are done,
synthesize the findings into one ranked list.

Here is what happens behind that prompt. The lead populates a shared task list, spawns one teammate per role, and each teammate works in its own context window — they load the same project context (CLAUDE.md, MCP servers, skills) but not the lead’s conversation history, so put task-specific details in the spawn prompt. When a teammate finishes, it notifies the lead automatically and includes its final answer, and the lead synthesizes once all three are done.

Watch the team in the agent panel, below the prompt input. The keys that matter:

  • Up / Down arrows: select a teammate.
  • Enter: open the selected teammate’s transcript and message it directly.
  • Escape: clear the selection; while viewing a teammate, Escape interrupts that teammate’s current turn.
  • x on a selected teammate: stop it.
  • Ctrl+T: toggle the shared task list.

Two things can surprise you here. First, the panel alone does not prove a team formed: subagents appear in the same panel. If Claude used subagents instead, ask again and explicitly request an agent team. Second, idle teammate rows hide 30 seconds after the whole panel goes idle — the teammate is still running and addressable, just hidden. Send it a message by name to bring its row back, and when more than three teammates are idle at once, the surplus rows collapse into a single N idle agents row that Enter expands.

Naming teammates in the spawn prompt is worth doing every time. The lead assigns each teammate a name when it spawns them, and any teammate can message any other by that name — predictable names (sec, perf, tests) are what make later prompts like “ask perf to re-check the hot loop” work.

6. Run a parallel build: one feature, three owners#

Once review works, give the team something to build. The rule that makes parallel implementation work is file ownership: break the work so each teammate owns a different set of files. Two teammates editing the same file overwrite each other — the docs are blunt about this, and there is no merge step to save you.

For the demo app, add a DELETE /notes/:id endpoint, split three ways:

Build the DELETE endpoint as a team of three. Teammate store owns
src/store.js: add a remove(id) function that deletes by id and returns
true or false. Teammate api owns src/server.js: add the DELETE /notes/:id
route, which requires the API key and returns 404 for a missing id.
Teammate tests owns test/: add tests for remove, for DELETE with and
without a key, and for DELETE of a missing id. The api task depends on
the store task — do not start it until remove() exists. Nobody edits a
file owned by another teammate.

The shared task list is what makes this safe. Tasks have three states — pending, in progress, completed — and a task can depend on other tasks, showing as blocked until they finish. Teammates do not self-claim a blocked task on their own, although you or the lead can still assign one. When a teammate finishes a task that others depend on, Claude Code unblocks the dependents automatically, and claiming uses file locking so two teammates cannot grab the same task at once. The lead can assign tasks explicitly, or teammates can self-claim the next unassigned, unblocked task after finishing one.

Keep tasks the right size: a self-contained unit that produces a clear deliverable — a function, a test file, a review. Too small, and coordination overhead eats the benefit; too large, and a teammate works for a long time without check-ins, which is where wasted effort comes from. And check in while the team runs. If you notice the lead implementing tasks itself instead of waiting for teammates, tell it to keep going — or rather, tell it to wait: the lead sometimes decides the team is finished before all tasks actually are.

7. Steer the team: talk, plan, and pick models per teammate#

A team you cannot steer is a team you cannot trust. Three controls cover most of it.

Talk to any teammate directly. Each teammate is a full, independent Claude Code session. In-process mode, select it in the agent panel and press Enter, then type — plain text and skills go to that teammate, while built-in commands go to the lead’s session. In split-pane mode, click into its pane. Use this to redirect an approach that is not working, ask a follow-up, or give one teammate a finding from another: “sec, perf found an unbounded read in store.js — check whether it is reachable without a key.” To end a teammate gracefully, refer to it by name: “shut down perf.” The lead sends a shutdown request, the teammate can approve and exit gracefully or reject with an explanation, and the team config directory is removed when the lead’s session exits normally.

Have teammates plan before implementing. For complex or risky work, switch the lead into plan mode first, then ask for the teammate — a teammate spawned while the lead is in plan mode also works in plan mode until its plan is ready. When it finishes planning, it sends a plan approval request to the lead, which Claude Code approves as soon as it arrives unless you changed the teammate’s permission mode since it was spawned. If you want the lead to actually review the plan, put the running teammate in plan mode yourself by pressing Shift+Tab while viewing its session: the lead then approves the plan or sends it back for revision.

Pick a model per teammate. The lead’s model is the default, but reviewers do not need the flagship. Claude Code picks each teammate’s model from the first of these that applies: the model your spawn prompt names for that teammate (“Use Sonnet for each reviewer”), the subagent definition’s model field, the CLAUDE_CODE_SUBAGENT_MODEL environment variable, and finally the lead’s current model. If you set CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1, the first two sources do not apply and every teammate runs on the variable’s model (or the lead’s). A teammate on the lead’s model inherits the lead’s effort level; for a teammate on another model, set effort in its definition. The practical setup for the demo team is the one in step 4: lead on Opus, reviewers on Sonnet, test runner on Haiku.

Permissions follow the lead, with one asymmetry to know. A new teammate starts in the lead’s permission mode — including bypassPermissions if the lead was started with --dangerously-skip-permissions — except that a lead in dontAsk mode spawns teammates in Manual mode. You cannot set per-teammate permission modes at spawn time; cycle a running teammate’s mode with Shift+Tab. Teammate permission prompts appear in the lead session, so approve them there. And a message from one agent can never answer another agent’s permission prompt on your behalf — Claude Code treats an approval claim relayed from another agent as untrusted input, not as confirmation from you.

8. Split-pane mode: watch the whole team at once#

In-process mode keeps everything in one terminal and works anywhere. Split-pane mode gives each teammate its own pane, so you can see everyone’s output at once — the right choice for regular team use with three or more teammates. It needs tmux, or iTerm2 on macOS.

Set the mode in settings — teammateMode accepts in-process (the default), auto, tmux, or iterm2 — or pass it for one session with the experimental flag:

claude --teammate-mode tmux

With auto, Claude Code uses split panes when you are already inside a tmux session (or in iTerm2 with the it2 CLI), and falls back to in-process otherwise. If you run Claude Code outside tmux and iTerm2, set teammateMode to tmux and the panes open in a separate tmux session — copy the command from the View teammates line at the Claude Code prompt and run it in a second terminal to watch them. If panes do not open in your iTerm2 window, set the mode to iterm2 explicitly.

Four terminal panes side by side, each running an AI coding agent, with the lead pane highlighted
AI-generated illustration

Split-pane teammates behave slightly differently from in-process ones, and the differences are worth knowing before you commit to the mode. A split-pane teammate ignores the definition’s autoCompactWindow field, uses the subagent body in place of its default system prompt (an in-process teammate gets it appended), and applies the definition’s mcpServers — an in-process teammate ignores that field and loads MCP servers from project and user settings. On permissions, --disallowedTools and --tools carry over to split-pane teammates, but --allowedTools does not: to pre-approve actions for split-pane teammates, put the rules under permissions.allow in a --settings payload when you start the lead, for example claude --settings '{"permissions":{"allow":["Bash(npm *)"]}}'.

Cleanup: if teammates are still running in tmux after the lead’s session ends, close their panes in your own tmux window if you started inside tmux. Outside tmux, the panes live in a session named claude-swarm on a separate tmux server, which you reach with tmux’s -L flag — list sessions, then kill the leftover with tmux kill-session -t claude-swarm.

9. Enforce quality gates with hooks#

CLAUDE.md is guidance; hooks are enforcement. Three hook events exist for teams, and all three fire without matcher support — they always run on every occurrence:

  • TeammateIdle — runs when a teammate is about to go idle. Exit with code 2 to send feedback and keep the teammate working.
  • TaskCreated — runs when a task is being created. Exit with code 2 to prevent creation and send feedback.
  • TaskCompleted — runs when a task is being marked complete. Exit with code 2 to prevent completion and send feedback.

The most useful gate is the simplest: run the test suite whenever a task is marked complete, and block completion if the tests fail. Add it to the project’s .claude/settings.json — this is the same file that carries the enable flag from step 2, plus the pre-approved commands from step 8:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  },
  "teammateMode": "in-process",
  "permissions": {
    "allow": ["Bash(npm test)", "Bash(npm start)", "Bash(node --check *)"]
  },
  "hooks": {
    "TaskCompleted": [
      {
        "hooks": [
          { "type": "command", "command": "npm test" }
        ]
      }
    ]
  }
}

This file was validated in the sandbox — it parses as JSON, and the three agent definitions it references parse as YAML. The hook contract is the same as every Claude Code hook: the command receives JSON about the event on stdin, exit 0 allows the action, exit 2 blocks it and shows stderr to Claude as feedback. A TeammateIdle hook that checks “did you actually finish, or did you stop early?” is the second gate worth adding once the first one earns its keep: teammates sometimes stop after an error instead of recovering, and a nudge at idle time is cheaper than discovering the gap in review.

10. What it costs, and when not to use a team#

A team is not a cheaper way to do the same work. It is a more expensive way to do work that a single session does badly. Every teammate is a separate Claude instance with its own context window, so token use scales with the number of active teammates, and coordination adds its own overhead. The pricing, checked December 5, 2026:

ModelInput / 1M tokensOutput / 1M tokensRole in the demo team
Opus 5.5$4.00$20.00Lead — planning, synthesis, judgment calls
Sonnet 5.5$2.00$10.00Reviewers — security and performance lenses
HaikuLowest of the threeLowest of the threeTest runner — run the suite, report the result

One cost detail is easy to miss: an in-process teammate’s requests fall outside the main conversation’s cache TTL bucket, so its cache holds for five minutes by default, including on a Claude subscription. Set subagentPromptCacheTtl to 1h to keep it for an hour — the API bills one-hour cache writes at a higher rate, so it pays only when teammates pause between turns.

Know the limits before you lean on the feature. Agent teams are experimental, and the current limitations are documented rather than hidden: /resume and /rewind do not restore in-process teammates, so after resuming a session, tell the lead to spawn new ones; teammates sometimes fail to mark tasks complete, which blocks dependent tasks — check whether the work is actually done and update the status or nudge the teammate; shutdown can be slow because teammates finish their current request first; a session has exactly one team, scoped to that session; teammates cannot spawn their own teammates; and an in-process teammate’s own subagents run in the foreground, because a teammate’s background work cannot outlive the lead’s process.

Under the hood, the team is files on your disk. The team config lives at ~/.claude/teams/{team-name}/config.json and is removed when the lead’s session exits normally; the task list at ~/.claude/tasks/{team-name}/ stays on disk afterward (set cleanupPeriodDays to change how long it is kept); each agent’s mailbox is a JSON file at ~/.claude/teams/{team-name}/inboxes/{agent-name}.json. The team name is session- followed by the first eight characters of the session ID. Do not edit the config by hand — it holds runtime state such as session IDs and tmux pane IDs, and your changes are overwritten on the next state update. To define reusable teammate roles, use subagent definitions, as in step 4.

Which approach should you use?#

Claude Code now offers three ways to parallelize, and the choice is about coordination, not speed:

ApproachHow it worksToken costBest for
SubagentsHelpers inside one session; report results back to the main agentLower — results summarized backFocused tasks where only the result matters
Agent teamsPeer sessions with a shared task list and direct messagingHigher — each teammate is a full instanceWork needing discussion, challenge, and coordination
Git worktreesSeparate checkouts; you run the sessions yourselfVaries — no automated coordinationManual parallel sessions across branches

Use subagents when you need quick, focused workers that report back. Use agent teams when teammates need to share findings, challenge each other, and coordinate on their own — the parallel review and the competing-hypotheses debug are the two cases where the extra tokens are usually worthwhile. For sequential tasks, edits to the same file, or work with many dependencies, a single session or subagents are more effective than a team. And if you are new to teams, start with tasks that have clear boundaries and do not require writing code — reviewing a PR, researching a library, investigating a bug. Those show the value of parallel exploration without the coordination challenges of parallel implementation.

The takeaway#

Agent teams change what a coding session is good at, not just how fast it goes. One agent finds one answer; three agents with different lenses find the answer that survives being challenged. The setup is small — one environment variable, three role files, one settings file — and the habits that make it work are smaller still: name your teammates, give each one files it owns, keep tasks self-contained, and check in before the team runs too far unattended. Start with a parallel review of a real diff. The first time three reviewers come back with three different real findings, the token bill stops being the question.

Sources: Claude Code docs — Orchestrate teams of Claude Code sessions (updated December 3, 2026); Claude Code docs — Create custom subagents; Claude Code docs — Hooks reference; Anthropic — Introducing Claude Opus 4.6; Anthropic — Pricing.