Claude Code swarms: agent teams, isolation and what N agents cost

Last updated

A coding agent swarm is several coding agents working on one codebase at once, each in its own session. "Claude Code swarm" means either Anthropic's agent teams, which blogs and forums call "swarm mode", or a setup you build where many sessions attempt the same task and you keep the best result. This page covers both, what breaks when agents share a machine, and what 5, 10 and 20 agents cost.

What is a Claude Code swarm?

There is no single definition, so here are the three in use.

  • Anthropic's agent teams. One Claude Code session is the lead. It spawns teammates, each "a full, independent Claude Code session" with its own context window. They share a task list and message each other through a mailbox. Anthropic introduced them with Claude Opus 4.6 on 5 February 2026, "as a research preview".
  • Thoughtworks' definition. Its Technology Radar (Vol. 34, April 2026) separates a small team of agents from a swarm, which "applies dozens to hundreds of agents to a problem", with AI choosing their number and roles. It rates the technique "Caution": costly and immature.
  • The practical one. N copies of one environment, one agent per copy, and a test suite that decides which result survives. Most of this page is about this one.

Is swarm mode an official Claude Code feature?

The feature is official; the name isn't. Anthropic's docs say "agent teams", never "swarm mode". The name comes from early 2026, when people found the feature behind a flag in Claude Code's code and unlocked it with third-party patches such as claude-sneakpeek.

What the docs say on 31 October 2026:

  • "Agent teams are experimental and disabled by default." Turn them on with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in your environment or in settings.json.
  • Teammates need an interactive session. In claude -p mode, including Agent SDK sessions, "Claude doesn't spawn teammates".
  • "Start with 3-5 teammates for most workflows." There's no hard limit, but "token costs scale linearly".
  • Teammates share your working tree. "Two teammates editing the same file leads to overwrites", so you split files between them.
  • "If the lead runs with --dangerously-skip-permissions, all teammates do too."

So agent teams solve coordination, not isolation: all teammates run on the lead's machine, against the same files, ports and database.

How does a coding agent swarm work?

The cycle that makes a swarm worth its cost has five steps.

  1. Prepare one environment. Clone, install dependencies, start the database and services, seed data, check that the tests pass. It's slow; do it once.
  2. Make N copies of it. Each copy has its own files, its own processes, its own port 3000 and its own database.
  3. Run one agent per copy. Same task with different prompts or models (best-of-N), or different tasks from one backlog.
  4. Rank the results by the tests. The test suite, a linter, a benchmark: anything a machine can run decides which branches are worth your review.
  5. Keep the best, discard the rest. Merge one branch, delete the other copies.

Step 2 is where the tools differ. With git worktrees, a copy is a new checkout: the files are copied, but the database and the running services are not. With a VM per agent, you either rebuild the environment N times or fork a prepared VM. A fork copies the memory too, so the database and the dev server are already running in every copy. E2B and Daytona document this today: an E2B fork "starts with the exact state the original had at the moment of the fork", up to 20 forks per call; Daytona "duplicates a VM sandbox's filesystem and memory into a new, fully independent sandbox". Fly's Sprites do something close with checkpoints: "have each one checkpoint, then attempt a different approach to the same problem".

For the best-of-N variant in detail, see best-of-N with coding agents.

Why does each agent in a swarm need its own environment?

Because everything an agent touches outside the git tree is shared on one machine. What collides, and what fixes it:

What collides Same machine, worktrees One VM per agent
Source files Separate per worktree Separate
Dev server port Shared: two agents on port 3000, the second fails Each VM has its own port 3000
Database Shared, unless you script one per worktree Each VM has its own
Docker daemon, caches, node_modules Shared daemon; one node_modules per worktree Separate
Secrets in the environment Every agent sees all of yours Only what you copy into the VM
--dangerously-skip-permissions A bad command can reach your home directory A bad command stays in the VM
RAM and CPU One laptop for all agents One VM each

The worktree fixes (a port and a database per worktree) are in running Claude Code agents in parallel, with tmux to watch them. They hold for a handful of agents.

Nobody approves 10 agents' prompts by hand, so swarms run with prompts off. A VM limits the damage to what's inside it. It doesn't stop an agent from leaking a token you copied into it; read running --dangerously-skip-permissions safely before you hand an agent a credential.

How do you pick the winner of a swarm?

With the tests. A swarm produces more diffs than you can read, so a machine has to do the first pass.

Anthropic's C compiler experiment shows both sides. Nicholas Carlini ran 16 Claude agents, each in its own Docker container with its own clone of the repository, over "nearly 2,000 Claude Code sessions across two weeks". Agents claimed tasks by writing lock files, and git rejected the second agent to claim the same one. Of the setup, he wrote: "Most of my effort went into designing the environment around Claude—the tests, the environment, the feedback". And: "it's important that the task verifier is nearly perfect, otherwise Claude will solve the wrong problem."

