Guides

Run coding agents in parallel

How to run several Claude Code or Codex tasks at once without the agents' edits, ports, and databases colliding.

The short answer

To run coding agents in parallel, give each task its own copy of the code. Git worktrees do this on one computer, and Claude Code's --worktree flag and the ChatGPT desktop app create them for you. That's enough if the agents don't need to run your app. If they do, each task also needs its own ports and database, or its own machine. Boxes.dev gives each task a full copy of a cloud machine where your app already runs, so every agent can test its work.

Why run agents in parallel

A coding agent spends long stretches working on its own: reading code, running tests, and waiting on builds. You don't have to wait for one to finish before starting the next. While one agent builds a feature, others can fix a bug, update a dependency, or try a second approach, and you can review each result as it's ready.

Running several agents at once can go wrong in two ways. If you start two sessions in the same directory, both agents will edit the same files on the same branch, and one agent's unfinished change can break the other's build or tests. And even with separate files, two agents that each start your app will fight over the same ports, database, and memory.

Git worktrees fix the first problem by giving each task its own copy of the code. For the second, each task needs its own ports and database, or its own machine.

Git worktrees: separate files for each task

A Git worktree is another working directory for the same repository, with its own files and branch. All worktrees share the repository's history, so you can review and merge each task's branch the usual way.

Claude Code creates a worktree for you when you pass --worktree, or -w. This command creates .claude/worktrees/feature-auth/ on a new branch named worktree-feature-auth and starts Claude in it:

claude --worktree feature-auth

Run it with another name in a second terminal to start a second session. When you exit, Claude removes a worktree that has no changes and asks before removing one with work in it. In the Claude desktop app, choose the worktree option when you start a session. Claude Code's agent view, which you open with claude agents, runs background sessions on your computer and moves each one into its own worktree before it edits files.

In the ChatGPT desktop app, Codex creates worktrees in $CODEX_HOME/worktrees and can run a setup script from a local environment when it creates one. It keeps up to 15 of these worktrees by default and saves a snapshot of an older one before deleting it.

With Git alone, create a worktree next to your checkout and start any agent in it:

git worktree add ../myapp-feature-a -b feature-a
cd ../myapp-feature-a
claude

A worktree is a fresh checkout, so it starts without your installed dependencies or gitignored files such as .env. Install dependencies in each worktree, or ask the agent to. Claude Code copies the gitignored files you list in a .worktreeinclude file at the project root into each worktree it creates, and a Codex setup script can do the same.

Worktrees are enough when the tasks edit different parts of the code and don't all need to run the app at the same time.

What worktrees don't separate

Worktrees separate files, but the agents still share one computer and everything else on it:

  • Ports. Two dev servers can't both listen on port 3000, so the second one fails to start or picks another port that the agent then has to find.
  • Databases. Agents that use one local database see each other's test data, and a migration on one branch can break the app on another.
  • Docker. Compose names each project after its directory by default, so containers in different worktrees get different names. Services that publish the same port on your computer still collide.
  • CPU and memory. Builds and test suites that run at the same time slow each other down.
  • Files and credentials outside the repository. Every agent can reach the same home directory, SSH keys, and cloud credentials.
  • Usage limits. Anthropic notes that ten Claude Code sessions in parallel use your plan's quota roughly ten times as fast as one.

People work around the first three by giving each worktree its own ports, database, and Compose project name. For example, a second worktree's .env.local might set:

PORT=3001
DATABASE_URL=postgres://localhost:5432/myapp_feature_a
COMPOSE_PROJECT_NAME=myapp-feature-a

This works when your app and Compose file read their ports and database from environment variables. Each new database also needs its schema and seed data, and every Compose service that publishes a port needs its own variable. The workarounds get harder as the app grows, with OAuth callbacks registered for one port, services that expect fixed ports, and seed data that takes minutes to load.

Tools that manage worktrees

Several desktop apps create worktrees for you and show each task's agent, terminal, and diff side by side. As of September 2026:

  • Conductor gives each workspace on your Mac a worktree and its own ports through CONDUCTOR_PORT. Its docs suggest running one workspace's app at a time when a project depends on one fixed port, one local database, or one Docker stack. Paid plans add a cloud microVM for each workspace. See Boxes.dev vs Conductor.
  • Superset makes each workspace a worktree with its own branch, directory, and terminals, on your Mac or a remote host. Project scripts can install dependencies and copy env files into each new worktree. See Boxes.dev vs Superset.
  • Orca runs worktrees on your computer or an SSH host, with commands that run when a worktree is created and a browser for each worktree that agents can drive. See Boxes.dev vs Orca.
  • T3 Code can start a thread in a new worktree with its own branch and working directory. See Boxes.dev vs T3 Code.

