Guides/Git worktree

Run AI coding agents in parallel with Git worktrees

Let several AI agents work on the same repository at once without stepping on each other — how Git worktrees isolate each agent, and how to merge the results safely.

Vulgr team··2 min read

The short answer: give every agent its own Git worktree — a separate checkout of the same repository on its own branch. Agents can edit, build and test at the same time without touching each other’s files or your working tree. When they finish, merge the branches, run the tests together, and review the combined diff.

What is a Git worktree?

A worktree is an extra working directory attached to the same repository. Each one has its own branch and its own files on disk, but they all share one .git history. You create one with:

git worktree add ../my-app-task-a -b task-a

Because the directories are separate, an agent running npm install or rewriting a file in one worktree cannot break the others.

Why agents need isolation

Two agents editing the same checkout will overwrite each other’s changes, trip over half-finished builds and produce test results that mean nothing. Isolation turns that chaos into independent tasks:

  • each agent gets a clean branch to work on,
  • each runs its own tests against its own changes,
  • your own working tree stays exactly as you left it.

A safe parallel workflow

  1. Split the goal into tasks that touch different parts of the code.
  2. Create one worktree per task and start one agent in each.
  3. Test each task in its own worktree before merging.
  4. Merge the branches and resolve any conflicts.
  5. Run the full test suite on the merged result.
  6. Review the combined diff — ideally with a different agent than the ones that wrote it.

Doing it in Vulgr

Vulgr’s Orchestrator automates exactly these steps: a planner splits the goal into a task graph, workers run each task in parallel in their own worktree with their own tests, the parts are merged and tested together, and a reviewer approves the result before it reaches your working tree. Agent Swarm can also run in an isolated worktree.

Vulgr keeps its worktrees in a .worktrees/ folder that is hidden through .git/info/exclude — your .gitignore is never touched — and cleans up orphaned worktrees automatically.

Common questions

How many agents can run in parallel?

As many as you have tasks that do not depend on each other — and as your agent plans’ usage limits allow. Three parallel workers is a good starting point.

What if two tasks change the same file?

The merge step will show a conflict. Splitting the goal so tasks touch different files avoids most of them; the reviewer step catches the rest.

Vulgr is a free, open-source (MIT) desktop terminal for running AI coding agents — Claude Code, Codex, Gemini CLI, Cursor, OpenCode and Antigravity — side by side. It gives each agent a role so one writes code, another reviews it and a third tests it, looping until the work passes. It runs locally on macOS, Windows and Linux and uses the agent CLIs you already have.

Try it in Vulgr