Docs/Workflows

Worktrees and code review

Local and worktree threads, review mode, comments, sync and merge back.

A Git worktree is a second checkout of the same repository. A thread placed in a worktree edits files there, so parallel threads do not touch each other's files. Its Files, Terminal and Changes panels use that directory.

Choose where a thread runs#

Before the first message, pick a mode in the row above the composer:
ModeDirectoryOptions
LocalThe project checkout.Branch: the current one, another one, or New branch from ….
WorktreeA new checkout for this thread.Branch name or detached, base branch, carry uncommitted changes, setup script.
The worktree is created when you send. /worktree new creates one at once; /new worktree starts a new thread in one. Remember saves the choice as the project's default.
The Worktree option with branch, base and setup before the first message.
The Worktree option with branch, base and setup before the first message.
Local refuses a branch switch when the checkout has uncommitted changes, another thread is running there, or another worktree holds the branch. Turn off Local: switching branches per project to prevent switches entirely.

Configure worktrees per project#

Settings → Projects → (project) sets:
  • the worktree folder and branch naming;
  • the setup script, which can install dependencies or copy files such as .env.local. Without one, pi-kit suggests one from the lockfile;
  • Remove the folder after merge back, hand-off or archiving: Ask, Right away, After 7 days or Never.
Open worktrees lists each worktree with its thread and offers Hand off, Merge back and Remove folder. With After 7 days, a worktree you handed off is removed a week later if it is still clean and no thread uses it.

Review changes#

Open Changes and pick a source:
SourceCompares
This threadEach file with its state before the run that first changed it.
Working treeAll uncommitted changes in the checkout.
OutcomeThe recorded diff of a commit, merge or pull request.
pi-kit takes Git snapshots before and after each run and each background-agent turn, and refreshes when HEAD moves. A folder without Git offers Initialise git.
The thread header shows a pill with added and removed lines. Click it to open review mode.
Review mode: source, file picker, progress and a unified diff.
Review mode: source, file picker, progress and a unified diff.
ControlDoes
SourceSwitch between This thread, Working tree and Outcome.
Changed files, ‹ ›Jump to a file or step through them. N of M viewed tracks progress.
Unified / SplitOne column, or Before and After side by side with synchronized scrolling. Narrow windows use Unified.
Find in diff (⌘F)Search the file. Aa matches case.
Open in editorOpen the file. Files above the size limit open only there.
Revert file, Stage allAct on current changes, not on an Outcome.
The same change in the Split layout.
The same change in the Split layout.
Find in diff with seven matches.
Find in diff with seven matches.

Comment and send

Hover a line, click +, write a comment and choose Add to batch. Comments collect until you choose Send comments to pi; they go as one message.

Video walkthrough · English captions

Review file changes

Review file changes

Fictional demo data · Qwen3-TTS · Aiden (English)

Select code in a prepared fictional change, queue comments across two files, and send one feedback batch to pi. File references and selected code stay attached to the conversation.

Snapshots record folder state, not who made each edit. Another thread in the same checkout shows up in the comparison; use a worktree to keep them apart.

Sync with the base branch#

Thread menu → Sync with ‹base›…, or /worktree sync. Choose Merge or Rebase (rebase needs a clean worktree). Conflicts open in review mode with Review conflicts; resolve them and run your checks before merging back.

Merge back or open a pull request#

Thread menu → Merge back…, or /worktree merge. Choose Merge into ‹branch› or Open a pull request. A pull request needs the GitHub CLI (gh), signed in, and a remote. The result appears as an outcome badge on the thread.
Removing the worktree is a separate step. Uncommitted files or another thread using the folder block removal.

Move a thread#

The thread menu offers, where they apply:
ItemDoes
Hand off to local…Move the work from the worktree into the project checkout. This can switch the checkout's branch.
Move into a worktree…Move a Local thread into a new worktree, with all uncommitted changes in that checkout.
Create branch here…Give a detached worktree a branch.
A disabled item explains what blocks it.

Several threads in one repository#

Threads see which files other agents in the repository changed recently. This is advisory: files are not locked. A worktree separates checkouts, not permissions: commands can still reach other folders. Use Sandboxed protection to restrict tools.
See Troubleshooting for branch, placement and cleanup errors.