/git-hygiene:worktree-hygiene [status | create | activate | relocate | cleanup | finish]from git-hygiene
Inspects, creates, relocates, finishes, or removes linked Git worktrees through deterministic checks. Use when the user asks to create an isolated worktree, clean up worktrees, explain duplicate project folders, move branch checkouts out of a project directory, or show which worktrees are finished. Never moves, unlocks, or removes a worktree without exact-path approval.
Ships in git-hygiene. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You manage linked worktrees without deciding their safety yourself. The script at
scripts/worktrees.js owns discovery, placement, classification, and every
mutation precondition. Carry its state and reason through unchanged. Unknown
evidence means keep.
This skill never deletes branches. After a worktree is removed, the branch stays
available for stale-branches to review separately.
status: inspect worktrees without changing anything.create: create or open an isolated checkout at <worktreeRoot>/<repo>/<task>.activate: lock an existing linked checkout as active agent work.relocate: move an existing clean, unlocked worktree to its configured path.cleanup: remove only worktrees classified merged after exact-path approval.finish: unlock one clean worktree after the user confirms no session is using it.If no route was named, infer it from the request. A request about duplicate project
folders means status first, not cleanup.
For the current repository:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js audit --repo "$PWD" --json
For every configured project root:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js audit --all-configured --json
If worktreeLocation is not configured, the current-repository form still works.
Global discovery and canonical placement stay off until /git-hygiene:setup has
run.
Group the result by state. Show the exact path, branch, reason, and whether the
script marked it removable or relocatable. A partial audit carries
truncated: true; report that the audit is incomplete and offer nothing for
cleanup from it.
If errors lists repositories that could not be read, name them and say the
counts leave them out. Each removal still re-checks its own path, so cleanup in
the repositories that were read can go ahead.
Read the configuration first:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/configure-worktree-location.js --show
If it is absent or invalid, route to /git-hygiene:setup. Do not guess a project
root or use a visible sibling path.
Show the computed destination before creating anything:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js destination --repo "<repository>" --branch "<branch>"
The task folder defaults to the branch name with slashes turned into dashes and
any other character outside letters, digits, -, _, . and ~
percent-encoded, so fix/a+b becomes fix-a%2Bb. If
the user names the task differently, add --task "<name>" to this command and to
create, and use the same name in both. The script refuses a destination that
already exists rather than picking another name.
Ask for approval if the branch does not already exist. If it exists on exactly
one remote but not locally, omit --base; the script creates a local tracking
branch at that remote tip. For a truly new branch, show the chosen base and,
after approval, create it:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js create --repo "<repository>" --branch "<branch>" --base "<base>" --approved
For an existing branch, omit --base; the script opens that branch rather than
creating another. The resulting worktree is locked as active agent work. Report
its exact path and lock state.
Run status first. Show the exact path and branch, then ask before marking that one existing linked checkout as active agent work. After approval:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js activate --path "<exact path>" --approved
The script refuses the primary checkout, an unregistered path, and a worktree that is already locked. Activation does not move files or change a branch; it adds the lock that prevents cleanup while an agent owns the checkout.
Run status first. Offer only entries whose returned relocatable value is true.
Show the exact current path and computed destination, then ask before moving that
one path. After approval:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js move --path "<exact path>" --approved
The script refuses primary, dirty, locked, detached-review, or already managed worktrees. It also refuses the caller's current working directory. Never add force or substitute another path after approval.
Run a complete audit. Offer only entries whose returned state is merged and
whose removable value is true. Show exact paths and branches, and say that the
branches will remain.
Ask which exact paths to remove. Approval for one path does not apply to another. For each approved path, run the verifier and then the removal separately:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js verify-remove --path "<exact path>"
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js remove --path "<exact path>" --approved
The remove command repeats the verification immediately before Git removes the
worktree. If either command refuses, report its reason and leave that path alone.
Never use rm, git worktree remove --force, or a batch command.
After removal, offer stale-branches if the user also wants the surviving branch
labels reviewed. Do not invoke branch cleanup automatically.
Missing registrations use Git's repository-wide prune operation, not worktree
removal. Show every exact missing path in that repository and ask the user to
approve the complete set. Approval of only some paths must be reported as a
refusal because Git cannot prune one registration by path. Then run the dry-run
verifier and governed prune separately:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js verify-prune --repo "<repository>" --path "<exact missing path>"
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js prune --repo "<repository>" --path "<exact missing path>" --approved
Repeat --path for every approved missing registration. The command re-checks
that the approved set is exactly the set Git can prune, never removes a working
directory, and preserves branches.
Finishing means making an active worktree eligible for later review. It does not remove it. Confirm the exact path and ask the user to confirm that no session is still using it. Then run:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js finish --path "<exact path>" --approved
For a path that still exists, the script refuses a dirty, unreadable, primary, already unlocked, or current working directory. After it succeeds, run status again and report the new classification. Cleanup still requires its own approval.
A locked registration may remain after its working directory disappears. It
stays locked, not missing, until the lock is deliberately cleared. After the
same ownership confirmation, finish it by naming the primary checkout as well:
node "${CLAUDE_PLUGIN_ROOT}"/scripts/worktrees.js finish --repo "<primary checkout>" --path "<exact absent path>" --approved
Run status again. The unlocked registration can then become missing and use
the separately approved prune flow.
dirty, locked,
open, unique, detached-review, or unknown as removable based on
conversation or age.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sarahcallmesmadds/infra-plugins --plugin git-hygiene4 skills in this plugin
/merge-strategyRecommends squash-and-merge, rebase-and-merge, or a merge commit for the branch in front of you, based on its actual commits, whether the branch is shared, and whether its history is already public. Use when the user asks which merge method to use, whether to squash or rebase, how to merge a pull request, or invokes /merge-strategy. Read-only: it recommends and explains; it never merges, rebases, pushes, or deletes./setupSets up Git Hygiene's optional project worktree location guard by choosing the project and worktree folders and writing them to user-owned configuration. Use when the user asks to configure or enable the worktree location guard, or invokes /git-hygiene:setup./Other plugins' skills for the same job