Git worktree slash commands for Pi.
Create, list, open, remove, and PR-checkout worktrees without leaving the session.
~/AGI/mobile/ ← main checkout
~/AGI/mobile-fix-login/ ← worktree for fix/login
Sibling folders next to the main repo: <repo>-<branch-slug>.
pi install npm:@thisux/pi-worktreeAlready in a session?
/reload
One-off try (no settings write):
pi -e npm:@thisux/pi-worktreeUpdate later:
pi update npm:@thisux/pi-worktree| Command | What it does |
|---|---|
/worktree |
List worktrees; pick one to copy path |
/worktree ls |
Same as above |
/worktree <branch> |
Create worktree for branch |
/worktree add <branch> |
Same as above |
/worktree open <branch> |
Show path (+ copy on macOS) |
/worktree rm <branch> |
Remove worktree (keeps branch; confirms) |
/worktree pr <number> |
Fetch PR via gh, create worktree |
/worktree help |
Show help |
- Local branch exists → attach worktree to it
- Else remote
origin/<branch>→ track it - Else new branch off default (
origin/main/main/master)
Path already taken by that branch → shows existing path (copied).
- Refuses main worktree
- Refuses locked worktrees
- Always confirms
- Dirty tree needs a second confirm before
--force - Branch is kept; only the worktree directory is removed
Needs GitHub CLI (gh) authenticated.
/worktree pr 42
Fetches pull/42/head and creates a worktree on the PR head branch.
-
Must be inside a git repo.
-
Never force-pushes, hard-resets, or
clean -fdx. -
Prefer the package over a hand-copied
~/.pi/agent/extensions/git-worktree.ts— remove the loose file so it doesn't load twice:rm -f ~/.pi/agent/extensions/git-worktree.ts -
Enable/disable via
pi config. Confirm withpi list.
- Land PRs on
mainwith conventional commits (feat:,fix:,docs:, …). - release-please opens a release PR (version bump +
CHANGELOG.md). - Merge the release PR → GitHub Release/tag → CI runs
bun publish.
Manual republish: Actions → Release → Run workflow (pass an existing tag).
Needs repo secret NPM_TOKEN (npm automation token allowed to publish under @thisux).
Copyright © 2026 THISUX Private Limited.
Released under the MIT License. You may use, modify, and distribute this project for personal and commercial purposes, provided the copyright and permission notice are retained.