From git-workflow
Automates git branch cleanup: inventories local/remote branches, identifies merged/gone candidates, protects main/develop/release/current, confirms deletions, prunes remotes, provides recovery SHAs.
npx claudepluginhub basher83/lunar-claude --plugin git-workflowThis skill uses the workspace's default tool permissions.
Perform a complete cleanup of local and remote branches after working on multiple PRs.
Safely identifies and deletes merged and stale Git branches after fetching latest state, filtering by pattern, and user confirmation via interactive prompts. Protects main branches.
Deletes merged Git branches locally and optionally remotely after user confirmation, flags stale unmerged branches for manual review. Supports dry-run, custom base branch, and inactivity threshold.
Safely analyzes and cleans up local git branches/worktrees: categorizes merged/squash-merged/superseded/active, groups related ones, deletes only after user approval.
Share bugs, ideas, or general feedback.
Perform a complete cleanup of local and remote branches after working on multiple PRs.
Default branch: !git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main"
Current branch: !git branch --show-current
Fetch latest: !git fetch --all --prune 2>&1
Local branches with tracking status:
!git branch --format='%(refname:short) %(upstream:track)' | sort
Recent branches by activity:
!git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(refname:short) - %(committerdate:relative)'
Remote branches:
!git branch -r --format='%(refname:short)' | grep -v HEAD | sort
Merged into default branch: !git branch --merged
Branches with gone remotes:
!git branch -vv | grep ': gone]' | awk '{print $1}' | sort
Never delete branches matching these patterns:
main, master, develop, staging, productionrelease/* branches (unless explicitly confirmed)renovate/* branches (managed by Renovate bot)Review the branch inventory above. Categorize branches:
release/* branches, branches with unpushed commitsPresent the cleanup plan and ask the user to select scope:
If "Review each" is selected, iterate through candidates asking per-branch confirmation.
After confirmation, execute in order:
git remote prune origingit branch -d <branch>git branch -D <branch>Record each branch name and SHA before deleting: git rev-parse <branch>
If deletion fails, ask user: Force delete, Skip, or Abort.
Ask whether to delete corresponding remote branches on origin.
Report:
git checkout -b <branch> <sha>