← Blog
Coding agentsClaude CodeSandboxes

How to run coding agents in parallel, each in its own cloud sandbox

Yura Dubinin
Yura Dubinin

Claude Code parallel agents work when every session gets its own copy of the repository and, for anything that runs tests or servers, its own machine. Git worktrees give each agent separate files on your laptop. A cloud sandbox per agent also gives it separate ports, processes, disk and CPU, and the sessions keep running after you close the lid. The same holds for Codex and OpenCode.

For the cloud route we use Lizard (lizard.build): each agent runs in a Firecracker microVM with its own kernel, and one command starts it. lizard sandbox create -t claude -s small --timeout 30m creates a sandbox with Claude Code installed, and lizard sandbox fork <id> -n 4 makes four more with the same files. We ran the whole flow on 29 November 2026 with five sandboxes; the commands, timings and costs are below.

How do you run several coding agents at once without conflicts?

Give each agent a separate working copy and a separate branch, and merge only after a check passes. Two agents in one checkout overwrite each other's files, fight over node_modules and port 3000, and leave a diff nobody can attribute.

There are three ways to get that separation. A git worktree per agent separates the files. A VM per agent separates the whole machine, and you manage the image, SSH keys and cleanup. A microVM sandbox per agent is also a whole machine, created by one API call and deleted when the task ends.

Claude Code also has subagents, which work inside one session, and agent teams, where a lead session hands tasks to teammates. Anthropic's docs call agent teams experimental and disabled by default, and warn that "two teammates editing the same file leads to overwrites" (agent teams docs, checked 29 November 2026). Teams coordinate work inside one checkout and leave the isolation to you. Our agent teams guide covers setup and token cost.

Worktrees, VMs or sandboxes: which isolation do parallel agents need?

Worktrees are enough for two or three agents that only edit files. Once agents run test suites, dev servers or databases, or run with permission prompts off, each one needs its own machine.

Git worktrees on one machineOne VM per agentOne microVM sandbox per agent
SeparateFiles and branchEverythingEverything, including the kernel
SharedCPU, RAM, ports, local databases, Docker, your home directory and credentialsNothingNothing
Setup per agentclaude --worktree <name>, then install dependencies in the new checkoutBoot, image, SSH, your own scriptsOne command; forks copy a prepared sandbox
Agents at onceWhat your laptop's RAM and CPU carryYour cloud quotaYour plan's vCPU limit
Laptop closedAgents stopAgents keep runningAgents keep running
CostNothing extraPer VM while it runs, busy or idle, plus its disk until you delete itPer second while the sandbox runs, idle time included
FitsA few edit-only tasksLong-lived, hand-tuned environmentsMany short tasks, best-of-N runs, unattended agents

Claude Code builds worktrees for you: claude --worktree feature-auth creates a checkout under .claude/worktrees/feature-auth/ on a new branch worktree-feature-auth (worktrees docs, checked 29 November 2026). The same page notes that a worktree is a fresh checkout, so you install dependencies again, and gitignored files such as .env are not copied unless you list them in .worktreeinclude.

A worktree does not separate anything outside the repository folder. Five agents on one laptop still share one port 5432, one Docker daemon and one set of SSH keys. If you run them with --dangerously-skip-permissions so they stop asking, each of the five can reach everything your user account can.

A sandbox per agent removes the shared parts. Lizard is one of several services that sell this; E2B, Daytona, Modal, Northflank and Blaxel are others. The steps below use Lizard because we build it and could test every command.

How do you start N Claude Code, Codex or OpenCode sessions in cloud sandboxes?

Create one sandbox, put the repository in it, fork it for the other agents, and send every copy the same prompt. On Lizard that takes four commands plus a loop.

Before you start: install Lizard CLI (npm i -g @lizard-build/cli), run lizard login, and connect your agent's login to the project the sandboxes will run in. For Claude Code that is claude setup-token on your machine, then lizard agents add claude. Agent logins on Lizard belong to a project, not to your account.

# 1. One Small sandbox from the claude template (2 vCPU, 4 GB RAM, 20 GB disk)
SB=$(lizard sandbox create -t claude -s small --timeout 30m --json | jq -r .id)

# 2. Your repository goes in as a git bundle: committed files only, no .env
git bundle create /tmp/shop.bundle HEAD
lizard sandbox files put $SB /tmp/shop.bundle /workspace/shop.bundle
lizard sandbox exec $SB -- git clone -q /workspace/shop.bundle /workspace/shop

# 3. Four more sandboxes with the same files
lizard sandbox fork $SB -n 4 --json | jq -r '.[].sandbox.id' > forks.txt

# 4. The same task in all five
for id in $SB $(cat forks.txt); do
  lizard sandbox prompt $id --agent claude --cwd /workspace/shop --no-wait \
    "npm test fails. Fix cart.js so every test passes. Do not edit cart.test.js. Run npm test, then commit."
done

