How to Run Multiple AI Coding Agents in Parallel
To run multiple Claude Code agents in parallel, give each one its own git worktree and branch, start each in its own terminal (tmux windows work well), hand every agent a task that touches different files, and merge the branches one at a time after reviewing each diff. The setup takes minutes. The hard part is that you can only watch and review so many terminals at once.
This guide covers the mechanics first: worktrees, tmux, how to cut a task into pieces that do not collide, and how to review the results. The same steps work for Claude Code, Codex, Gemini CLI, Aider or any other command-line agent, and you can mix them. Running Claude Code and Codex side by side is just two terminals in two worktrees.
Why one directory per agent
An agent edits files, runs builds and commits. Put two of them in the same directory and they trip over each other in ways that are annoying to debug. One agent changes a header while the other is mid-compile. Both stage files into the same index. A test run fails because of a half-finished edit that belongs to somebody else.
You could clone the repo several times. A git worktree is the lighter way. It is a second (third, fourth) checkout of the same repository, each on its own branch, sharing one object database. Creating one is instant and costs almost no disk beyond the working files.
Step 1: create a worktree per task
From your main checkout, make a sibling directory for each task. The -b flag creates the branch at the same time.
cd ~/code/myapp
git worktree add ../myapp-auth -b agent/auth
git worktree add ../myapp-search -b agent/search
git worktree add ../myapp-docs -b agent/docs
git worktree list
Each directory is now a full working copy. Anything untracked and local, such as a .env file or node_modules, does not come with it. Copy the env file over, and run your install command in each worktree. For big dependency trees, a package manager with a shared cache keeps this cheap.
Two rules git enforces and you should know. A branch can be checked out in only one worktree at a time. And you remove a worktree with git, not rm -rf:
git worktree remove ../myapp-docs
git branch -d agent/docs # after it is merged
git worktree prune # clean up stale entries
Ports are the other collision. If your app listens on 3000, three agents each running the dev server will fight. Give each worktree its own port through an env var, for example PORT=3001, PORT=3002, and tell the agent which one is its own in the prompt.
Step 2: one terminal per agent, with tmux
tmux keeps the sessions alive when you close the laptop lid or drop an SSH connection, which matters because agent runs can take a while. A layout that holds up in practice is one tmux window per agent, named for the task, plus one window for you.
tmux new-session -d -s agents -n auth -c ~/code/myapp-auth 'claude'
tmux new-window -t agents -n search -c ~/code/myapp-search 'codex'
tmux new-window -t agents -n docs -c ~/code/myapp-docs 'claude'
tmux new-window -t agents -n review -c ~/code/myapp
tmux attach -t agents
Switch with Ctrl-b then a window number, or Ctrl-b w for a list. Note that the first window runs Claude Code, the second runs Codex, and nothing about the setup cares which is which.
You can also tile panes in one window with Ctrl-b % and Ctrl-b ", which is nice for watching two or three agents at the same time. Beyond that it falls apart. Agent output is long, wide and full of diffs, and a pane at one quarter of a laptop screen shows you very little of it. Panes are for watching. Windows are for working.
Step 3: split the work so agents do not collide
Worktrees stop agents from overwriting each other on disk. They do nothing about two branches that edit the same lines, and git will surface that later as a merge conflict. The cheap fix is in how you split the task.
- Split by files or modules, not by idea. "Add rate limiting to the API" and "add a search endpoint" probably both touch the router. "Work only in
src/auth/" and "work only insrc/search/" do not. - Say which paths each agent owns in the prompt, and which it must not touch. Agents follow this well when it is explicit.
- Keep shared files out of parallel tasks. Lockfiles, route tables, database migrations, generated code, central config. If two tasks need a new dependency, one of them should wait, or you add the dependencies yourself first.
- Prefer tasks with a checkable end. "Make these 14 failing tests pass" or "migrate these five files to the new API" is easy to verify. "Improve the codebase" is not.
Good candidates for parallel work: independent bug fixes, test writing for separate modules, docs, a refactor in one package while a feature lands in another, and exploratory spikes where you will keep the best of two attempts. Bad candidates: anything where step two depends on the design decisions of step one.
Step 4: write a real brief
An agent running unattended is only as good as its brief. Put the repeated conventions in your project instructions file (CLAUDE.md for Claude Code, AGENTS.md for Codex and several others), then keep each brief short and specific.
Task: add pagination to GET /search.
Scope: only edit files under src/search/ and tests/search/.
Do not touch: package.json, lockfiles, src/router.ts.
Run the dev server on PORT=3002 if you need one.
Done when: npm test -- search passes. Commit to this branch.
If you need a change outside scope, stop and tell me.
That last line matters. An agent that hits a wall outside its scope should ask rather than quietly edit a shared file.
Step 5: review and merge one branch at a time
This is where parallelism pays or fails. Three agents finishing in ten minutes is no gain if you then spend an hour working out what they did.
- Review each diff against its branch point, not the working tree:
git diff main...agent/auth. The three-dot form shows only what that branch added. - Run the tests in that worktree before you merge, not after.
- Merge the smallest, most isolated branch first, then rebase the next one onto the result:
git -C ../myapp-search rebase main. Conflicts then appear one at a time, with one agent's work in front of you. - Hand conflicts back to the agent that owns the branch if they are non-trivial. It still has the context of what it was doing.
- Clean up with
git worktree removeandgit branch -das each branch lands.
git diff main...agent/auth --stat
git diff main...agent/auth
git merge --no-ff agent/auth
git -C ../myapp-search rebase main
Reading the diff is not optional. Treat each branch like a pull request from a capable colleague who has not shown you their reasoning.
The real limit is attention and screen space
People run into the same wall after the first afternoon. The CPU is fine. The API limits are fine. What runs out is you.
A laptop screen fits one comfortable terminal, or two if you squeeze. A single large monitor might hold four useful ones. Every agent also wants a browser tab with its preview, a diff to read, and sometimes a spec open for reference. With five agents you are alt-tabbing and re-finding context every few seconds, and each context switch costs more than it looks. The agents sit idle waiting for an answer to a question you did not notice.
Some honest ways to push the limit with a normal setup:
- A second or third monitor. The straightforward answer, and it works. A portrait monitor is good for a terminal that scrolls a lot.
- Fewer, better-scoped agents. Three agents you actually review beat six you skim.
- Virtual desktops. One desktop per task group, with the terminal, the browser and the diff together. Good, but you only see one group at a time.
The pattern behind all of these is that you want more surface area for glanceable state, not more things to type into. Which is a spatial problem.

Where a spatial workspace helps
An AR headset with passthrough does not make agents faster. What it does is remove the rectangle. Instead of a fixed number of pixels, you get as many terminal windows as you want arranged around you at a readable size, and you look at the one you want. For a workflow built on several long-running sessions you check in on, that is a useful property. It is also not free: you are wearing a headset, and for some people that is a dealbreaker for long sessions. If that is you, a multi-monitor desk plus tmux gets you most of the way.
VibeAR: the agent cockpit for Quest 3
VibeAR is a native mixed-reality workspace for Meta Quest 3 and 3S, built for developers running coding agents. You get unlimited terminals floating in your real room, with the shells running on your own Mac, so agents use your files, git and toolchains. Works with Claude Code, Codex, Grok, Mistral Vibe, Gemini CLI, Aider and any shell. $14.99/month, or $69 once for Lifetime.
Try VibeARHere is what that looks like for the parallel-agent workflow specifically.
- A window per agent, laid out like a desk. Terminals are resizable and reflow their rows and columns. Put the auth agent on your left, the search agent in front, and the docs agent over your shoulder. Your layout persists across sessions, and agent sessions survive restarting the server.
- Diff pills under each terminal. When an agent changes files, the +/- count shows as a pill under its terminal. Tap it to open the diff as its own window. That turns "which agent has something for me to review" into something you can see at a glance across the room. This works with Claude Code, Codex, Grok and Mistral Vibe.
- Presented files. Agents can put tappable file and URL pills under their terminal, so a finished task can hand you the page to open or the file to read rather than a path in scrollback.
- Voice orchestration. An optional cloud voice orchestrator can spawn agents, move windows and open pages by voice. "Start a Claude agent on the search folder" is a sentence, not three commands. Terminals can also ask you questions out loud, and you can answer by voice, which helps when an agent is blocked and you are looking at a different one. Dictation into any terminal uses local speech-to-text on your own machine.
- Workspaces per task group. The palm menu switches between virtual desktops, each with its own folder and ambience. Use one for the feature you are building and another for the cleanup agents.
- Browsers, a code viewer and notes beside the terminals. Each worktree's dev-server preview, a code viewer and a sticky note with the plan can sit next to the agent that needs them.

