From claude-coding
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.
npx claudepluginhub gupsammy/claudest --plugin claude-codingThis skill is limited to using the following tools:
Safely remove merged and stale git branches with confirmation.
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.
Automates git branch cleanup: inventories local/remote branches, identifies merged/gone candidates, protects main/develop/release/current, confirms deletions, prunes remotes, provides recovery SHAs.
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.
Safely remove merged and stale git branches with confirmation.
0. Parse arguments
If $ARGUMENTS provided, treat it as a glob pattern to filter branch candidates (e.g., feature/* shows only feature branches). Pass it to the candidate script in Step 2.
1. Fetch latest state
git fetch --all --prune
If fetch fails (no remotes configured), note remote data is unavailable and continue with local analysis only.
2. Identify candidates
Run the candidate detection script, passing the optional pattern filter:
bash ${CLAUDE_PLUGIN_ROOT}/skills/clean-branches/scripts/find-candidates.sh "$PATTERN"
The script outputs two labeled sections (=== MERGED === and === STALE ===), one branch per line. Parse each section into its own list.
3. Present results
Display branches in three groups: merged (safe to delete), stale (no recent commits), and protected (never touch). If both candidate lists are empty, report "No branches to clean" and stop — do not proceed to Step 4.
4. Confirm before deletion
Use AskUserQuestion with concrete options derived from the candidates found. Structure:
Never proceed to deletion without explicit user confirmation through AskUserQuestion.
5. Execute deletion
Delete only what the user confirmed:
git branch -d <branch-name>
Use -d (not -D) because -d refuses to delete branches with unmerged commits — git itself enforces the safety check.
If the user explicitly requests remote cleanup:
git push origin --delete <branch-name>
Remote deletion requires explicit user request — never delete remotes unless the user says so directly.
-d not -D to preserve git's unmerged-commit safety checkSummary of actions taken: