1. git worktrees
Best for: a handful of agents on one laptop or dev box, which is how most people run Claude Code, Codex or Cursor in parallel
A worktree is another working directory attached to the same repository, on its own branch. Git shares everything except per-worktree files such as HEAD and the index, and won't check one branch out in two worktrees. The three main coding agents build on it. Claude Code starts a session in a new worktree with claude --worktree <name>, under .claude/worktrees/, and subagents with isolation: worktree get one each. The Codex app creates a worktree per thread in $CODEX_HOME/worktrees. Cursor runs agents in worktrees with setup commands from .cursor/worktrees.json. Each agent's work ends up on a branch you merge or open a pull request from.
Strengths
- Built into git and into Claude Code, Codex and Cursor, which handle creation and cleanup
- History is stored once; a new worktree is only a checkout
- Every agent's work is a branch, so merging is ordinary git
- Gitignored files such as
.envcan be copied in automatically with.worktreeinclude(Claude Code and Codex)
Tradeoffs
- Each worktree is a fresh checkout: Claude Code's docs say to install dependencies in it, and Cursor recommends against symlinking dependencies, so
node_modulesand build output exist once per agent - Agents share one machine's CPU, memory, ports, databases and dev servers, so two test suites or dev servers can still collide
- Limited to one machine; Cursor caps worktrees at 25 per machine by default, and Codex keeps its 15 most recent managed worktrees
- Large datasets don't belong in git: GitHub blocks files over 100 MiB