How to Run Multiple Claude Code Agents in Parallel
Run multiple Claude Code agents at once with git worktrees, Terminal tabs or tmux. Exact commands, plus fixes for port clashes, missed prompts and merges.
GuideUpdated 12 min read
On this page
To run multiple Claude Code agents in parallel, give each agent its own git worktree. Then start claude in each folder from its own Terminal tab or tmux window. For example, git worktree add -b agent/auth ../myapp-auth creates a separate checkout on a new branch, so no agent edits another agent's copy of the files.
Two agents are easy to manage this way. Past two, three problems show up:
- Dev servers fight over ports.
- Permission prompts sit unanswered in background tabs.
- Merging the branches back gets messy.
The sections below cover the manual setup, each of those problems, and a workspace app that handles them.
Why parallel agents need separate checkouts
Two agents in one folder share one working tree. One agent's half-finished edit breaks the other's test run. A git stash or git checkout from one agent changes files under the other. When something goes wrong, you can't tell whose change caused it.
A git worktree is a second working folder for the same repository, checked out on its own branch. All worktrees share the repo's history and branches, so a commit made in one is visible from the others right away. Each worktree has its own files, its own index and its own HEAD, so agents can work side by side without touching each other's edits.
For more on worktrees, see Claude Code worktrees: run agents without conflicts.
The manual way: git worktrees and terminal tabs
You need git, Claude Code and the Terminal app. The examples assume your repo is at ~/code/myapp and its main branch is main.
Open Terminal and go to your repo:
bash cd ~/code/myappCreate one worktree per task, each on a new branch:
bash git worktree add -b agent/auth ../myapp-auth git worktree add -b agent/search ../myapp-searchEach line creates a sibling folder (
~/code/myapp-auth) checked out on a new branch (agent/auth) that starts from your current commit.Press ⌘T (Command-T) to open a new Terminal tab. Then start an agent in the first worktree:
bash cd ~/code/myapp-auth && claudeOpen another tab and do the same for
~/code/myapp-search.Give each agent its task in its own tab.
To list every worktree and its branch:
git worktree listWhat this can't do:
- If you close the Terminal window, the agents in it stop.
- Nothing tells you which tab is waiting for an answer.
- Each new worktree contains only the files git tracks. It has no
node_modules, no.envand no build output until you add them. See "Avoiding port clashes and duplicated setup" below.
Using tmux to keep several sessions running
tmux keeps terminal sessions alive after you close the Terminal window, and it puts every agent in one session you can switch around in. It doesn't come with macOS. If you use Homebrew, install it with:
brew install tmuxThe commands below create one tmux session with a window per agent, start Claude Code in each window, then attach:
tmux new-session -d -s agents -n auth -c ~/code/myapp-auth
tmux new-window -t agents -n search -c ~/code/myapp-search
tmux send-keys -t agents:auth 'claude' Enter
tmux send-keys -t agents:search 'claude' Enter
tmux attach -t agents- Line 1 creates a detached session named
agents, with a windowauththat opens in the auth worktree. - Line 2 adds a window
searchin the search worktree. - Lines 3 and 4 type
claudeand press Return in each window. - Line 5 attaches your Terminal to the session.
Inside tmux, press Control-B and then one of these keys:
nfor the next windowpfor the previous windowwfor a list of all windowsdto detach and leave everything running
Reattach later with tmux attach -t agents. When you're done, tmux kill-session -t agents ends the session and every agent in it.
What this can't do:
- tmux sessions don't survive a restart. Afterward, go to the worktree and run
claude --continueto pick up the most recent conversation in that folder. - tmux can't tell you which agent is waiting. Its
monitor-activityoption flags windows that have new output. A working agent produces output all the time, so the flag doesn't separate "busy" from "waiting for you".
Agents also pause when your Mac sleeps. If you leave them running unattended, see keep your Mac awake while Claude Code runs. To keep a single session going after you close the terminal, see keep Claude Code running in the background.
Avoiding port clashes and duplicated setup
A new worktree gets only tracked files. Anything git-ignored stays behind in your main checkout, including dependencies, .env files and local config. That causes two problems.
Duplicated setup. Every worktree needs its dependencies installed and its secrets copied. A small shell function can do both:
- Add the function below to
~/.zshrc. - Open a new Terminal tab so the change loads.
- From your main checkout, run it with a task name, for example
newagent auth.
newagent() {
local repo dir
repo=$(basename "$PWD")
dir="../$repo-$1"
git worktree add -b "agent/$1" "$dir" || return
[ -f .env ] && cp .env "$dir/"
(cd "$dir" && npm ci)
}The function creates the worktree and branch, copies .env if there is one, and installs dependencies in the new folder. Replace npm ci with your project's install command. To remove the function, delete it from ~/.zshrc.
Port clashes. Suppose every agent starts a dev server on the same port. The second one fails with an "address already in use" error, or the agent ends up testing the wrong server. Give each worktree its own port:
- For tools that read the
PORTvariable, such as Next.js:PORT=3001 npm run dev - For tools that take a flag, such as Vite:
npm run dev -- --port 3001
Tell each agent its port in the task, or put the port in that worktree's .env. To see what is holding a port:
lsof -i :3000This lists the process using port 3000. To stop it, see how to kill a process on a port.
Knowing which agent needs you
This problem grows fastest. Claude Code stops and waits whenever it asks permission to run a command or edit a file. With four agents in four tabs, one can sit blocked for an hour while you watch another.
Your options with the manual setup:
- Check each tab or tmux window regularly. This works for two agents and gets tedious after that.
- Use Claude Code's hooks. Claude Code can run a command when it needs your attention, for example to post a macOS notification. The setup is in get notified when Claude Code needs you.
- Don't skip permissions to avoid the prompts. Running every agent with
--dangerously-skip-permissionsremoves the waiting. It also removes your only chance to stop a bad command. See a safer alternative to --dangerously-skip-permissions.
Reviewing and merging each agent's work
An agent's work only lives on its branch once it is committed. Ask the agent to commit when it's done, or commit the work yourself in that worktree.
To check a worktree for uncommitted changes without leaving your main checkout:
git -C ~/code/myapp-auth statusTo review what a branch changed since it split off main, run this from the main checkout:
git diff main...agent/authThe three dots compare against the point where the branch started, so changes made on main since then don't show up.
Then do one of the following.
To merge the branch locally:
git switch main
git merge --no-ff agent/authTo push the branch and open a pull request on your Git host:
git push -u origin agent/authAfter that merge, the second agent's branch starts from an older main. Worktrees share branches, so the search worktree already sees the updated main. Commit any work there, then rebase it before merging. Resolve any conflicts in that folder:
cd ~/code/myapp-search && git rebase mainOnce a branch is merged, clean up its worktree and branch:
git worktree remove ~/code/myapp-auth
git branch -d agent/authThese commands refuse to run in two cases:
git worktree removerefuses if the worktree has uncommitted changes or untracked files. Adding--forcedeletes those changes permanently.git branch -drefuses to delete a branch that isn't merged.git branch -Ddeletes it anyway, along with any commits that exist only on that branch.
Running multiple Claude Code agents in Sledbot
We make Sledbot, a native Mac app for running coding agents in real terminals, so weigh our view accordingly. It handles the worktrees, ports, prompts and merges described above.
It needs macOS 14 Sonoma or later and Claude Code installed and logged in. If Claude Code is missing, Sledbot offers to run its install command for you.
Start several agents, each in its own worktree
- Choose File ▸ Add Project Folder… (⌘O, Command-O), or drag the repo folder onto the sidebar. It becomes a space.
- Press ⌘T to open New task.
- Describe the task. Type
@to mention a file. - In the agent chip, pick Claude Code. Sledbot defaults to the agent you used last, or to Claude Code if you haven't used one yet.
- Leave Work in a new worktree on. It's on by default for git repos. Edit the
agent/…branch name if you want. - Press ⌘↩ (Command-Return) to start.
- Repeat for each task.
Each worktree goes in <repo>/.sledbot/worktrees/. Sledbot adds .sledbot/ to .git/info/exclude so these folders stay out of your commits.
Each agent gets its own tab. A tab can hold up to 4 panes. Split it with ⌘D (Command-D) to the right or ⇧⌘D (Shift-Command-D) down.
Agents run in a background engine, so quitting Sledbot doesn't stop them. When you reopen the app, it reattaches to the live screens. After a crash or reboot, the engine restarts Claude Code with claude --resume in the same folder.
Setup and ports per worktree
Put a .sledbot/config.json (or sled.json) at the root of your repo:
{"setup": ["npm ci"], "copy": [".env"], "run": "npm run dev -- --port $SLED_PORT", "archive": "docker compose down"}setupholds the commands that prepare a worktree.copylists git-ignored files to bring over.runstarts your dev server.archiveholds the cleanup command.
Terminals in a worktree get their own SLED_PORT. They also get SLED_PORT_1 to SLED_PORT_9 if you need more ports, plus SLED_WORKTREE, SLED_BRANCH and SLED_ROOT. Use $SLED_PORT in your run command and dev servers stop colliding.
Every Sledbot terminal has the sled command, so you can run the scripts with sled worktree setup and sled worktree run.
See which agent needs you


