How to run multiple coding agents in parallel
Running three Claude Code sessions at once is easy. Running them without clobbering each other’s files, ports, and dependencies, and without merging something nobody checked, takes a little more. Here is the manual way, the friction in it, and what Orgabot automates.
Last updated
Why can’t two coding agents share one checkout?
A checkout is one set of files on one branch. Start two Claude Code sessions in the same directory and ask one to add OAuth while the other fixes a flaky test, and both are editing the same working tree. One agent’s half-finished change breaks the other’s test run. One runs git checkout and the other’s edits land on the wrong branch. When you commit, you get both changes tangled together in one diff that neither agent fully understands.
The fix is a git worktree: a second (or fifth) working directory attached to the same repository. Each worktree has its own files and its own branch but shares the repository’s history and remotes, so a commit made in one is immediately visible to the others as a branch. One agent per worktree gives every agent a private copy of the code without cloning the repository again.
Worktrees solve file collisions. They do not solve everything else that goes wrong when several agents run at once, and that is where most of the time goes.
What goes wrong when agents run in parallel?
Three failure modes show up almost every time someone scales from one agent to several. None of them is a git problem, which is why worktrees alone do not fix them.
1. Port collisions
Your dev server listens on port 3000. So does the dev server in every worktree, because they all read the same config. The first agent to start its server wins; the second gets EADDRINUSE, or worse, a framework that silently picks the next free port, so the agent tests against a server running a different worktree’s code and reports a pass. Integration tests that bind a fixed port, a local database on its default port, and a Storybook instance all collide the same way.
2. Shared or missing node_modules
A new worktree contains only tracked files. There is no node_modules, no build output, and no .env. The agent either runs a full install in every worktree (slow, and on a Mac with many worktrees, a lot of disk) or you take the shortcut and symlink your main checkout’s node_modules into each one. The shortcut works until one agent adds a dependency and runs a clean reinstall: npm ci deletes node_modules before installing, and through a symlink it deletes the tree every other worktree is using. Orgabot’s own codebase records exactly that incident: one worker’s reinstall wiped the shared dependency tree and broke every parallel mission at once.
3. Unreviewed merges
With one agent, you read every diff. With five, you skim, and then you trust the summary. The summary says the tests pass. Sometimes the agent ran a subset, sometimes it ran them before its last edit, and sometimes it did not run them at all and is describing what it expects. Five branches arriving in an afternoon is where an unverified change gets merged, because the review step did not scale with the number of agents.
How do I run coding agents in parallel with git worktrees manually?
The manual method is entirely standard git, and worth knowing even if you automate it later. From your main checkout, create one worktree per task, each on its own new branch. Putting them in a sibling directory keeps them out of your repository’s file tree:
# one worktree per task, each on a new branch
git worktree add ../myapp-oauth -b feature/oauth
git worktree add ../myapp-flaky-test -b fix/flaky-test
# see every worktree and the branch it has checked out
git worktree listThen set up each one and start an agent in it. This is where the three failure modes are handled, by hand:
cd ../myapp-oauth
cp ../myapp/.env .env # gitignored files do not come along
npm install # its own node_modules, not a symlink
PORT=3001 npm run dev & # a port no other worktree uses
claude # start the agent hereRepeat in the second worktree with PORT=3002, and so on. On macOS you can make the install step much faster by cloning your main checkout’s dependencies instead of downloading them again: cp -Rc ../myapp/node_modules . uses APFS copy-on-write, so the copy is near-instant and takes no extra disk until a file changes. Unlike a symlink, a reinstall in the clone cannot touch the original.
Claude Code can create the worktree for you. claude --worktree oauth (or -w) creates a worktree under .claude/worktrees/oauth/ on a new branch named worktree-oauth and starts the session in it, and a .worktreeinclude file at the repository root lists gitignored files such as .env to copy into each new worktree. It still leaves installing dependencies and choosing ports to you. The Claude Code worktrees documentation covers the details.
When an agent finishes, review its branch, run the tests yourself, merge or open a pull request, and clean up:
git worktree remove ../myapp-oauth # refuses if there are uncommitted changes
git branch -d feature/oauth # after it is merged
git worktree prune # forget worktrees you deleted with rmTwo git rules trip people up. A branch can be checked out in only one worktree at a time, so you cannot point two agents at the same branch. And deleting a worktree folder with rm -rf leaves git’s record of it behind until you run git worktree prune.
The honest friction
None of this is hard. It is just a checklist you run by hand for every task, in every terminal tab, and it degrades exactly when you are busiest. The port assignments live in your head. The worktree you forgot to remove holds a branch you now cannot check out. And the step that matters most, checking that each branch actually works before it merges, is the one most likely to be skipped when four agents finish at once.
How does Orgabot run coding agents in parallel?
Orgabot is a local control plane that runs each task as a mission: you give it a project and an instruction, and it creates an isolated git worktree, runs a coding agent in it (Claude Code is the default worker), commits the result, checks it, and delivers it as a draft pull request. You can run several missions at once, and each one follows the same path. The overview explains the whole loop.
Registering a project once records the command that proves it works. After that, launching parallel work is one line per task, run from Orgabot’s framework/ directory:
npm run orgabot -- project add ~/code/myapp --verify "npm test"
npm run orgabot -- mission myapp "Add GitHub OAuth login" --background
npm run orgabot -- mission myapp "Fix the flaky checkout test" --background
npm run orgabot -- status # every mission and where it is
npm run orgabot -- logs <mission-id> # one mission's outputOr type the instruction into the dashboard’s mission terminal, which streams the agent’s output, lets you steer it mid-run, and treats Escape as an interrupt request that is only reported once the runtime acknowledges it. The first mission guide walks the whole path.
Here is how Orgabot handles each failure mode from above:
- Files: every mission gets its own real git worktree, created and cleaned up per task, so two missions on the same repository never edit the same files. When two missions on one project name overlapping file paths, the second waits for the first to merge instead of producing a conflicting pull request; disjoint paths still run concurrently.
- Dependencies: Orgabot gives each mission worktree its own node_modules by copy-on-write cloning your installed tree (APFS clonefile on macOS), so a reinstall in one worktree touches only its own copy. It is best-effort: if the clone fails, dependencies are simply absent and the verify step will say so.
- Load: a host-wide admission budget caps how much runs at once, checked before work starts. By default that is one coding-worker session per eight CPU cores (minimum one), one full verification run, and two light ones. Anything over budget is queued, never started and then paused.
- Checking and merging: covered in the next section, because it is the part worth the most.
Orgabot does not assign ports to dev servers you start yourself; if your agents run servers, give each worktree its own port as in the manual method. What the admission budget does mean is that two full test suites never run at the same time on your machine by default, which removes the most common test-time port collision. The dashboard documentation describes the budget and how to tune it.
If an agent dies or times out, Orgabot commits its work in progress to a salvage branch (excluding untracked node_modules, dist/ and similar build directories) so nothing is lost, and a mission that stops to wait for you keeps its worktree, branch, and session intact. The core concepts page defines each of these terms.
Manual worktrees, Claude Code worktrees, or Orgabot?
| Concern | Manual git worktree | claude --worktree | Orgabot |
|---|---|---|---|
| File isolation | A worktree per task, created and named by you. | A worktree per session under .claude/worktrees/, on a worktree-<name> branch. | A worktree per mission, created and cleaned up by Orgabot. |
| Dependencies | Install in every worktree yourself. | Fresh checkout: you or Claude install. A .worktreeinclude file copies gitignored files like .env. | Best-effort copy-on-write clone of your installed node_modules into each worktree, so no worktree shares another’s tree. |
| Dev-server ports | Yours to assign per worktree. | Yours to assign per worktree. | Still yours for servers you start. Full verification runs are limited to one at a time per machine by default. |
| Checking the work | You run the tests, if you remember. | Whatever you ask for, or wire up with hooks. | Orgabot runs the project’s verify command and gates on the exit code. |
| Review | You, reading every diff. | You, or another session you prompt to review. | An independent reviewer that is never the agent that wrote the change. |
| Merging | Whatever you push. | Whatever you push. | A draft pull request; merge follows the project’s approval policy. |
| Platform | Anywhere git runs. | Wherever Claude Code runs. | Local-first, macOS-first. Private alpha. |
The manual method and Claude Code’s own worktree flag are the right choice for two or three agents you are actively watching. Orgabot earns its setup cost when you would rather not be the verification step for every branch.
What actually stops a bad merge from a parallel agent?
Isolation keeps parallel agents from breaking each other. It does nothing to stop any one of them from shipping a broken change. That takes checks that do not depend on the agent’s own report, and Orgabot runs three of them on every mission, in order.
1. Orgabot runs your tests, not the agent
After the agent finishes, Orgabot runs the project’s registered verify command (npm test, pytest, swift test, anything with an exit code) in the mission’s worktree, against the exact committed change. A non-zero exit fails the gate and the mission stops instead of shipping. The agent’s description of its own test run is never counted as evidence. One honest caveat: if a project has no verify command and none is detected, verification is recorded as skipped rather than passed, and it does not block, so set one.
2. A different agent reviews the diff
An independent reviewer reads the diff and raises findings. The reviewer is never the agent that produced the change, by rule rather than by convention. Findings go back to a fix round, which re-verifies and is re-reviewed, until the change converges. The shipping and review page covers the loop in detail.
3. Draft pull requests and approval policy
Editing a branch is automatic. Opening a pull request, merging, and deploying are not: they require policy or your explicit approval. Pull requests open as drafts on purpose, so the work lands in your normal GitHub review process instead of on your default branch. If a mission needs authority it does not have, it asks and waits rather than proceeding. The approvals guide and the list of invariants Orgabot will not weaken explain why.
When a check fails, the mission holds with a named reason and its worktree intact, and orgabot follow-up continues it on the same branch. A hold is Orgabot declining to guess, not a crash. The known limitations page lists what the current alpha does not do yet.
What do I need before I start?
- A Mac. Orgabot is local-first and macOS-first; your code, worktrees and credentials stay on your machine.
- Node 22 or newer, npm, and git.
- The claude CLI installed and logged in, since Claude Code is the default worker.
- A test command worth gating on. The verification gate is most of the value.
- Alpha access. Orgabot is a private alpha; the install and setup guide covers the rest.
Common questions
- Can I run multiple Claude Code sessions on the same repository at once?
- Yes, as long as each session has its own working directory. Two sessions in one checkout share one set of files and one branch, so their edits collide. Give each session its own git worktree (git worktree add, or claude --worktree <name>) and each gets its own files and branch while sharing the same repository history.
- Do git worktrees share node_modules?
- No. A new worktree is a fresh checkout of tracked files, so it has no node_modules, no build output, and none of your gitignored files such as .env. You either install dependencies in each worktree or copy them in. Symlinking one shared node_modules into every worktree is the tempting shortcut and the risky one: a clean reinstall in one worktree can delete the tree the others depend on.
- How many coding agents can I run in parallel on a Mac?
- Fewer than you expect. Each agent session is cheap, but each one also runs installs, builds, and test suites, and several full test suites at once is what actually saturates a laptop. Orgabot defaults to one concurrent coding-worker session per eight CPU cores (at least one) and one full verification run at a time per machine, queuing the rest rather than starting and then pausing them. Both limits are configurable.
- What stops a parallel agent from merging broken code?
- Only a check the agent cannot talk its way past. An agent saying the tests pass is a claim. Orgabot runs the project’s own verify command itself, in the mission’s worktree, and gates on the exit code; then a reviewer that is never the agent that wrote the change reviews the diff; then the change opens as a draft pull request, and merging still follows the project’s approval policy.
- Is Orgabot free, and does it run on Linux or Windows?
- Orgabot is a private alpha, and you can request access at orga.bot/alpha. It is local-first and macOS-first: the dashboard, CLI and workers get their primary end-to-end testing on macOS, and equal packaging on other platforms is not promised yet.
Run agents in parallel without being the only safety check.
Orgabot is a private alpha for macOS. Every mission gets its own worktree, your own tests as the gate, an independent review, and a draft pull request you merge on your terms.