cleanup-brancheslisted
Install: claude install-skill thettwe/nyann
# cleanup-branches
Wraps `bin/cleanup-branches.sh`. Lists local branches whose tip is
reachable from the base branch (`main` / `develop` / wherever the
profile points), then either previews the list or actually deletes
them with `git branch -d` (safe — refuses unmerged work).
Mirrors the same preview-then-mutate contract as `undo` and
`migrate-profile`: nothing is deleted unless the caller passed
`--yes` AND `--dry-run` was absent.
## 1. Run the preview
Always invoke without `--yes` first:
```
bin/cleanup-branches.sh --target <cwd>
```
Output is a CleanupBranchesResult JSON (see
`schemas/cleanup-branches-result.schema.json`). Show the user:
- The base branch the merge check ran against (`base_branch`).
- The list of candidates (`candidates[]`), one per merged branch,
with last-commit timestamp + short SHA so they can sanity-check.
- The total count from `summary.candidates_count`.
- The recovery hint: re-run with `--yes` to delete.
If `summary.candidates_count == 0`, tell the user there's nothing
to clean up and exit. Don't prompt.
## 2. Confirm and apply
Ask: "Delete N merged branch(es)?" — list the names if there are 5
or fewer, or summarise if more. On confirmation:
```
bin/cleanup-branches.sh --target <cwd> --yes
```
The script uses `git branch -d` (lowercase d, the safe form) so even
if a candidate's merge state changed between the preview and the
apply, git will refuse the unsafe delete and the entry lands in
`errors[]` instead of `deleted[]`. Surface any