Pi extension

Git worktrees for parallel Pi sessions

Two AI coding agents in one checkout can overwrite each other's edits. Pi Worktree gives each task its own worktree, branch, and resumable session. One command, no manual setup.

pi install npm:pi-worktree-extension
pi
/worktree fix-auth
npm version MIT license Tested with Pi 0.83.0

Why Git worktrees

Git worktrees let one repository have multiple branches checked out at the same time. Each Pi session gets a separate directory, so its file changes do not collide with another session.

Worktrees isolate files, not permissions. Each Pi process still uses your account and has the same repository access.

Manual workflow and Pi Worktree

TaskPi WorktreeManual workflow
Create a task workspace or move the current conversation/worktree fix-authCreate a branch and worktree, cd, start Pi, and recreate context
Return to the primary checkout/worktree-exitFind the checkout and restart or resume Pi
Remove a checkout/worktree-remove fix-authCheck that it is clean and inactive, then remove it

Move an active conversation

Run /worktree fix-auth from an active Pi session. Pi moves the current conversation into the worktree, including its history.

Worktree layout

my-project/
├── primary checkout                 main
└── .pi/worktrees/
    ├── fix-auth/                    worktree-fix-auth
    ├── add-api-tests/               worktree-add-api-tests
    └── refactor-cache/              worktree-refactor-cache

Commands

/worktree fix-auth
Create or enter a task workspace.
/worktree-switch fix-auth
Switch to an existing workspace.
/worktree-list
See managed worktrees.
/worktree-exit
Return to the primary checkout.
/worktree-remove fix-auth
Remove a clean, inactive checkout.

The optional pi -w fix-auth shell launcher starts or resumes a task directly from a terminal.

Safety

Removal refuses dirty or active checkouts. Pi Worktree never deletes branches. There is no force mode.