Every agent shows a live status: working, needs you, done, idle, error or exited. Sledbot gives Claude Code per-launch hooks, so it learns as soon as Claude Code stops for permission or asks a question. You can find waiting agents in several places:
- Needs you in the sidebar lists everything waiting, oldest first. You can answer approval cards from the keyboard:
- ⌘↩ allows once.
- ⌥⌘↩ (Option-Command-Return) always allows.
- ⌘⌫ (Command-Delete) denies.
- ⌘J (Command-J) jumps to the next agent that needs you.
- Board shows every agent in the columns Needs you, Working, Done and Idle.
- Banners appear for agents you aren't looking at. They have Allow once, Deny, Later (1 h) and Reply… buttons. Sledbot asks for the Notifications permission the first time you start an agent.
- A bell in the menu bar and a badge on the Dock icon show how many items are waiting.
Built-in rules make risky actions ask first unless you add a rule that allows them. These include:
- Pushes to protected branches such as
main - Merges, deploys and package publishing
sudo- Deleting or writing files outside the worktree
Claude Code also keeps its own permission prompts. Needs you and approvals covers the rules.
Run one task on several agents, or send one message to all
- Agents ▸ Compare Agents… runs the same task with 2 to 4 agents. Each one gets its own worktree on a
compare/…branch, and they open side by side in one tab. This only works in a git repo. - Broadcast… (⇧⌘B, Shift-Command-B) sends one message to several agents, for example "run the full test suite and commit". Agents that are waiting for you are skipped.
Review and merge
Click Review changes on an agent to see everything it changed compared with the base branch, one hunk at a time:
- Accept (A) stages the hunk.
- Reject (R) restores the original.
- Comment (C) sends your note to the agent's terminal along with the file and line.
Merge and Open PR become available once every hunk is reviewed:
- Merge commits any uncommitted work in the worktree. Then it runs
git merge --no-ff --no-editin your main checkout, which must be on the base branch. - Open PR pushes the branch and runs
gh pr create --fill, so it needs the GitHub CLI.
To remove old worktrees, use Clean up worktrees… in the space's context menu. Details are in review an agent's changes and workspace, tabs and the board.
Sledbot is part of MacSuite ($349 one-time as of November 2026), and you can try it free for 7 days.
Other tools built for this
As of November 2026, based on our research notes:
- Claude Squad is an open-source terminal UI built on tmux and git worktrees. Its
--autoyesoption accepts prompts automatically. It suits you if you want to stay in the terminal. - Conductor is a closed-source Mac app. It has parallel agent workspaces, setup scripts, a per-workspace port variable (
CONDUCTOR_PORT) and pull request creation.
For more options, see the best Claude Code GUI apps for Mac, Claude Squad alternatives and Conductor alternatives.
Which method to use
| Worktrees + Terminal tabs | Worktrees + tmux | Sledbot | |
|---|---|---|---|
| Agents survive closing the window | No | Yes, until a restart | Yes, and they resume after a restart |
| Shows which agent needs you | No (hooks can notify) | No (hooks can notify) | Needs you list, Board, banners, badges |
| A separate port per agent | You assign them | You assign them | SLED_PORT per worktree |
| Setup per worktree | Your own script | Your own script | setup / copy in config |
| Review and merge | git commands | git commands | Per-hunk review, Merge, Open PR |
| Cost | Free | Free | MacSuite license, 7-day trial |
- Terminal tabs: pick these for two agents and a short session.
- tmux: pick this if you live in the terminal and want sessions that outlast the window.
- A workspace app like Sledbot: pick this once you regularly run three or more agents and spend more time hunting for blocked tabs than reviewing work.
How many agents is too many?
There is no fixed number. These are the limits you'll hit:
- Your review time. Every agent produces a branch you have to read. If finished branches pile up unreviewed, more agents won't speed you up.
- Overlap between tasks. Agents working in the same files produce merge conflicts. Split work by area, such as one agent on auth, one on search and one on tests. Don't give several agents slices of the same feature.
- Usage limits. Every session on the same Claude account draws on the same plan limits, so four agents reach the limit sooner than one. How to check Claude Code usage and limits shows where you stand.
- Your Mac. Each agent can bring its own dev server, test runs and language server. Watch memory pressure in Activity Monitor, or in Sledbot's Resources view (⌥⌘R, Option-Command-R).
Start with two or three agents on clearly separate tasks. Add more once your reviewing keeps up.
If it doesn't work
git worktree addsays the branch is already checked out or used by another worktree. Git won't check out one branch in two worktrees. Create a new branch with-b agent/<name>, or use a different existing branch.- The agent can't find dependencies or environment variables. The worktree has only tracked files. Run your install command in it and copy
.envover, or use thenewagentfunction above. - The dev server fails with "address already in use". Another worktree's server holds the port. Run
lsof -i :3000to find it, and give each worktree its own port. - An agent looks stuck. It's usually waiting at a permission prompt in a tab you aren't watching. Check every tab or window, or set up notifications.
- The agents are gone after a restart. Terminal tabs and tmux sessions don't survive a restart. Go to the worktree and run
claude --continueto resume the latest conversation there. - The second merge conflicts. The two agents changed the same lines. In the second worktree, rebase its branch onto the updated
mainand resolve the conflicts there. Then merge.
FAQ
Can two agents work in the same folder without worktrees? Only if at most one of them edits files. For example, one agent can explain code while another writes it. Once both edit, they change each other's working tree and test against each other's half-finished work.
Do worktrees take up a lot of disk space? They share the repository's history. The extra cost is one copy of the tracked files plus whatever each worktree installs or builds, such as node_modules. Remove worktrees once their branches are merged.
Can I mix Claude Code with other agents? Yes. Each worktree can run a different agent. In Sledbot you pick the agent per task, and Compare Agents… can run Claude Code and Codex on the same task side by side.