Definition
Git worktrees
Git worktrees are a Git feature that lets you check out several branches at once, each in its own directory. Codex can use worktrees for isolated tasks in the ChatGPT desktop app, which prevents conflicts when parallel local tasks run; its CLI and Cloud use different execution models.
Why it matters
Two agents editing one checkout will collide, and the collision is silent — each sees a working tree the other is changing underneath it. A worktree per agent is the cheapest way to make parallel work actually parallel.
How each tool handles it
- Cursor
- The Agents Window runs local, worktree, cloud and SSH agents.
- Claude Code
-
--add-dirextends a session across repositories. - Codex
- Worktree threads for isolated local tasks in the desktop app.
Frequently asked questions
Why do AI agents need worktrees?
Because parallel agents editing the same checkout overwrite one another. A worktree gives each its own directory on its own branch, so the isolation is enforced by Git rather than by everyone remembering to take turns.
Is a worktree the same as a clone?
No. Worktrees share one repository and its history, so they cost far less disk than separate clones while still giving each branch its own working directory.
Which tools run agents in worktrees?
Codex runs worktree threads for isolated local tasks in the ChatGPT desktop app, and Cursor's Agents Window runs local, worktree, cloud and SSH agents. Claude Code reaches across directories with --add-dir instead.