/ghp:cleanup — Clean Up Stale Artifacts
Scans for stale branches, dead milestones, and orphaned issues. Always asks the user before taking action.
Flow
Scan remote branches:
git fetch --prune git branch -r --list 'origin/m*'For each remote branch, check if the linked issue is still open. Categorize:
- Stale: issue is closed but branch still exists
- Orphaned: no issue found for this branch
- Active: issue is open
Scan local branches:
git branch --list 'm*'Check for local branches whose remote tracking branch is gone (
[gone]).Scan milestones:
gh milestone list --state openFor each open milestone, check if all issues are closed. Flag milestones that should be closed.
Scan for stale issues (optional — ask the user first since this is slower):
- Check open issues for references to files, functions, or classes that no longer exist in the codebase
- Tag stale issues with
needs-revision
Present findings to the user, grouped by category:
Stale branches (issue closed, branch exists): m5/34-improve-init-flow — #34 closed m3/12-old-feature — #12 closed Local-only branches (remote deleted): m4-script-test [gone] Milestones ready to close (all issues done): Milestone 3 - GHP Improvements (3/3 closed) Stale issues (references deleted code): #9 — references `scripts/organize.sh` (deleted)Ask the user via
AskUserQuestionfor each category what to do:Category Options Stale branches Delete both / Delete remote only / Delete local only / Keep Local-only branches Delete / Keep Milestones Close / Keep open Stale issues Tag needs-revision/ Close / KeepExecute the user's choices and report what was done.