safe-cleanup
Installation
SKILL.md
Safe Cleanup — Tidy Stale Local Branches (Phase 5)
Remove the per-slice feat/<feature>/<NN>-<slice> branches that pile up after slices ship — safely. Same posture as safe-pr: report first, confirm before deleting, never force away unmerged work, keep everything recoverable. Scope is LOCAL branches only by design; this skill never deletes anything on the remote.
The deterministic classification (cross-referencing git merge status and gh PR state) lives in scripts/classify-branches.mjs. It defaults to dry-run and deletes nothing without --apply --yes plus the category you approve.
What counts as what
| Bucket | Meaning | Default action |
|---|---|---|
| merged | Commits already in the base (ancestor), or PR merged and git cherry confirms every commit is present in the base |
Eligible to delete (after you confirm) |
| ahead-of-merged-pr | PR merged, but the branch carries extra commits not in the base (reused branch name, or commits pushed after the merge) | Never delete — report only |
| abandoned | PR was closed without merging — carries commits not in the base | Delete only if the user explicitly opts in; recoverable via reflog / the log only |
| open-pr | Has an open PR — active work (wins even if the branch is an ancestor of the base) | Never delete |
| local-only | Unmerged local commits, no PR (possible WIP) | Never auto-delete — report only |
| protected | base / main/master/develop/release, the current branch |
Never delete |
If gh or the remote is unavailable, PR-based buckets (squash-merged, abandoned) can't be detected — only git-merged branches are eligible, and the report says so. That is the safe default.