How this skill is triggered — by the user, by Claude, or both
Slash command
/stylish-git:cleanup-branchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Clean up branches that have been merged or are no longer needed.
Clean up branches that have been merged or are no longer needed. Handles squash merges correctly and cleans up associated worktrees.
git fetch --prune origingit worktree list to find associated worktreesgh CLI for accurate squash merge detectioncommand -v gh &>/dev/null && gh auth status &>/dev/null
For each local branch (excluding protected), check if its PR was merged:
gh pr list --head <branch> --state merged --json number,title --limit 1
List all non-protected local branches and show to user for manual selection.
Use git branch -D (force delete) since git branch -d cannot detect squash merges.
Branches with no commits in 30+ days and no merged PR:
git for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:relative)' refs/heads/
Before deleting any branch, check for associated worktrees:
git worktree list --porcelain
If a target branch has a linked worktree:
git worktree remove <path> (or --force if dirty)Also detect orphaned worktrees (worktree directory missing):
git worktree prune
git fetch --prune origin to syncgit worktree prune to clean orphaned worktree referencesgh CLI availabilitygh: iterate local branches, check gh pr list --head <branch> --state mergedgh: list all non-protected branches for user selectiongit worktree list --porcelain to find worktrees linked to target branchesgit worktree remove <path>git branch -D <branch>git push origin --delete <branch>Basic cleanup (with gh):
/stylish-git:cleanup-branch
→ Fetching and analyzing branches...
→ Checking merged PRs via GitHub...
→ Found 3 merged branches:
Merged PR (squash/merge):
- feature/add-button (#42)
- feature/fix-header (#38)
- bugfix/typo (#45)
Protected (skipped):
- main
- develop
→ Delete these 3 local branches? (y/n)
→ Deleted 3 branches ✅
With worktree cleanup:
/stylish-git:cleanup-branch
→ Fetching and analyzing branches...
→ Found 2 merged branches:
Merged PR:
- feature/add-button (#42)
- feature/new-page (#50)
Linked worktrees:
- feature/new-page → ~/projects/repo-feature-new-page
→ Delete 2 branches and 1 worktree? (y/n)
→ Removed worktree: ~/projects/repo-feature-new-page
→ Deleted 2 branches ✅
Without gh CLI (fallback):
/stylish-git:cleanup-branch
→ gh CLI not available, showing all non-protected branches
→ Local branches:
1. feature/add-button (3 days ago)
2. feature/old-experiment (30 days ago)
3. bugfix/typo (1 day ago)
→ Enter branch numbers to delete (e.g. 1,2): 1,2
→ Deleted 2 branches ✅
With remote cleanup:
/stylish-git:cleanup-branch --remote
→ Found 5 merged branches:
Local:
- feature/add-button (#42)
- feature/fix-header (#38)
Remote:
- origin/feature/old-feature
- origin/feature/completed-work
- origin/bugfix/fixed
→ Delete 2 local + 3 remote branches? (y/n)
→ Deleted 5 branches ✅
Nothing to clean:
/stylish-git:cleanup-branch
→ Fetching and analyzing branches...
→ No merged branches found ✅
→ Repository is clean
npx claudepluginhub stylelist94/claude-plugins --plugin stylish-gitGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.