Products
DeckSpaceLive DeckVoice$19 DeckTest$29 Claude Accounts$14 DeckStudioSoon
More
Docs Changelog Pricing Community Download Start free trial →
Home / DeckSpace / Guides / Several agents, one repo

Running several AI agents on one repo

Two agents in one checkout do not work in parallel. They take turns, badly. A git working tree has one index and one HEAD, so once a second agent starts editing, both are staging into the same index, writing the same files and committing onto the same branch. There is no merge step, because there is nothing to merge — one agent's edit lands on top of the other's and nothing reports it.

The fix predates coding agents. git worktree checks the same repository out into a second directory, on its own branch, with its own index. Give each agent one and they share history and nothing else. This page covers the pattern by hand first, so you can run it with no tooling at all, then what DeckSpace automates around it.

The parts where the isolation stops are here too. A worktree solves a git problem, not a filesystem one, and the count of agents you ask for is a ceiling rather than a promise.

Why two agents in one checkout collide

Three things belong to the working tree rather than to the process using it. Each one fails differently.

This is why several terminal tabs opened in the same directory is not parallel work. It is the same serial work with the accounting removed. You find out at review time, if at all.

The worktree-per-agent pattern, by hand

You can run this today with git alone. Each agent gets a directory and a branch, and your own checkout is never written to.

  1. Create a tree per agent: <code>git worktree add -b agent-1 ../work/agent-1 HEAD</code>. Repeat with a different branch and path for each one.
  2. Start each agent CLI with its working directory set to that path. It now has its own index, its own HEAD and its own files.
  3. Give each agent an explicit list of files it owns, and tell it not to touch others. Nothing enforces this — it is a prompt, and it is the weakest link in the pattern.
  4. Before merging, predict the result without mutating anything: <code>git merge-tree --write-tree --name-only HEAD agent-1</code>. A non-zero exit lists the paths that would conflict.
  5. Merge the one you want — <code>git merge --no-ff agent-1</code> — then remove the rest: <code>git worktree remove --force ../work/agent-1</code> followed by <code>git branch -D agent-1</code>.

Two costs are worth knowing before you script this. A new worktree has no <code>node_modules</code> and no build cache, so each agent starts with an install. And <code>--force</code> on removal overrides git's own refusal to delete a tree containing modified files, which is what makes a run disposable and also what makes it unrecoverable.

What DeckSpace automates

Swarm takes one goal, splits it into tasks, and gives each task a branch, a worktree and a terminal pane. The mechanics are the ones above, run for you.

Merge commits the worktree, snapshots your repository first, runs <code>git merge --no-ff</code>, then removes the worktree and deletes the branch. Discard runs <code>git worktree remove --force</code> and <code>git branch -D</code>, and throws away uncommitted work in that tree with no second prompt. Team works from a plan you approve first, on branches named <code>maestro/&lt;run-id&gt;/&lt;key&gt;</code>. It stops short of your working branch: the merged result lands on a <code>maestro/&lt;run-id&gt;/integration</code> branch and the run report hands you the <code>git merge --no-ff</code> line to run yourself.

The number you ask for is a ceiling

Four separate limits sit between the number you type and the agents that actually open.

The task split comes from a headless planning call that runs only when the CLI you picked for the roster resolves to Claude Code. Picking another CLI skips it even when Claude Code is installed. Without the split the planner returns a single task — your goal, verbatim — and the swarm opens one builder whatever number you asked for. The log line reads Plan: 1 builder task(s), and that is the only warning you get. The builders themselves can be any detected CLI, and the optional Scout pass is gated the same way.

What the Sandbox setting does not cover

A worktree is an isolation boundary for git, not a fence around the process. Those are separate mechanisms with separate switches, and conflating them is the mistake worth avoiding.

On macOS, worktrees all live under the same temp directory, so a write fence anchored on that directory does not stop one builder reaching another's checkout. Treat the worktree as protecting your own checkout, which it does completely, and not as fencing builders off from each other.

The review gate before anything merges

Nothing reaches your branch because an agent said it was finished. Review on a task card runs four steps, and none of them touch your own branch.

  1. The worktree is committed on its own branch. Your checkout is untouched.
  2. The merge is predicted with <code>git merge-tree --write-tree</code> against your current HEAD. It writes objects but mutates nothing, and conflicting paths are listed on the card.
  3. Your project's own checks run inside the worktree, then a reviewer agent returns a verdict whose first line must be exactly <code>APPROVED</code> or <code>CHANGES_REQUESTED</code>. A timeout or a missing verdict is not an approval.
  4. Approved plus a clean predicted merge is what produces a green card. A predicted conflict or a failed check downgrades a clean approval to changes requested, and Merge relabels itself Merge anyway — the first click only arms it, and you have six seconds to click again before it disarms. An approval is also tied to a digest of the files it was given: if the worktree or the base branch moves afterwards the approval is dropped and you are asked to review again.

Review needs one of three CLIs installed — Claude Code, Codex or Antigravity — each launched in its own verified read-only mode. When more than one is present it deliberately picks a different one from the CLI that wrote the code, so the work is not graded by the model that produced it; with only one, it reviews with that same one. If none of the three is installed, Review stops and tells you to review the task manually. Team goes further and parks at a plan gate before anything launches — no worktree is created and no CLI is started until you approve the plan.

Where this stops working

The honest limits, in the order people hit them.

Try it on your own repository

DeckSpace runs your own agent CLIs in up to 16 panes, gives each Swarm and Team worker its own git worktree, and predicts the merge before anything reaches your branch. $24/mo, or $228/yr. Seven-day free trial, card required.

Start the 7-day free trial

Common questions

Can two AI agents work on the same repo at the same time?

Only if each one has its own working tree. A single git checkout has one index and one HEAD, so two agents editing it are staging into the same index and committing onto the same branch, and one agent's write silently replaces the other's. Give each agent its own git worktree on its own branch and they share only history. That is the pattern DeckSpace automates for Swarm and Team runs.

Do I need a separate clone for each agent?

No. A git worktree checks the same repository out into a second directory on a different branch, with its own index, without duplicating the object database. It is cheaper than a clone and the branches are visible from your main checkout, so you can review and merge them without adding a remote. The one real cost is per-directory build state: a fresh worktree has no node_modules and no build cache.

How many agents can actually run at once in DeckSpace?

The roster accepts 1 to 12, and the builder list is truncated to 12 before any worktree is created. Panes are capped at 16 in total, shared with every other pane you have open, so a full grid means a builder does not get a pane even though its branch and worktree exist. Asking the assistant to launch a run reads a separate cap that defaults to 8.

What happens if two agents edit the same file?

The planner is asked for tasks that touch different files, and each task's owned paths go into its builder's prompt, but nothing enforces that at the filesystem level. An overlap produces a warning line in the log before dispatch, which compares only the declared ownership and does not stop the launch. The real check is at review time, when the merge is predicted with git merge-tree and the conflicting paths are listed on the task card.

Does a worktree sandbox the agent?

No. A worktree isolates git state — index, branch and working files — so your own checkout is never written to and a bad run is deleted rather than unpicked. Process confinement is a separate mechanism with its own setting, and what you get depends on your operating system. Each pane records the fence it actually received, so you can tell a confined pane from an unconfined one rather than inferring it.