← Back to Blog

AI Agent Teams: Running 5 Parallel Agents on One Project with Claude Code

(Unofficial)

This guide is independently community-maintained. It is not affiliated with, endorsed by, or sponsored by the vendor of the third-party tool it covers. All third-party trademarks are the property of their respective owners.

December 1, 2026
Isometric illustration of a glowing violet orchestrator hub coordinating four autonomous white-and-violet coding agents working in parallel tracks with emerald checkmark build cards.

TL;DR

"Claude Code agent teams" is not a single switch — it is a combination of three official parallel mechanisms: an isolated git checkout per session (claude --worktree), one screen that shows every background session (Agent View, claude agents), and sub-agents that take focused sub-tasks inside a session with their own context. The three stack: sessions dispatched from Agent View land in their own worktree automatically, and a sub-agent can take its own checkout with isolation: worktree.

Running 5 agents on one project takes five reproducible steps:

  1. Partition the files first: split the files you intend to change into 5 non-overlapping slices, then decide who owns which slice. That is what keeps parallel work from colliding; worktrees are the safety net, not the plan.
  2. One worktree per agent: claude --worktree feature-a through claude --worktree feature-e, each landing in .claude/worktrees/<name>/ with its own worktree-<name> branch.
  3. Watch the whole board from Agent View: claude agents opens a panel showing each session's state and which ones need you. To move a conclusion between sessions, use cross-session messaging.
  4. Split work inside one session with sub-agents: each sub-agent runs in its own context and returns only a summary; isolation: worktree gives it an isolated checkout too.
  5. Do the accounting: running several sessions at once multiplies token usage, which Anthropic states explicitly on the Claude Code costs page. Pay-as-you-go billing charges per token.

Below: the commands, the isolation rules, the cleanup and resume behavior, and the billing arithmetic, all against the official documentation.

Table of contents

1. What "Claude Code agent teams" actually is

The official documentation splits "doing several things at once" into five shapes (Claude Code docs, "Run agents in parallel", as-of 2026-11-07): subagents, agent view, agent teams, dynamic workflows, and projects. They differ in who coordinates and how much they talk to each other, so match your workload to the right one before writing any prompt.

  • Sub-agents: workers delegated inside a single session. They run in their own context and hand back a summary. Best for work whose output you need but will not quote later — searches, log triage, file contents that would otherwise flood the main conversation.
  • Agent View: one screen where you dispatch and watch background sessions, opened with claude agents. The docs mark it as a research preview. Best when you have several independent jobs, want to hand them off, glance at status, and only step in when needed.
  • Agent teams: coordinated sessions with a shared task list, inter-agent messaging, and a lead that assigns and collects. The docs mark it experimental and off by default.
  • Dynamic workflows: a script that runs many sub-agents and cross-checks their results. Best for work too large to coordinate turn by turn — a repository-wide audit, a migration touching hundreds of files.
  • Projects: a long-running conversation in claude.ai/code or the desktop app, where Claude starts parallel threads that can run in the cloud or, with Remote Control, on your own machine.

Three supporting tools sit alongside these. They are not ways to run agents, but they decide whether parallel work is safe:

  • Worktrees: a separate git checkout per session, so parallel sessions never edit the same files. Use them for sessions you start yourself; Agent View moves dispatched sessions into their own worktree, and the sub-agents you spawn can each get one too.
  • Cross-session messaging: Claude can list and message other Claude Code sessions on this machine, another machine, or on the web — so sessions you started yourself can exchange conclusions.
  • /batch: a skill that splits one large change into 5 to 30 worktree-isolated sub-agents, each opening a pull request.

Claude Code agent teams, in practice, means assembling these: worktrees for isolation, Agent View for dispatch, sub-agents for decomposition. What decides the outcome is the partitioning, not the commands.

The documentation gives three questions for choosing:

  • Who coordinates? Claude delegates inside one conversation and collects the results → subagents. You hand off and come back later → agent view. Claude plans, assigns, and supervises a set of workers → agent teams (experimental, off by default). The plan lives in a script rather than in Claude's turn-by-turn judgment → dynamic workflows.
  • Do the workers need to talk? Sub-agents report back to the conversation that spawned them; Agent View sessions report only to you; teammates in an agent team message each other directly and share a task list when they have the Task tools; sessions you start yourself talk through cross-session messaging.
  • Will they touch the same files? If yes, isolate with worktrees. And remember one official caveat: agent teams do not isolate teammates into their own worktrees, so you have to partition the work yourself.

