Give each AI agent its own git worktree: a second folder of the same repository, on its own branch, made with git worktree add. Agents then can’t overwrite each other’s files, and every worktree shares one history. Install dependencies in each, start one agent per folder, and merge each branch once you’ve reviewed it.
What is a git worktree?
A git worktree is a second working folder for a repository you already have. Each worktree has its own branch and its own files on disk, but they all share one history, so a commit made in one is visible to the others straight away. It’s built into Git; there’s nothing to install.
For AI agents that’s exactly the right shape. An agent works in its folder, on its branch, and can run its own tests there. Another agent in another worktree can’t see its half-finished edits, and neither can touch your main folder.
1. Make one worktree per agent
From your main folder, add a worktree beside it for each job, each on a new branch. Name the folder and the branch after the job, not the agent: the job is what you’ll review later.
Each new branch starts from the commit you’re on. A branch can be checked out in only one worktree at a time; if Git refuses, that branch is already open somewhere else, and git worktree list shows where.
2. Set each worktree up
A worktree holds the files Git tracks, and nothing else. Anything your .gitignore leaves out isn’t there yet:
- Install dependencies again in each worktree (
npm install,pip installand so on). - Copy across any local settings the app needs, such as a
.envfile. Never commit it to make this easier. - If two worktrees run a dev server, give each its own port, and its own database or data folder if the app writes one, so they don’t fight over them.
On Windows, deep folders in a worktree can hit the old 260-character path limit. Git for Windows can lift it for you:
3. Start one agent in each
Open a terminal in each worktree and start the agent there. Claude Code, Codex and Gemini CLI all work on the folder they’re started in, so each one stays inside its own copy.
Give each agent one job, and say which branch it’s on. If the agents should follow the same rules, keep those rules in a file the repository tracks, so every worktree has them: see a decision log for agents.
4. Merge, then clean up
When an agent says it’s finished, read the change and run the tests in its worktree. Then merge it from your main folder, remove the worktree, and delete the branch. Merge one branch at a time, and rebase the next on top before merging it, as the parallel agents guide shows.
git worktree remove refuses while the folder still has changes nobody committed, which protects work you haven’t looked at. If you ever delete a worktree folder by hand instead, run git worktree prune so Git forgets it.
Mistakes to avoid
The free IDE runs Claude Code, Codex and Gemini CLI side by side on up to two projects open at a time, and you can follow every step above in its terminal. Helpers handed out by the orchestrator, and landing their work in one step, are Founder.