Clean out stale repo state
Audit branches, PRs, commits, and worktrees; rescue anything valuable; then delete what's provably stale.
Use this when
Use this when abandoned branches, old worktrees, unclear pull requests, or unmerged commits make it difficult to know which repository state still matters.
How it runs
- Inventory local and remote branches, open and recently closed pull requests, unmerged commits, and registered worktrees.
- Classify each item as current, valuable but unfinished, superseded, merged, abandoned, or uncertain, recording evidence and ownership.
- Recover valuable changes into an appropriate current branch before removing any stale reference.
- Clean only proven stale state, fetch and prune safely, then rerun the inventory until every remaining item is intentional.
Done when
✓ Valuable work is recovered and remaining repository state is intentional. Branches, pull requests, commits, and worktrees are current, owned, or safely removed with evidence.
Why it works
Inventory and classification separate recoverable work from clutter before cleanup begins. Repeating the inventory proves the repository is organized instead of merely smaller.
Implementation note
Do not delete uncertain work, discard uncommitted changes, or close someone else's pull request without confirmation. Preserve evidence for every destructive cleanup action.
More refactoring loops
Migrate an API import by import
Sweep a codebase from a legacy API to its v2 replacement with tests and typecheck as the safety net, capped at 30 turns.
Dead code elimination
Hunt down unreferenced exports, unused files, and unreachable branches, deleting them in small verified steps until the analyzer reports clean.
Tidy code, one safe change at a time
Prove one small cleanup is safe, make the smallest useful change, and keep it only after existing checks pass.