What we measured on 29 November 2026, with Lizard CLI 4.0.136 run from a machine in the same region (us-east-1):

  • lizard sandbox create returned a running Small sandbox in 1.5 seconds.
  • lizard sandbox fork -n 4 returned four running copies in 1.7 seconds.
  • Claude Code 2.1.286, the version in the claude template that day, finished the task in 9 to 12 seconds in each of the five sandboxes.

Our test repository was tiny on purpose: three files, one rounding bug in a cart total, two failing tests out of three. We started the agents through the API call that lizard sandbox prompt --no-wait makes and checked the command's flags with --help.

Pass -s small explicitly. Outside the trial, a create with no size is Medium (4 vCPU, $0.0324 an hour), twice the Small price. And set --timeout: without it the CLI gives a sandbox 5 minutes, and a sandbox is deleted at its deadline even if the agent is mid-task.

A fork copies files only. Each fork boots fresh from a copy of the source's disk; memory and running processes are not copied, and the source keeps running. So fork before you start the agent, when the sandbox holds the repository and installed dependencies and nothing is running yet.

For Codex, create the sandbox with -t codex (it had Codex CLI 0.159.2 on the day we checked) and pass --agent codex, with a ChatGPT sign-in (lizard agents login) or an OpenAI API key (lizard agents add openai) connected to the project. OpenCode had no template of its own in us-east-1 that day: -t opencode was refused as an unknown template. npm i -g opencode-ai in the first sandbox, before you fork, installed OpenCode 1.19.6 in our test; lzs (below) does the same in its base snapshot. We ran agents with Claude Code only. The Claude Code sandbox guide has the single-session version of these steps.

How do you compare the results and keep the best one (best of N)?

Run the same check in every sandbox, read the diffs of the ones that pass, and fetch the winner as a git branch. Best of N means N agents attempt one task and your tests pick the result.

# The check, everywhere
for id in $SB $(cat forks.txt); do
  echo "== $id"
  lizard sandbox exec $id -- sh -c 'cd /workspace/shop && npm test 2>&1 | grep -E "^# (pass|fail)"; git diff --shortstat HEAD~1'
done

# Bring the winner home as a branch (W = the sandbox you picked)
lizard sandbox exec $W -- git -C /workspace/shop bundle create /tmp/win.bundle HEAD
lizard sandbox files get $W /tmp/win.bundle /tmp/win.bundle
git fetch /tmp/win.bundle HEAD:agent/$W

# Delete all five
for id in $SB $(cat forks.txt); do lizard sandbox rm $id --yes; done

Output from our run, trimmed:

== account-label-tm4v
# pass 3
# fail 0
 1 file changed, 8 insertions(+), 6 deletions(-)
== coffee-volume-knw4
# pass 3
# fail 0
 1 file changed, 11 insertions(+), 5 deletions(-)

All five sandboxes passed 3 of 3 tests, with diffs between 8 and 11 inserted lines. All five agents also chose the same fix, integer cents instead of floating-point dollars. For a bug this small, one agent would have done. Best of N earns its cost on tasks where attempts fail or diverge: a flaky test, a refactor with several valid shapes, a performance fix you can measure.

Lizard's open-source tool lzs wraps these steps. From its README (version 0.5.1, 29 November 2026):

npm i -g @lizard-build/cli @lizard-build/lzs
lizard login && lzs init --new-project
lzs fan 5 . -p "fix the flaky checkout test" --check "npm test"
lzs watch          # who is working, who is done, whose check passes
lzs diff           # all five side by side, passing ones first
lzs pick lzs-3     # keep it as branch lzs/lzs-3, delete the other four
lzs push lzs-3     # open a pull request

lzs init saves a base snapshot with tmux, Claude Code, Codex, OpenCode and your agent login; lzs fan boots N sessions from it (50 at most, and it asks above 20) and runs --check in each when its agent finishes. lzs sessions are Nano by default and start the agent with permission prompts off. Anyone who can open the project can restore that snapshot, login included, so the README asks you to give lzs a project of its own (--new-project). We did not run lzs's agent commands for this article: lzs init needs a sign-in that can read the project's agent logins, and our test key could not. The run above used the Lizard CLI commands that lzs drives.

What do 5 or 20 parallel sessions cost per hour?

Five Small sandboxes cost $0.081 an hour on Lizard and twenty cost $0.324, billed per second. The model usually costs more than the machines.

SizevCPU / RAM / disk1 session per hour5 sessions per hour20 sessions per hour
Nano0.5 / 1 GB / 5 GB$0.00405$0.02025$0.081
Mini1 / 2 GB / 10 GB$0.0081$0.0405$0.162
Small2 / 4 GB / 20 GB$0.0162$0.081$0.324

These are compute prices in US dollars from the Lizard pricing page, checked 29 November 2026. They cover CPU, memory and the root disk while a sandbox runs, idle time included. They leave out the plan itself (Lizard Pro is $19 a month and includes $19 of usage; more is pay as you go at the same rates), Persistent Volumes, and storage for paused sandboxes and snapshots at $0.14 per GB-month.