2. claude --worktree: one isolated checkout per session

--worktree (short form -w) is the most direct command in the docs for parallelism: give it a name and it creates an isolated checkout and starts Claude inside it. In the Claude Code agent teams setup, worktrees are the base layer: isolation first, parallelism second.

bash
# add this to ~/.zshrc or ~/.bashrc
claude --worktree feature-auth
claude --worktree feature-billing

Those two commands start two independent sessions, working in .claude/worktrees/feature-auth/ and .claude/worktrees/feature-billing/. Run the second one in a different terminal and the two sessions share nothing but the repository history.

  • Where it lands: worktrees are created under .claude/worktrees/<name>/ at the repository root, each on a new branch named worktree-<name>. Omit the name and Claude generates one.
  • Trust dialog: interactive runs require the directory to be trusted. Run claude once in it and accept the trust prompt, otherwise --worktree exits with an error telling you to do that. The non-interactive claude -p --worktree skips the trust check.
  • Add it to .gitignore: put .claude/worktrees/ in .gitignore, or the main checkout fills up with untracked files.
  • Set the environment up again: a worktree is a fresh checkout, so dependencies need installing in it. To carry gitignored files such as .env into every new worktree, add a .worktreeinclude file.
  • Let Claude enter one itself: ask in the session to work in a worktree and Claude calls the EnterWorktree tool. It can also switch to another worktree under .claude/worktrees/, leaving the previous one untouched on disk. Moving to a path outside .claude/worktrees/ asks for approval first, and the move takes the session's working directory, write access, and project configuration (such as CLAUDE.md and settings) with it.

Isolation is enforced, not merely encouraged. The docs list four checks, and the same rules apply whether the session started with --worktree, entered through EnterWorktree, or resumed a worktree session — and they cover every sub-agent spawned from an isolated session:

  • File edits: Edit, Write, and NotebookEdit are blocked from targeting paths in the main checkout.
  • Command working directory: Bash, PowerShell, and Monitor commands are blocked when the working directory resolves to the main checkout, or when it cannot be confirmed.
  • Git redirects: commands that redirect git into the main checkout are blocked — git -C, --git-dir, GIT_DIR / GIT_WORK_TREE, or changing into the main checkout and running git from there.
  • Command shape: when the command text cannot demonstrate that its git runs inside the worktree, it is rejected, and Claude is told how to rewrite it as plain commands.

The boundary matters: those four checks read the edit target, the command's working directory, and the command text itself. They do not trace which files a shell command writes. A cp or a shell redirect that writes into the main checkout without running git is outside their scope, and stays subject to your permission and sandbox settings.

One more detail that surprises people: hook paths do not follow the worktree. ${CLAUDE_PROJECT_DIR} still points at the directory the session started in, so hooks run in the main checkout; the worktree path is in the cwd field of the hook's input JSON.

Cleanup on exit follows rules the docs spell out:

  • On exit, Claude checks whether removal would destroy work: changed or untracked files, uncommitted work in submodules, new commits.
  • Unnamed and clean: the worktree and its branch are removed automatically.
  • Named session: you are asked first. Keep it and the directory and branch survive, so you can come back with claude --worktree --resume; remove it and both go.
  • -p non-interactive: there is no exit prompt, so nothing is cleaned up and the lock taken at creation stays. Remove it with git worktree remove; if git refuses because the worktree is locked, run git worktree unlock first.

Two recovery details are worth keeping: --continue picks up the most recent session recorded under the directory you launch from, and session recording follows the working directory, so resuming from the main checkout lands you back in its own worktree while a --fork-session copy stays in the launch directory with the original worktree untouched.

3. Agent View: every background session on one screen

