How to run Claude Code, Codex and other AI agents in parallel

A workflow for running several AI coding agents at once with git worktrees: one branch per agent, setup, knowing which agent is waiting on you, and landing the results.

Short answer: give every agent its own git worktree on its own branch, created from an up-to-date main. Install dependencies and copy ignored config into each one, run each agent in its directory, review and land each branch through a pull request, then clean up the worktrees that landed.

Why one directory per agent

AI coding agents such as Claude Code, Codex, Gemini CLI, Aider and Cursor Agent edit your working tree directly and run git commands. Put two of them in one checkout and they overwrite each other’s files, mix unrelated changes into one diff, and compete for index.lock. A git worktree per agent gives each one an isolated directory and branch while sharing a single repository.

Step 1: create a worktree per task

git fetch origin
git worktree add -b feat/search    ../app-search    origin/main
git worktree add -b fix/login-loop ../app-login     origin/main
git worktree add -b chore/vite-6   ../app-vite      origin/main

Use one branch per task, not per agent. Branch names that describe the task make the later review and cleanup much easier than agent-1, agent-2.

Step 2: make each worktree runnable

  • Install dependencies in each directory (npm install, bundle install, and so on). Package managers with a shared global store, like pnpm, keep this fast.
  • Copy ignored files the project needs, such as .env. A new worktree only contains tracked files.
  • Give each dev server its own port so the agents can run tests and previews side by side.

Step 3: start the agents

Open a terminal tab per worktree and start the agent from inside that directory, for example cd ../app-search && claude or cd ../app-login && codex. Each agent sees only its own branch. Claude Code can also create the worktree for you with claude --worktree <name>; see Claude Code worktrees, and how Codex and Cursor compare. Keep your original checkout on main and don’t run an agent there, so you always have a clean place to review and test.

Step 4: notice which agent needs you

With three or more agents, the bottleneck becomes you. Agents stop to ask for permission, wait for an answer, or finish quietly, and it’s easy to lose ten minutes before noticing. Things that help:

  • Glance at each tab regularly, or turn on your terminal’s notification for a bell or finished command.
  • Watch file activity: an agent that hasn’t changed a file in a while is often waiting for input.
  • Keep the number of parallel agents to what you can actually review.

Step 5: land the work

When an agent is done, review the diff from its worktree, commit, push and open a pull request: git push -u origin feat/search then gh pr create. Watch for work an agent left uncommitted or committed but never pushed. That’s the work that gets lost when worktrees are cleaned up later.

Step 6: clean up what landed

Once a pull request is merged, remove its worktree and branch. If your repository squash-merges, git branch --merged won’t show those branches, so check the PR instead. Our worktree cleanup checklist covers every case.

A dashboard for parallel agents

Orchard is a Mac app built for this workflow. It shows every worktree in every project in one window and recognizes Claude Code, Codex, Aider, Gemini CLI, Cursor Agent, opencode, Amp and Goose by the folder each one is running in. You see which agent is still working, which one hasn’t changed a file for a while and may be waiting for you, what hasn’t landed yet, and which worktrees are already in main and can be cleaned up. Its background checks are read-only, so it never gets in an agent’s way.

FAQ

How many AI coding agents can I run in parallel?

The limit is usually your attention, not your Mac. Many developers find three to five parallel agents manageable. Beyond that, review and merge become the bottleneck, and unattended worktrees start to pile up with unlanded work.

Can Claude Code and Codex work on the same repository at once?

Yes, as long as each runs in its own git worktree on its own branch. They share the repository’s history, but files, index and branch are separate, so they don’t overwrite each other’s changes.

Should I run an agent in my main checkout?

It’s better not to. Keeping the main checkout on main gives you a clean place to pull, review and test, and avoids accidentally committing an agent’s experiment directly to main.