These apps make worktrees easier to manage. Worktrees on one host still share its CPU, memory, services, databases, and ports.

A cloud machine for each task

When each task has its own machine, the agents' files, ports, databases, and memory are all separate, and the work keeps going after you close your laptop.

  • The agent vendors' clouds. Each Claude Code cloud session and each Codex cloud task runs in its own isolated environment, starting from a copy of your repository. Parallel Claude Code sessions share your Claude plan's usage limits.
  • Managed platforms such as Replicas, Tembo, and Niteshift build a VM for each task from setup scripts. See the Claude Code guide for how they differ.
  • Servers you manage. You can run a separate server for each task and pay for each one. As of September 2026, a DigitalOcean Basic Droplet with 4 vCPUs and 8 GB of memory costs $48 a month, and an AWS EC2 c7i.xlarge instance of the same size costs about $130 a month on demand in US East, before storage.

Boxes.dev

Boxes.dev gives each task its own devbox: a full, isolated copy of a cloud machine where your app already runs.

You'll start by setting up your app on a cloud machine called the Template box, with its tools, databases, services, and data. Boxes.dev saves the Template box as a snapshot, and each new devbox starts as a copy of it. Every devbox runs its own databases and services, so each agent can start your app on its usual ports, run migrations, and load test data without affecting the others.

You'd expect an engineer to run the app locally before shipping a change; a full dev environment lets agents do the same. On a devbox, an agent can test its changes in a browser and reproduce bugs against real services and data.

To start a task, choose New devbox + thread in the desktop app, pick Claude or Codex, and describe the task. After you've set up a project, you can also start a task on a new devbox from your terminal:

dvb codex

You can also start work from Slack, Linear issues, or scheduled automations.

The desktop app's Ports tool forwards the selected devbox's ports to the same ports on your laptop, so http://localhost:3000 reaches the app on whichever devbox you're looking at. To keep several devboxes' apps open side by side, turn on Local URLs. Each devbox will then get its own address in the form http://<name>.localhost:3000. A public link shares one devbox's app with anyone. A Project URL is a stable public address that you point at the devbox you're testing, so OAuth callbacks and webhooks can reach it.

When two agents should work on the same files, start a second thread on the same devbox. With your permission, an agent can also hand part of its task to Claude or Codex on a new devbox and message it. Agents can leave notes for each other in a shared project folder, too.

A devbox goes to sleep after about five minutes when no agent is working and nobody is using it. Sleep keeps its files and memory, so its dev servers and databases pick up where they left off when it wakes. You'll get a notification when an agent replies or needs your input.

As of September 2026, the free trial includes 10 box-hours with up to two devboxes awake at once. Starter costs $19 per user each month, with 40 box-hours and up to four devboxes awake. Pro costs $99, with 250 box-hours and up to ten awake. Extra time costs $0.75 per box-hour on Starter and $0.60 on Pro. A box-hour is one default devbox, with 4 vCPUs and 8 GiB of memory, awake for an hour. Sleeping devboxes don't use box-hours. See Plans, seats, and box-hours.

To try it, set up a project, then see Create and manage devboxes and Preview your app.

How to choose

  • The tasks edit different code and rarely need to run the app at once: worktrees, with claude --worktree, the ChatGPT desktop app, or an app that manages them.
  • A few tasks need the running app, and your app reads its ports and database from environment variables: worktrees, each with its own ports, database, and Compose project name.
  • The tasks need only the repository and should keep going while your laptop is closed: the agent vendors' cloud sessions.
  • You want each task to run and test your full app with its own services and data, or you want to run more tasks than your laptop can handle: Boxes.dev.

Frequently asked questions

How many Claude Code sessions can I run at once?

On one computer, you're limited by its CPU and memory and by your Claude plan's usage limits, which parallel sessions reach sooner. On boxes.dev, your plan also sets how many devboxes can be awake at once: four on Starter and ten on Pro.

Do worktrees share installed dependencies?

No. Each worktree is a fresh checkout, so install dependencies in each one, or let a setup script do it. A Codex local environment can run a setup script for each new worktree, and Claude Code's .worktreeinclude copies gitignored files such as .env into each worktree it creates.

Can two agents work on the same devbox?

Yes. Start a second thread from the devbox's menu, and both agents will share its files and running services. Give them work that won't edit the same files at the same time.

Sources

Product names are trademarks of their respective owners.

Close your laptop again.

Develop in the cloud: one computer per agent, running your full app, steerable from every device you own.

Also oniOS·Android·CLI