Worktrees solve "agents fight over files". Agent View solves "I cannot tell what is happening". The entry point is claude agents:

  • One screen, every session: each session's state and which ones need your input, together in one place.
  • Dispatch and take over: dispatch new background sessions from the panel, send an existing interactive session to the background, or attach to a session and read its output directly.
  • Dispatch implies isolation: a session dispatched from Agent View enters its own worktree before it edits any file, so you do not pass extra flags.
  • /agents and claude agents are different things: /agents creates and edits custom sub-agent files, and since v2.1.198 it no longer opens a panel — it prints a pointer to where the sub-agent files live.
  • /tasks shows the current session's background work: every item can be checked, attached, or stopped, including finished sub-agents. Named background sub-agents also appear in the @ typeahead with their status.

The docs close this page with a line worth memorizing: running several sessions or sub-agents at once multiplies token usage. That is why parallel work needs a budget, which section 7 covers.

Agent View is the dispatch surface of Claude Code agent teams: where each session is running, where it is stuck, and which lane needs a human — visible at a glance instead of polling five terminals.

4. Sub-agents: splitting work inside a single session

A sub-agent is parallelism *within* one session. It has its own context window, reads files and runs commands on its own, and returns only a conclusion to the main conversation — so the main conversation does not get flooded with search results and logs. This is where Claude Code sub-agents sit in the wider parallel setup: they solve how much work one session can absorb, while worktrees handle isolation.

  • Where they are defined: .claude/agents/ (project level, committed and shared with the team) or ~/.claude/agents/ (user level, applies to every project). Claude Code sub-agents are plain Markdown with a frontmatter block, so a team can review them in a pull request like any other file.
  • Three fields: name (how you invoke it), description (when it should be delegated to — say what it does and when to use it), and tools (the minimum set it needs).
  • isolation: worktree pins the sub-agent to its own worktree for every run.
markdown
---
name: refactorer
description: Performs mechanical refactors on the given module, then runs the tests and reports.
tools: Read, Grep, Glob, Edit, Bash
isolation: worktree
---

Apply the requested refactor across the relevant files, then run the tests and report the result.
  • Each sub-agent gets a temporary worktree: when it finishes, a sub-agent that left no changes is cleaned up automatically, and one that did leave changes keeps its directory until a periodic cleanup reclaims it. You can also just say "use worktrees for your agents" to isolate a delegation on the spot.
  • A forked sub-agent is a different thing: /subtask starts a sub-agent that inherits your full conversation context instead of starting from zero. With agent view turned off the command becomes /fork and /subtask is unavailable. It is a way to spawn, not a separate interface.
  • /batch is the packaged version: it splits one large change into 5 to 30 worktree-isolated sub-agents, each opening a pull request. If you want to fan out widely without hand-rolling the orchestration, that is the shortest path.

5. Agent teams: letting Claude act as the lead

Agent teams are the tier where Claude runs the crew: a shared task list, teammates messaging each other, and a lead that assigns and collects. It is the most literal reading of "Claude Code agent teams" — and the least stable.

  • Off by default: it is an experimental feature. To use it, set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS to 1, either in the env block of settings.json or as a shell environment variable.
json
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
  }
}
  • Without the variable: no team directory is created, no directory is written, and Claude neither spawns nor proposes teammates.
  • With it, ordinary delegation changes too: sub-agents Claude names itself start as teammates, and a team can form on its own when you did not ask for one. The docs describe how to turn that behavior off.
  • Non-interactive mode does not spawn teammates: in -p mode, including Agent SDK sessions, no teammates are created, and named sub-agents run as ordinary sub-agents. Spawning teammates requires an interactive session.
  • Describe the job and it runs: give it a role and a perspective, and Claude creates the shared task list, spawns one teammate per perspective, lets them challenge each other, and summarizes at the end. Teammates message each other directly and share the task list when they have the Task tools.
  • Two display modes: in-process by default, with every teammate in the main terminal — arrow keys to select, Enter to view and message a teammate, Esc to interrupt its current turn. split panes gives each teammate a pane, and needs tmux or iTerm2 with the it2 CLI. Set teammateMode (auto / tmux / iterm2) in ~/.claude/settings.json, or override it for one session with claude --teammate-mode auto (the flag is experimental and does not appear in claude --help).
  • Known limitations: the docs list open problems around session resumption, task coordination, and shutdown behavior.
  • The cost: the docs state that the coordination overhead is significantly more than a single session, so token usage goes up — and, as noted earlier, teammates are not isolated into worktrees.

