Git worktrees for AI agents | Use cases | Lanes
When two agents edit the same working tree, they clobber each other. Git worktrees solve this: each is a separate checkout of the same repo on its own branch, sharing history without sharing files.
Doing this by hand, running git worktree add, naming branches, and cleaning up after, gets old fast. Lanes does it for you.
How Lanes does it
Auto-created. A worktree with a generated branch name appears when a session starts. Lanes puts it under .worktrees/ in your project root, names it {issueId}-{adjective}-{noun} (say 407-fond-cave), and branches it off the per-project base branch. The other worktree strategies cover the remaining cases: None runs the session in the project directory, Select reuses an existing worktree.
Tracked live. Uncommitted and unmerged state is shown per worktree in real time. The status popover in the status bar lists every active worktree grouped by project, with dirty indicators for uncommitted changes and unpushed commits.
Auto-cleaned. The worktree is removed when the issue reaches Done. If it is dirty, Lanes warns you first and explains what uncommitted state exists, so you never silently lose work.
No collisions. Each agent has its own files, its own branch, its own terminal. Three sessions on three issues means three directories on three branches.
Reviewing the work happens in the same panel. The built-in git viewer compares the worktree against the base branch in two modes: Changes shows everything the branch has done so far, History walks the commit log one commit at a time. Diffs open in a Monaco side-by-side view, the same diff editor VS Code uses.
Because each worktree is an independent directory, you can run a dev server or a test suite inside one without touching the others. Quick commands execute with the worktree as their working directory, and two built-in ones handle the finish line: Test Worktree runs your test suite inside the worktree, and Complete & Merge commits what remains, merges the branch into the base branch, and completes the issue.
When many worktrees are active at once, per-worktree board tabs filter the board down to the issues running in a single one.
Why it matters
Worktrees are what make real parallelism safe. A handful of agents can touch the same repo at once and none of them steps on another. You get the throughput of many agents without the merge chaos.
Worktrees themselves are not new; git worktree add has been in git for years. What stops people is the lifecycle. Creating, naming, branching, watching for dirty state, and removing worktrees is bookkeeping, and bookkeeping is exactly what makes running agents in parallel feel harder than it is.
Set it up
Add a project. Lanes detects the base branch (usually main), and you can override it in Settings.
Leave the worktree strategy on Create. It is the default for git repos; every new issue gets its own branch and directory.
Start sessions. Each one lands in its own worktree automatically.
Finish with Test Worktree, then Complete & Merge. Tests run inside the worktree; the merge brings the branch back to base and cleans up.
Add .worktrees/ to your .gitignore if you do not want the directory tracked.
Where this breaks without Lanes
Hand-rolled worktrees fail at the edges: a branch named after nothing, a directory you forgot to remove, an agent quietly running in the checkout you were editing. One stale worktree with uncommitted changes is enough to make you distrust the whole setup. Lanes owns the full lifecycle, from creation to warned-before-removal, so the edges are where it is most careful.
Further reading
Worktree management: strategies, auto-creation, dirty-state warnings, and cleanup.
Git integration: Changes and History modes and the Monaco diff view.
Quick commands: per-repo commands that run inside the issue's worktree.
Run AI coding agents in parallel: the workflow worktrees make safe.
See worktrees in the docs or get Lanes Desktop.