Loop 012
The repository cleanup loop
A repository-hygiene workflow that audits branches, pull requests, commits, and worktrees, recovers valuable changes, and removes proven stale state.
Ready-to-use prompt
Copy the loop
Inspect local and remote branches, pull requests, commits, and worktrees. Recover valuable work and clean everything stale until the repository is current and organized.
Verify / stop
Valuable work is recovered and remaining repository state is intentional.
Branches, pull requests, commits, and worktrees are current, owned, or safely removed with evidence.
Context and guidance When to use it, steps, safety notes, and related loops
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 to run it
- 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.
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.