They also leave out model usage. In our run the five sandboxes lived about two minutes and cost under one cent of compute in total. Claude Code reported $0.16 of model usage across the five sessions. With a Claude subscription token you pay that from your plan's usage limits; with an API key you pay Anthropic per token. Running N agents multiplies the model bill by N; the sandbox bill stays small next to it.

Nano is enough for an agent that edits code and runs a light test suite. Pick Small when the agent builds a project or starts a database next to the code.

What limits apply on the trial and on Pro?

Lizard Pro runs 40 vCPU of sandboxes at once, which is 20 Small, 40 Mini or up to 100 Nano sandboxes, or a mix. Pro has no limit on how many sandboxes you start. Pro 5x ($99 a month) runs 220 vCPU or 500 Nano, and Pro 20x ($499) runs 1,200 vCPU or 2,000 Nano.

The 7-day trial is much tighter:

  • 1 Small, 2 Mini and 2 Nano sandboxes at a time, in US regions only.
  • Every trial sandbox is deleted 1 hour after it starts at the latest. A longer --timeout is refused.
  • 50 Small, 100 Mini and 100 Nano starts in total. Creates and forks count; resumes do not.
  • A fork counts as one more sandbox of its source's size. Forking a running Small is refused on the trial, because the trial runs one Small at a time.

So the fork command in this article needs a paid plan. On the trial you can still try the pattern with two Mini or two Nano sandboxes created one by one. The trial limits end with the first paid Pro invoice: "Start Pro now" in Billing, or lizard billing start-now. The full list is on the limits page.

Your model provider has limits too. All sessions on one Claude subscription draw from the same usage allowance, so twenty agents use it up about twenty times as fast as one.

How do you keep sessions running when your laptop sleeps?

Start the agent with --no-wait and give the sandbox a deadline long enough for the task. The agent runs inside the sandbox, so your terminal only watches. Closing it, or the laptop, stops the watching and nothing else.

SB=$(lizard sandbox create -t claude -s small --timeout 4h --json | jq -r .id)
lizard sandbox prompt $SB --agent claude --cwd /workspace/app --no-wait "migrate the test suite to vitest"

The deadline matters most. The default is 5 minutes. --timeout 4h sets four hours, and lizard sandbox timeout $SB 3600000 changes it on a running sandbox. On a paid plan --timeout 0 removes the deadline and the VM stops after at most 596 hours. On the trial the ceiling is 1 hour, so overnight runs need a paid plan.

A running sandbox bills per second whether the agent works or waits. Pause it with lizard sandbox pause $SB to end the compute charge; its used disk then bills at $0.14 per GB-month until you resume or delete it.

A pause keeps files only. Running processes end and the sandbox boots fresh on resume. In our test, a paused Small sandbox resumed in 1.6 seconds with the agent's commit and its Claude Code transcript folder still on disk. A second prompt sent with the same conversation id (lizard sandbox prompt $SB -c <conversation id> ...) picked up the conversation where it stopped: the agent recalled what it had written before the pause.

lzs automates this part too, according to its README: a session pauses itself after 30 idle minutes and after 24 hours of running (change it with --max-hours), and lzs init --notify <url> pings ntfy, Slack, Discord or Telegram when an agent finishes or asks a question. Our background coding agents article compares the hosted products that work this way.

FAQ

How many Claude Code sessions can I run in parallel? Locally, as many as your laptop's RAM and CPU carry; each session plus its test runs and dev server adds up quickly. In cloud sandboxes the plan sets the number: Lizard Pro runs 40 vCPU at once, which is 20 Small, 40 Mini or up to 100 Nano sandboxes. Your Claude plan's usage limits are shared by all of them.

Do I still need git worktrees inside a sandbox? No. Each sandbox holds its own clone of the repository, so every agent already has a separate checkout and branch. Worktrees solve the shared-folder problem on one machine, and a sandbox per agent does not have that problem.

Does a fork copy the running agent? No. A Lizard fork boots fresh from a copy of the source sandbox's files. Memory and running processes are not copied. Fork first, then start an agent in each copy.

Can I run parallel agents on the Lizard trial? A little. The trial runs 1 Small, 2 Mini and 2 Nano sandboxes at a time in US regions, deletes each one within 1 hour, and refuses a fork of a running Small. Runs with five or twenty agents need paid Pro, $19 a month with $19 of usage included.

Is best of N worth it for small fixes? Usually not. In our test on 29 November 2026, five Claude Code sessions produced the same fix for a simple rounding bug, at five times the model usage. Use best of N when a single attempt often fails your check or when you want to choose between different designs.

What does an idle parallel session cost? The same as a busy one while it runs: $0.0162 an hour for a Small sandbox on Lizard, billed per second. A paused sandbox has no compute charge, and its used disk bills at $0.14 per GB-month until you resume or delete it.

Build with AI. Ship with Lizard

You don't need a platform team to go live. Your whole cloud, one CLI command away.

Start 7-day trial
Services
—
Add-ons
—
Deployments
—
Sandbox starts
—

We use cookies for essential site functionality and analytics. See our Cookie Policy.