---
title: Repository cleanup loop
description: Inspect branches, worktrees, commits, and PRs; recover valuable work
  and remove stale state with evidence.
url: https://subramanya.ai/awesome-loops/repository-cleanup-loop/
tags:
- git
- cleanup
- maintenance
---

# Repository cleanup loop

Use this when repo state has become hard to trust.

1. List local branches, remote branches, open PRs, closed PRs, and worktrees.
2. Identify unmerged commits and owners.
3. Recover valuable work by opening or updating PRs.
4. Archive or delete stale branches only after confirming no useful commits remain.
5. Prune unused worktrees and stale remotes.
6. Summarize what was recovered, retained, and removed.

Stop when every remaining branch and PR has a clear owner or purpose.
