@thisux/pi-worktree
v1.2.0
Published
Git worktree slash commands for Pi (/worktree ls|add|open|rm|pr)
Maintainers
Readme
@thisux/pi-worktree
Git worktree slash commands for Pi.
Create, list, open, remove, and PR-checkout worktrees without leaving the session.
Layout
~/AGI/mobile/ ← main checkout
~/AGI/mobile-fix-login/ ← worktree for fix/loginSibling folders next to the main repo: <repo>-<branch-slug>.
Install
pi install npm:@thisux/pi-worktreeAlready in a session?
/reloadOne-off try (no settings write):
pi -e npm:@thisux/pi-worktreeUpdate later:
pi update npm:@thisux/pi-worktreeUsage
| 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 |
Create behavior
- 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).
Remove safety
- 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
PR checkout
Needs GitHub CLI (gh) authenticated.
/worktree pr 42Fetches pull/42/head and creates a worktree on the PR head branch.
Notes
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.tsEnable/disable via
pi config. Confirm withpi list.
Links
Release flow
Same automation as @thisux/pi-double-esc-clear:
- 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).
License
MIT · ThisUX
