Skip to content

Patterns

Pattern: repo-cleanup-loop

Repositories accumulate their own kind of clutter — branches nobody deleted, worktrees nobody closed, PRs superseded months ago. Weekly, this kit…

Repositories accumulate their own kind of clutter — branches nobody deleted, worktrees nobody closed, PRs superseded months ago. Weekly, this kit inspects local and remote state and classifies every stale-looking item as current, someone's in-progress work, safe to remove, or genuinely uncertain — and it never suggests discarding uncommitted changes or closing someone else's PR without flagging it for confirmation first.

Quick facts

FieldValue
CategoryA · Repo maintenance
Heartbeatschedule
Cadenceweekly
LevelL1 (report-only)
CostLow
GroupB — Forward Future Loop Library

The six parts

PartThis kit
Heartbeatschedule — weekly
Bodyreads branches, PRs, commits, and worktrees via the SCM CLI and local git state; writes only repo-cleanup-report.md, its own state file, and the run log
Spinerepo-cleanup-loop-state.md — per-item classification (current / owned / safe-to-remove / uncertain) and evidence
Stopping conditionthe source's own, verbatim: "valuable work is recovered and remaining repository state is intentional"
Checkerloop-verifier (read-only) — confirms every "safe to remove" classification actually has supporting evidence, not a guess
Human gatethe source's own explicit rule — "do not delete uncertain work, discard uncommitted changes, or close someone else's pull request without confirmation"

The three valid stops

  • Success — valuable work is recovered and remaining state is intentional, checked against the source's own criteria.
  • Limit — 15 runs or 150k tokens.
  • No progress — 3 consecutive beats with nothing newly flagged → log and stop.

Source: Loop #10, "The repository cleanup loop," from Forward Future's Loop Library, original prompt by Matthew Berman. This kit's L1 goes further than the source's own gate — it deletes nothing at all, regardless of confidence. Full attribution: resources/sources.md.