The short version: use agent teams when the pieces are genuinely independent and the teammates need to discuss them. For serial tasks, repeated edits to the same file, or dense dependencies, a single session with sub-agents works better.

6. Running 5 parallel agents on one project

This is the main playbook of the article: a mid-sized repository, split into 5 non-overlapping lines of work, each with its own worktree and its own session. It is also the most common shape of Claude Code parallel agents in practice.

6.1 Partition before you start

  • Split by file ownership: each of the 5 roles owns a distinct set of files, with no overlap. If this step is sloppy, worktrees only catch the collisions after the fact.
  • Split by capability: one agent on the feature, one on the defect, one on tests, one on the migration, one on review and docs. The review lane suits a read-only sub-agent with a restricted tool set.
  • Write the dependency order down: decide who depends on whom and who merges first, before the sessions start, not after all five have run.

6.2 Start the sessions

bash
claude --worktree feature-auth
claude --worktree fix-checkout
claude --worktree add-tests
claude --worktree migrate-schema
claude --worktree review-docs

Run one in each of five terminals: feature, defect, tests, migration, review.

  • Each session works in .claude/worktrees/<name>/ on its own worktree-<name> branch.
  • Every worktree needs its environment prepared again (install dependencies); projects that need .env should set up .worktreeinclude as described in section 2.
  • Give each session a prompt that states three things: which files you own, which files you must not touch, and how you prove the work is done (which test to run, which lint command). These three lines decide the outcome more than the flags do.

6.3 Watch the board

  • claude agents opens the panel: the state of all five sessions and which ones are blocked waiting for you.
  • Use cross-session messaging when one lane needs to tell another something — if the feature lane changes an interface signature, it can tell the migration lane directly instead of letting that lane discover the change after finishing.
  • Give the review lane to a read-only sub-agent: independent context, no file writes, and a prioritized list of problems as the output.

6.4 Verify and merge

  • Run lint and tests inside each worktree before merging. Worktrees isolate the file edits, not the dependencies between lanes, so the merge order is still yours to manage.
  • Merge in dependency order: branches with no upstream dependency first, then the ones that depend on them. Open one pull request per branch and let CI run after each merge rather than batching all five.
  • Clean up deliberately: interactive sessions ask on exit whether to keep or remove the worktree; sessions started with -p are not cleaned up, so remove those with git worktree remove.

6.5 Verification record

No numbers are filled in here that were not measured. What is fixed is the mechanism: the worktree layout and branch naming, the cleanup rules on exit, and the four isolation checks are all documented behaviors you can verify line by line. How much time five parallel lanes actually saves, how often they fail, and by how much token usage grows depends on your repository and your tasks — measure that yourself and fill it in.

7. What parallel work costs and how the bill works

Parallelism trades one problem for another. A single agent has one context window; the main conversation grows until the model starts losing track, so splitting the work means serial handoffs, and several agents editing the same files overwrite each other. claude --worktree fixes the isolation, Agent View and sub-agents fix the dispatch, and none of them fixes quota — the docs are explicit that running several sessions or sub-agents at once multiplies token usage.

That is why Claude Code agent teams in production needs model quota you can draw on whenever it is needed, one routing layer, and one place to reconcile the bill:

  • Quota: with five sessions running, any one of them hitting a limit stalls the whole chain. You want quota you can take as you go, not a single session window holding everything back.
  • Routing: the five lanes may use different model tiers. When they run together you want them on one billing basis rather than five separate subscriptions to track.
  • Reconciliation: parallel usage is bursty, so per-token accounting is what makes "what did today cost, and was it worth it" answerable.

CodeGateway is built for exactly that shape: pay-as-you-go, billed per token, with no session window in the middle, and the account stops when the available balance runs out. The billing rules are published:

  • Consumption multiplier: official list price × 1.07x, a flat multiplier with no tiers. The multiplier covers global acceleration, highly available infrastructure, and API key management. (Live /pricing value, as-of 2026-11-07)
  • Top-up service fee: 2% of the face value you top up; the credited balance is not reduced. (as-of 2026-11-07)
  • Payment processing fee: charged by the third-party payment channel, Stripe, at roughly 3.9% + $0.30 per transaction, itemized on the checkout page. That is Stripe's fee, not CodeGateway's.
  • Payment methods: Supports credit card (Visa / Mastercard / AmEx), Stripe Link, and bank transfer; the checkout is provided by Stripe, and payment fees are itemized separately.
  • What you actually pay = top-up face value + top-up service fee + Stripe processing fee.

