shedix

Run several coding agents at once with git worktrees

Two agents in one checkout will edit the same files, fight over the same dev server port and mix their changes into one diff that nobody wants to review. Git already has the fix. A worktree gives each agent its own folder and its own branch, while all of them share one repository.

One branch and one folder per agent

The git worktree docs describe it this way: a repository has one main worktree and any number of linked ones. Each linked worktree has its own HEAD and index, and shares everything else, including branches and history.

cd ~/work/myapp
git worktree add ../myapp-auth -b agent/auth
git worktree add ../myapp-search -b agent/search
git worktree list

Each add makes a folder next to your checkout, creates a branch from your current HEAD and checks it out there. Point one agent at ../myapp-auth and another at ../myapp-search.

Two rules make this safe. Git refuses to check out a branch that's already checked out in another worktree unless you force it, so two agents can't land on one branch by accident. And because branches are shared, a commit made in one worktree is visible from all of them at once. You can review an agent's work from your main checkout with git log agent/auth or git diff main...agent/auth without switching folders.

When an agent is done, merge its branch, or push it and open a pull request. Then clean up:

git worktree remove ../myapp-auth
git worktree prune

remove refuses if the folder has uncommitted changes or untracked files, unless you add --force. prune clears the records of worktree folders you deleted by hand.

Let the agent make the worktree

Both agents can set this up themselves. In Claude Code, claude --worktree auth (or -w auth) creates .claude/worktrees/auth/ at the repository root, on a new branch called worktree-auth, and starts the session there. The Claude Code worktree guide suggests adding .claude/worktrees/ to .gitignore. When you exit, Claude Code removes a worktree that has no changes, or asks whether to keep one that has work in it.

Codex has a --worktree flag that starts it in a new managed git worktree, listed in the Codex CLI reference.

Every worktree is a fresh checkout

A worktree holds your tracked files and nothing else. Untracked files such as .env aren't there, and neither are installed dependencies or build output. Each agent needs its own install before it can run tests. Claude Code can copy gitignored files into every worktree it creates: list them in a .worktreeinclude file at the project root, in .gitignore syntax.

Shared resources still collide. Two agents running migrations against one local database will step on each other, so give each its own database or container. Ports need watching too. Vite, for one, moves to the next free port when 5173 is taken, so a second dev server starts without an error, and you have to check which agent got which port.

Where a laptop runs out of room

Every agent brings a set of processes with it: the agent itself, a type checker or language server, a test runner, a dev server, sometimes a browser for end-to-end tests. Every worktree with its own node_modules adds disk. Many test tools also size themselves to the machine. Playwright runs workers on half the logical CPU cores by default, so two agents running Playwright at the same moment ask for all of them.

We won't give you a number of agents a laptop can handle, because it depends on the project. Run your usual work with two agents and watch memory and CPU in top or Activity Monitor. When the editor lags or the test runs slow down, you've found your limit.

A laptop also has one limit that all the agents share: when it sleeps, every one of them stops at once.

One tmux session per agent

Give each agent its own tmux session, named after its task. You can leave them running, detach, and check in on one at a time.

tmux new -s auth -c ~/work/myapp-auth
# start claude, give it the task, then press Ctrl-b d to detach
tmux new -s search -c ~/work/myapp-search
tmux ls
tmux attach -t auth

Inside tmux, Ctrl-b s lists your sessions so you can jump from one agent to the next. The tmux manual has the rest. Claude Code can do both steps at once: its --tmux flag, used with --worktree, creates a tmux session for the new worktree. It uses iTerm2's own panes when they're available; pass --tmux=classic for plain tmux.

claude -w auth --tmux=classic

Spread the agents out

On shedix you can run this layout on one bigger machine or across several.

One machine: an L has 8 vCPU and 16 GB of RAM for $0.32/hr, and an XL, from the API and CLI, has 16 vCPU and 32 GB for $0.64/hr. Put one worktree and one tmux session per agent on it. The machine page has a web terminal that works in a browser or on your phone, so you can switch between sessions from anywhere.

Several machines: give each agent its own. An S, with 2 vCPU and 4 GB, is $0.06/hr. Machines sit on an isolated network and can't reach each other, so agents on separate machines can't touch each other's files or ports. Each one pushes its branch to your remote and you review there. The machines have git and gh installed; run gh auth login on a machine if you want its agent to push.

Many at once shows the one-machine layout on shedix, and the pricing page lists every size. When you want to try it, start a machine.