Imported from ahmedelgabri/git-wt (
skills/git-wt/SKILL.md). Install upstream withnpx skills add ahmedelgabri/git-wt --skill git-wt. Copyright stays with the author.
git-wt
Use this skill when the user asks to manage Git worktrees with git-wt or when
a repository uses the bare worktree layout: Git data lives in .bare, .git is
a file pointing at ./.bare, and branch worktrees are sibling directories.
Detecting git-wt repositories
-
From any directory in the repo, run:
git rev-parse --git-common-dirIf the result ends in
.bare, treat the repo as agit-wtbare worktree layout. -
If you are at a repository root, a
.gitfile containinggitdir: ./.bareand a.baredirectory are also strong signals. -
If uncertain, run:
git wt doctor
Operating rules for agents
- Prefer
git wt(orgit-wt) over rawgit worktreecommands in agit-wtlayout so path resolution, fetching, branch cleanup, and safety prompts stay consistent. - Prefer explicit, non-interactive commands. Avoid bare
git wt add,git wt remove, andgit wt switchin automation because they may openfzfpickers or prompts. git wt addprints the absolute created worktree path onstdout. Capture that path if you need tocdinto the new worktree. Human progress and prompts are written tostderr.- Use dry-runs before destructive cleanup. Only delete remote branches when the user explicitly asks for remote deletion.
DEBUG=1before a mutating command prints the underlyinggitoperations instead of executing them.
Common commands
Inspect repository health and worktrees:
git wt doctor
git wt status
git wt list
git wt list --porcelain
Clone or migrate repositories:
git wt clone <url> [folder]
git wt migrate --dry-run
git wt migrate
Create worktrees with explicit arguments:
git wt add feature origin/feature
git wt add -b new-feature new-feature
git wt add --detach hotfix HEAD~5
Update the default branch worktree:
git wt update
Switch worktrees:
-
For an interactive human workflow, use:
cd "$(git wt switch)" -
For an agent workflow, inspect
git wt listoutput andcdto the exact worktree path instead of invoking the interactive switch picker.
Remove worktrees safely:
git wt remove feature --dry-run
printf 'y\n' | git wt remove feature
git wt remove --sweep --dry-run
printf 'cleanup\n' | git wt remove --sweep
Remote branch deletion is destructive. Use it only when explicitly requested, and confirm with the branch name expected by the prompt:
git wt remove feature --delete-remote --dry-run
printf 'feature\n' | git wt remove feature --delete-remote
Suggested workflow
- Inspect first with
git wt doctor,git wt status, orgit wt list. - Explain the planned operation when it will create, remove, or migrate worktrees.
- Prefer a dry-run or
DEBUG=1preview where available. - Execute the explicit
git wtcommand. - Report created paths, removed branches, and any follow-up command the user should run.