Rates can change, so check the pricing page for the current figures.

Pick the amount on the top-up page — custom amounts start at $5, with $10 / $20 / $50 / $100 presets.

To start running parallel work the order is: top up for credit, create an API key, point Claude Code's base_url at it. Claude Code reads two environment variables:

bash
export ANTHROPIC_BASE_URL="https://api.codegateway.dev"
export ANTHROPIC_AUTH_TOKEN="your API key"

Once the top-up lands, create a key in the dashboard and Get a CodeGateway key, put those two lines in your shell configuration, and the sessions in all five worktrees are ready to start.

To be explicit about what this is not: a pay-as-you-go endpoint is still billed per token, and the account stops when the available balance runs out. What changes is the shape of the quota — metered access instead of a seat window — not the billing itself, and not any of Claude Code's official rules. What you control is the number of parallel lanes and the model tier you give each one.

8. FAQ

Will 5 agents overwrite each other's changes?

As long as you partition by file ownership. At the worktree level, Claude Code blocks subprocesses from editing files in the main checkout, blocks commands whose working directory resolves back to the main checkout, and blocks git redirected into the main checkout; a command whose text cannot show that git stays in the worktree is rejected too. Note that those four checks do not trace which files a shell command writes, so the partitioning discipline is still yours to keep.

Is claude --worktree the same thing as agent teams?

No. --worktree is isolation: it gives a session its own checkout. Agent teams is coordination: a shared task list, teammates messaging each other, and a lead assigning the work. The docs also state that agent teams do not isolate teammates into worktrees, so the two are often used together — but partition the work, because teams will not isolate it for you.

Why is agent teams off by default?

It is experimental, and the docs list known issues around session resumption, task coordination, and shutdown behavior. You have to set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 explicitly, and teammates are only spawned in interactive sessions; in -p mode named sub-agents still run as ordinary sub-agents.

How much more does parallelism cost?

The docs give no multiplier, only that running several sessions or sub-agents at once multiplies token usage. The factor depends on how much each session reads, how long its context gets, and how much it writes, and it scales roughly with the number of lanes. Under pay-as-you-go billing that shows up directly on the token bill, so estimate the budget per lane.

When should I use sub-agents, and when background sessions?

Sub-agents fit work where "the result is what you need" — repository-wide search, bulk review, parallel research — because it all happens inside one session and comes back as a summary. Background sessions fit independent long jobs you hand off and revisit later, watched together through Agent View. If you use both in one session, watch the context: a sub-agent's intermediate output does not crowd the main conversation.

How do I prepare dependencies and .env in a worktree?

A worktree is a fresh checkout, so dependencies need installing again in each directory (or you let Claude run the install inside the worktree). Gitignored files such as .env come along via a .worktreeinclude file.

How do I clean up a worktree afterwards?

On exit, Claude checks for uncommitted changes, new commits, and uncommitted work in submodules. A clean unnamed worktree is removed automatically; a named session asks you to keep or remove it. Non-interactive -p runs are not cleaned up — remove them with git worktree remove, and run git worktree unlock first if git refuses because of the lock.

How do I decide the merge order?

By dependency: merge branches with no upstream dependency first, then the ones that depend on them. Run lint and tests inside each worktree before merging, open one pull request per branch, and let CI run after each merge.

10. Sources

On the numbers: Anthropic's rules above follow the official documentation and help center as published on 2026-11-07. CodeGateway's 1.07x multiplier and 2% top-up service fee are the live pricing page values as of 2026-11-07; when they change, the pricing page wins — see the pricing page.
Author:CodeGateway TeamReviewed on:2026-11-09

Solve API Key & Billing limits with CodeGateway

Lacking an official API key or facing overseas card payment issues? Create an sk-cg- key instantly. One key for Claude, GPT, Gemini, and DeepSeek: Claude and Gemini text models use the Anthropic Messages protocol (/v1/messages) — the OpenAI-compatible text endpoints do not accept them. Built-in smart routing and free trial credits included.

Sign up free