glossary
what is worktree isolation?
TL;DR
Worktree isolation means each AI agent gets its own copy of your code, on its own branch, in its own folder. Agents can then edit the same files at the same time without overwriting each other. Your main checkout stays untouched until you merge. Pane sets this up automatically for every pane.
Worktree isolation means every AI agent works in its own copy of your code, on its own branch, in its own folder. Several agents can then change the same files at the same time without overwriting each other, and your main checkout stays untouched until you merge.
the problem
Agents sharing one folder will eventually overwrite each other.
You ask agent A to rewrite the login page and agent B to add a signup flow. Both need to change auth.ts. In one shared folder, agent B saves its version and silently replaces agent A's edits. Neither agent notices, and you find out later.
That's why several agents in one directory is a gamble. It works until two of them touch the same file, and then someone's work is lost.
the fix
One worktree per agent: separate files and branches, same history.
Give each agent its own git worktree: a separate folder with a separate branch, sharing the same history. Agent A works in one, agent B in another, and both can edit auth.ts because they're editing different copies.
my-project/ ← main branch, untouched
my-project/worktrees/
├─ login-rewrite/ ← agent A, branch login-rewrite
└─ signup-flow/ ← agent B, branch signup-flowwhat gets isolated
Files, branch and shell are separate. History, remote and git objects are shared.
| isolated | shared |
|---|---|
| Files and uncommitted changes | Git history and commits |
| Branch | Remote (origin) |
| Shell state and env vars | Git config |
| Working directory | Object store (saves disk space) |
how pane does this
Pane sets up and cleans up a worktree for every pane automatically.
When you create a pane, Pane hands it a worktree it prepared in advance, gives it a new branch, copies in your .env files, agent settings and node_modules, and starts the agent there. When you archive the pane, Pane checks for unsaved work and removes the worktree. You never type git worktree add yourself.
what isolation doesn't cover
Worktrees keep agents' files apart. They don't sandbox what an agent can do.
A worktree is a folder, not a sandbox. Agents still run with your user's permissions, so one could read another worktree's files by path, reach the network, or change things outside the repo. In practice agents stay in their working folder, but if you need hard limits, run them in a container or VM.
Some things are shared outside git: a database your app uses, a dev server port, a global package cache. Pane gives each pane its own block of ports in PANE_PORT; for databases, use a setup script or a tool that creates one per worktree.
related
Sources
- Corrections
- If anything here is wrong or out of date, tell us and we'll fix it and update the date at the top. Open an issue on GitHub
- Sources
frequently asked questions
By Parsa Khazaeepoul, co-founder of Pane. .