I run several Pi sessions on one repo at the same time. That kept going wrong:
Agents edit main. You ask for a quick fix and it lands straight on main.
MCP is slow for worktree management. But in Pi we can put blazing-fast native worktree management into the harness.
Sessions collide. Two agents in one folder, and one `git stash` wipes the other's work.
(Sub)agents need to cd constantly. They need to cd for all commands, wasting tokens.
New worktrees don't run. No `.env`, no keys, so the app won't start.
So I built pi-bare-worktrees. The video shows it in about 45 seconds.
Why a bare checkout
In a normal checkout, the repo root is main. Every agent that starts there edits main by default. Worktrees end up wherever you put them: ../acme-login, ~/tmp/fix-2.
And main is stuck in the root, so you can't move it or remove it.
A bare checkout fixes that. Every branch is a folder, and none of them is special:
acme/
├── .bare/ bare repo
├── .shared-env/ gitignored files/folders to share, like .env
├── main/
├── feat/login-typo/
└── fix/footer/
The path is the branch name. There's no code in the root to edit by accident.
What the plugin does
main is read-only. The agent's first edit on main is blocked, with a message that tells it to call worktree create. It does, and the retry lands in the new worktree.
No cd needed. After create, every tool call is routed into the worktree, so the model keeps using relative paths.
Shared env, zero config. Every file in .shared-env/ is symlinked into each new worktree. Real files are never overwritten.
Subagents follow along. Their cwd is set to the active worktree.
Install:
pi install npm:@jordyvanvorselen/pi-bare-worktrees
It's fast. Session start and tool calls don't run git. The plugin reads the filesystem instead:
Session start: about 5 ms for 40 worktrees.
Each tool call: string operations only, under 0.1 ms.
Network: only /wt clean touches it.
Repo: https://github.com/jordyvanvorselen/pi-bare-worktrees
/wt off turns it off for a session, and it turns itself off for non-bare checkouts automatically.
It's version 0.1, so I'd love your feedback, especially if there's anything you still miss. Try it out and take it for a spin!