VibeAR does not replace the git discipline above. You still want worktrees, scoped tasks and one-at-a-time merges. What it changes is how much of the state of your agents you can hold in view at once.
The desktop companion is macOS on Apple silicon today, with Windows coming soon. The Quest app comes from the Meta Store, the two find each other on your local network, and you pair them with a 6-digit code. Your physical keyboard stays visible through passthrough, so you type normally.
Alternatives to consider
You do not need a headset to get most of the benefit.
- Several monitors plus tmux. Cheap, reliable, no new habits. Probably enough for three or four agents at a desk.
- A small script that creates the worktree, branch and tmux window for a task name. Ten lines removes most of the friction.
- Virtual monitor apps on a headset (Meta's remote desktop features, Immersed, Virtual Desktop, Apple Vision Pro's Mac Virtual Display). They give you big screens showing your normal desktop, so you still arrange the windows yourself.
- Display glasses such as Xreal. Lighter than a headset, good for one large screen, less suited to many independent windows.
- A browser and SSH inside a headset. Free, but one tab at a time, and you build the layout.
The difference with VibeAR is that it is built around the coding-agent case, not a general virtual monitor: the terminals are native windows that the app positions, tracks and reports on, so diff pills, presented files and voice spawning exist because it knows what a terminal and an agent are. If you do not run several agents at once, the extra is hard to justify, and one of the options above is a better fit.
Start with two agents, not five. Once reviewing two feels easy, add a third. The number that works for you is set by how quickly you can read a diff and decide.
FAQ
Can I run Claude Code and Codex side by side on the same repo?
Yes, as long as they do not edit the same working directory at the same time. Give each agent its own git worktree and branch, start claude in one and codex in the other, and merge the branches yourself when you have reviewed the diffs.
How many coding agents can I run at once?
The machine rarely limits you first. Your attention does. Most people find that three or four agents on well-separated tasks is about what they can review properly, and past that the review queue grows faster than they can clear it.
Do parallel agents need separate git worktrees?
If they touch the same repository, yes, in practice. Two agents in one directory share the same files and the same git index, so they overwrite each other, break each other's builds and mix their changes into one commit. A worktree gives each agent its own checkout while sharing the repository history.
What is the best tmux layout for several agents?
One tmux window per agent, named after the task, plus a separate window for a shell where you review and merge. Panes in a single window get cramped fast because agent output is long and wide. Use a tiled layout only for two or three agents.
How do I avoid merge conflicts between parallel agents?
Split work by files or modules, not by feature idea. Tell each agent which paths it owns, keep shared files such as lockfiles, route tables and config out of parallel tasks, and merge branches one at a time, rebasing the next onto the result.
Does VibeAR run the agents in the headset?
No. The shells run as real terminals on your Mac, so the agents use your files, git and toolchains. The Quest headset is the display and input, which is what lets you put as many terminal windows around the room as you like.