/git-flow:cleanup-gitfrom git-flow
Removes merged local branches and stale git worktrees. Invoked by "cleanup branches", "prune worktrees", or "tidy git".
Ships in git-flow. 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.
Read when SKILL.md points to them; scripts run unread.
Use the target repo's own scripts/cleanup-git.sh if it ships one, otherwise this skill's script. Inspect a repo-provided script before relying on its safety policy. Use direct deletion only for a specifically approved exception described below; never pipe a branch list into force-delete.
scripts/cleanup-git.sh # preview (default)
scripts/cleanup-git.sh --apply # execute the requested safe cleanup
scripts/cleanup-git.sh --apply --force --branch <name> # approved ahead-commit loss
scripts/cleanup-git.sh --base <ref> # override base detection
The script fetches and prunes remotes. It prefers the fetched remote default branch, then remote main, master, trunk, develop, or dev, then local fallbacks. --base overrides this choice.
A branch or its worktree is a candidate when one of these holds:
PR merged: GitHub confirms the PR in the target repository and base, and its merge commit is reachable from the base. This catches squash, conflict-resolved squash, and rebase merges; ahead commits count only past the PR head.merged: the branch is an ancestor of the base.squash merged: the complete branch patch is equivalent to a commit in the base. This works offline without gh; conflict resolution can prevent equivalence.upstream gone: only a candidate signal, not merge proof. Unique commits still keep the branch.It prunes worktree registrations whose directory is gone (git worktree prune) before listing, so a stale entry does not keep its branch forever. It removes a detached worktree when its HEAD is merged or squash-merged into the base and the tree is clean; an unmerged, dirty, locked, or current detached worktree stays.
It skips the current worktree, current branch, base, and main/master/trunk/develop/dev. It keeps locked worktrees and worktrees with tracked, untracked, or ignored files, or unknown status. It keeps candidates with ahead commits or unknown ahead counts unless --force --branch <name> is passed for one approved target. No proof prints skip ... (active); do not treat that as proof of unmerged work.
--apply for verified safe candidates. Run it without another confirmation; kept objects do not block safe removals. For a preview-only request, do not apply.Stop if the directory is not a git repo. If no base is found, ask for --base <ref>. A fetch failure makes the preview use stale refs (say so) and makes --apply refuse.
After explicit user consent, recheck the tip and file list. If either changed,
ask again. For one worktree, use the using-git-worktrees cleanup script with
--force <branch>. For a branch-only exception, or a hook-blocked direct
cleanup, use the command-local marker:
git -c cc-thingz.cleanupApproved=<full-tip-oid> worktree remove --force <exact-path>
git -c cc-thingz.cleanupApproved=<full-tip-oid> branch -D <exact-branch>
Use separate commands, worktree first. The marker must match the current tip.
It does not authorize protected/current/locked worktrees, other branches,
reset --hard, clean, or force-push. Never save it with git config,
invent user consent, or use bulk --force when only one exception was approved.
The marker pins only the commit, not file contents; the agent must recheck
files immediately before executing. This is a consent attestation by the agent,
not cryptographic proof that the user approved; the hook is a mistake guard, not a security sandbox.
GIT CLEANUP
Status: PREVIEW | APPLIED | BLOCKED
Base: <ref>
Remove: <branch/worktree> — <reason>
Keep: <branch/worktree> — <reason and decision needed>
Verification: <command> — pass/fail/not run
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alexei-led/cc-thingz --plugin git-flow3 skills in this plugin
/configuring-git-hygieneConfigure safe git workflow hygiene: pre-commit/pre-push hooks, Gitleaks secret scanning, .gitignore rules, local git config, and guardrails. Use when setting up git hooks, gitleaks/git leaks, staged pre-commit checks, pre-push validation, core.hooksPath, .gitignore, or git config best practices. NOT for creating commits (use committing-code), cleaning branches/worktrees (use cleanup-git), or creating worktrees (use using-git-worktrees)./using-git-worktreesCreates and removes isolated git worktrees for parallel development. Use when starting feature work needing isolation, working on multiple branches simultaneously, or removing one specific worktree and its branch after its PR merges. NOT for simple branch switching, sweeping multiple stale worktrees or merged branches at once (use cleanup-git), or git hook/config setup (use configuring-git-hygiene).Other plugins' skills for the same job