Repo Cleanup Loop

Recovers valuable unmerged work and prunes stale branches and PRs until the repository is tidy.

WorkflowengineeringMIT1 source files

Before you use this component

This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.

Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.

Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.

Source publisher
Claude Code Templates
Creator supplied by source
Not listed in source
Pinned source version
a344359459263d73d8948651c789244093c02e4e
License evidence
LICENSE

Source preview

cli-tool/components/loops/engineering/repo-cleanup-loop.md

---
name: repo-cleanup-loop
description: Recovers valuable unmerged work and prunes stale branches and PRs until the repository is tidy.
category: engineering
interval: 7d
stop-condition: No stale branches or abandoned PRs remain and any salvageable work has been captured.
components: [command:git-workflow/branch-cleanup, agent:git/git-workflow-manager, skill:git/git-context-controller]
tags: [git, maintenance, cleanup, loop]
---

# Repository Cleanup Loop

> **Loop Engineering** — a recurring janitor that keeps the repo's branch and PR list honest without deleting anything valuable.

## 🎯 Goal
Find stale branches and abandoned PRs, **recover** any work worth keeping (extract to an issue or fresh branch), and safely remove the rest.

## ⏱️ Schedule
Suggested interval: `7d` (weekly). Because this loop can delete branches, keep the cadence slow and review its actions.

## ▶️ Run it
```
/loop 7d "Scan branches and PRs. For each stale one, decide: salvage valuable work into an issue/branch, or delete if fully merged or abandoned. Never lose unmerged work. Continue until the branch and PR list is clean."
```

## 🔁 Iteration steps
1. **Perceive** — list branches/PRs by last activity with `git-context-controller`.
2. **Reason** — classify each: merged, abandoned, or contains salvageable work.
3. **Plan** — decide salvage vs delete for the oldest item.
4. **Act** — salvage to an issue/branch, then prune with `/branch-cleanup`; the `git-workflow-manager` agent guides safe operations.
5. **Observe** — confirm nothing valuable was lost; continue down the list.

## 🛑 Stopping condition
No stale branches or abandoned PRs remain and all salvageable work is captured.

## 🧩 Referenced components
- `command:git-workflow/branch-cleanup` — prunes merged/stale branches.
- `agent:git/git-workflow-manager` — guards safe git operations.
- `skill:git/git-context-controller` — inspects branch/PR history.

## 💡 Example
A six-month-old `spike/new-parser` branch holds a useful prototype; the loop extracts it into an issue with the diff attached, then deletes the branch.

Preview capped at 60,000 characters. Download the bundle for every original file and notice.

Read the redistribution license
MIT License

Copyright (c) 2025 Daniel (San) Ávila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Bundle SHA-256: 92658f48a56d1c8855fd67e8f597c6c7407228c6c816360160554fd9fcd58599. Files are served as downloads and are never executed by this page.