| name | jb-worktree |
| description | Use when creating, switching, bootstrapping, or cleaning Git worktrees with wtp. |
| homepage | https://github.com/satococoa/wtp |
| metadata | {"clawdbot":{"emoji":"🌳","requires":{"bins":["wtp"]},"install":[{"id":"brew","kind":"brew","formula":"satococoa/tap/wtp","bins":["wtp"],"label":"Install wtp (brew)"}]}} |
| skill_author | bjesuiter |
wtp Git Worktrees
Based on satococoa's wtp workflow: https://dev.to/satococoa/wtp-a-better-git-worktree-cli-tool-4i8l
Use wtp instead of raw git worktree when you want predictable paths, easier branch handling, setup hooks, and fast navigation.
Why use it
wtp init creates a starter .wtp.yml in the repo root
wtp add feature/auth creates ../worktrees/feature/auth automatically
wtp add can create or reuse local/remote branches
.wtp.yml can copy .env, create symlinks, and run bootstrap commands
wtp cd and wtp exec make navigation and command execution easier
wtp remove --with-branch cleans up both the worktree and its branch
Install
brew install satococoa/tap/wtp
Alternative:
go install github.com/satococoa/wtp/v2/cmd/wtp@latest
Quick start
wtp init
wtp add feature/auth
wtp add -b feature/new-ui
wtp add -b hotfix/login origin/main
wtp list
wtp cd feature/auth
wtp cd @
wtp exec feature/auth -- npm test
wtp remove feature/auth
wtp remove --with-branch feature/auth
Agent workflow
When the user asks to work in a separate branch or isolated checkout:
- Check whether the repo already has
.wtp.yml; if not, prefer wtp init
- Inspect repo lockfiles before editing hooks:
- if
bun.lock or bun.lockb exists, use bun install
- if
pnpm-lock.yaml exists, use pnpm install --frozen-lockfile
- otherwise, if the repo has a
package-lock.json and no Bun lockfile, use pnpm install by default, and prefer pnpm install --frozen-lockfile when reproducibility matters
- Check the current worktrees with
wtp list
- Create or open the target worktree with
wtp add ...
- Run commands inside it with either:
cd "$(wtp cd <name>)" && ...
wtp exec <name> -- <command>
- When the work is done and merged, clean up with
wtp remove --with-branch <name>
Prefer:
wtp add -b <branch> for new work
wtp add <branch> when the branch already exists locally or remotely
wtp exec <name> -- <command> for one-off commands
Avoid force removal of dirty worktrees unless the user explicitly asks.
wtp init
Use this first in repos that do not have a config yet:
wtp init
It creates .wtp.yml in the repository root with a starter configuration and example hooks. If .wtp.yml already exists, wtp init errors instead of overwriting it.
Recommended .wtp.yml
wtp init gives you a starter file. Customize the post_create install command based on the repo lockfile:
bun.lock or bun.lockb present → bun install
pnpm-lock.yaml present → pnpm install --frozen-lockfile
- otherwise,
package-lock.json present and no Bun lockfile → pnpm install by default, or pnpm install --frozen-lockfile for stricter reproducible installs
Example for a Bun repo:
version: "1.0"
defaults:
base_dir: "../worktrees"
hooks:
post_create:
- type: copy
from: ".env"
to: ".env"
- type: symlink
from: ".bin"
to: ".bin"
- type: command
command: "bun install"
- type: command
command: "npm run db:setup"
Example for a repo with pnpm-lock.yaml:
version: "1.0"
defaults:
base_dir: "../worktrees"
hooks:
post_create:
- type: copy
from: ".env"
to: ".env"
- type: symlink
from: ".bin"
to: ".bin"
- type: command
command: "pnpm install --frozen-lockfile"
- type: command
command: "npm run db:setup"
Example for a repo with a pure package-lock.json setup:
version: "1.0"
defaults:
base_dir: "../worktrees"
hooks:
post_create:
- type: copy
from: ".env"
to: ".env"
- type: symlink
from: ".bin"
to: ".bin"
- type: command
command: "pnpm install"
- type: command
command: "npm run db:setup"
This is especially useful for repos that need local env files, shared tool directories, or bootstrap commands in every new worktree.
Shell integration
For interactive shells, enable completions and navigation hooks:
eval "$(wtp shell-init zsh)"
Then wtp cd feature/auth can switch directly in the shell, and interactive wtp add can auto-switch into the new worktree.
Useful patterns
wtp cd @
wtp exec @ -- npm test
wtp remove --force feature/auth
wtp remove --with-branch --force-branch feature/auth
Notes
- Default generated paths are based on branch names under
../worktrees
- Remote-only branches are tracked automatically when unambiguous
- If multiple remotes contain the same branch name, create a local tracking branch first
wtp cd is also useful in scripts because it prints the resolved absolute path