In practice:

  • Run the full suite in each copy, not only the tests the agent wrote. An agent can make its own tests pass.
  • Rank by what you can count: tests passed, then the size of the diff, then lint warnings. A smaller diff that passes is easier to review.
  • Read the top two or three, not all N. Carlini's warning applies: "it is easy to see tests pass and assume the job is done, when this is rarely the case."

Without a test suite you trust, a swarm gives you N untested branches.

How much does a coding agent swarm cost?

Two bills: the compute the agents run on, and the model tokens. Tokens are almost always the larger one.

Compute, on E2B's public grid (checked on 31 October 2026): $0.000014 per vCPU-second and $0.0000045 per GiB-second. A 2 vCPU / 4 GiB sandbox costs 2 × 0.000014 + 4 × 0.0000045 = $0.000046 per second, so $0.1656 per hour.

Agents 30-minute run 1-hour run 2 hours per workday, 22 days
5 $0.41 $0.83 $36.43
10 $0.83 $1.66 $72.86
20 $1.66 $3.31 $145.73

Formula: agents × hours × $0.1656. Plan fees aren't included. E2B's free Hobby plan allows 20 concurrent sandboxes. The fork count "must also be lower than your team's concurrent sandbox limit", because the original takes a slot, so 20 forks of one sandbox need the Pro plan ($150 a month plus usage, 100 concurrent).

Tokens. Anthropic's agent teams docs say they "use significantly more tokens than a single session"; its costs page puts it at "approximately 7x more tokens than standard sessions" when teammates run in plan mode. The C compiler run cost "just under $20,000" in API tokens for about 2,000 sessions: about $10 per session (calculation). For scale: if its 16 agents had each run nonstop for 14 days in a 2 vCPU / 4 GiB E2B sandbox, compute would have been 16 × 336 h × $0.1656 = $890, under 5% of the token bill (calculation; the post doesn't give container sizes or uptime).

On a Pro or Max plan, tokens come out of your usage limits instead of a bill, and N agents drain the window N times faster. That ceiling usually comes before the compute one.

Which setup fits which swarm?

Swarm Setup What it gives you What it doesn't
2-5 agents, split tasks Agent teams Lead, task list, messaging An environment per agent; teammates in claude -p
2-5 agents, same task Worktrees + tmux Free, local Separate ports and databases, unless you script them
5-20 agents on a laptop Docker Sandboxes, --clone A microVM per agent; API keys injected by a host-side proxy More RAM than your laptop has; alternatives here
10-20 agents from one prepared state Hosted sandboxes with fork (E2B, Daytona) Copies with memory, processes still running Your own host; compared here
Many agents, with a lead An orchestrator on top of any of these A board, diffs side by side Isolation, which comes from the layer below; compared here

What does flockvm do for swarms today?

flockvm runs each coding agent in its own Firecracker microVM. Sign-ups are open (Google, GitHub or an email link), with a 7-day free trial: card required, nothing charged for 7 days, cancel anytime. Today:

  • one microVM per agent, booted to SSH in about a second;
  • pause and resume with memory: a paused VM resumes with its processes still running (see Firecracker snapshot and restore);
  • SSH, logs, billing per second;
  • one host in France (OVHcloud), with up to 15 small VMs (2 vCPU, 4 GiB) at once, across all customers, 2 during the trial; other regions are planned.

What it doesn't do yet: there's no fork, so each VM is prepared on its own, and no ranking of results. The secrets you set, such as an API key, are written into each VM, where you can revoke them, not held outside it by a proxy. A fork of one prepared VM into N copies, swarms of 10 to 20 agents started from it, and the ranking of their results by the tests are what flockvm is building next. Not shipped.

So today flockvm suits up to 15 agents in parallel when the shared host has room for them, each in its own small VM in France, prepared one by one with a setup you script; the swarm of N copies of one environment is the part still being built. Installing Claude Code in a VM is covered in the Claude Code integration guide; what stays in the EU and what doesn't is in EU data residency. If you need 20 forks this week, E2B or Daytona do it now.

When is a swarm the wrong tool?

  • No tests you trust. Ranking falls back on you reading N diffs.
  • Tasks that touch the same files. Agent teams' docs say so; merge conflicts cost more than the parallel time saved.
  • Sequential work. Anthropic: "For sequential tasks, same-file edits, or work with many dependencies, a single session or subagents are more effective."
  • Your plan's limits. Ten agents on one subscription use its limits ten times as fast; they run out before the compute does.

If your work passes these tests and outgrows your laptop, start a 7-day free trial.

Run your agents in their own microVMs

flockvm gives each coding agent a Firecracker microVM that pauses with its memory and resumes, billed per second. France is live, and you can start with a 7-day free trial.

Start your 7-day free trial

Card required. Nothing charged for 7 days.