# Repo cleanup loop

> Repo cleanup loop is an open-source agent skill for developer tools. Runs a weekly, evidence-gated sweep that classifies and tidies branches, PRs and worktrees. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/ivy00johns/Skill-Madness/tree/main/skills/loops/repo-cleanup-loop
- **Repository:** https://github.com/ivy00johns/skill-madness
- **GitHub stars:** 12
- **License:** MIT
- **Skill name:** repo-cleanup-loop
- **Collection:** https://github.com/ivy00johns/Skill-Madness
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

Repo Cleanup Loop is a recurring hygiene routine for a git repository. Each pass scans local and remote branches, open pull requests, commit trails and worktrees, then assigns every item to a classification that starts as unreviewed until evidence confirms it. Valuable work that sits outside the default branch is recovered first, for example by saving it under a recovery ref and logging where it went, and only then becomes eligible for removal. Each pass removes one class of safely removable items, then re-scans the whole state.

The skill is built on the loop-controller guardrails and delegates the post-merge branch and worktree cleanup to the git-post-merge-cleanup skill rather than reimplementing it. It keeps an inventory file, a recovery log and a pass cap, and it stops for a human on ambiguous items such as squash-merged branches that show as unmerged or worktrees with uncommitted changes. It never force-deletes unmerged work.

It expects a git repository and the gh command-line tool for pull request listing. It is meant to be triggered deliberately with a weekly schedule or a direct command, and it is intended for Claude Code.

## When your agent uses it

> Weekly repo hygiene: classify every branch, PR and worktree, recover valuable work first, then remove one class of stale items with evidence. HITL on anything ambiguous; never force-deletes unmerged work. Broader and recurring; one-off post-merge cleanup is git-post-merge-cleanup. Trigger on "weekly repo hygiene", "clean up the repo weekly", "scheduled repo cleanup".

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ivy00johns/Skill-Madness/tree/HEAD/skills/loops/repo-cleanup-loop)
- [Asks for: Read, Edit, Bash, Grep, Glob](https://github.com/ivy00johns/Skill-Madness/blob/HEAD/skills/loops/repo-cleanup-loop/SKILL.md)
- [License: MIT](https://github.com/ivy00johns/Skill-Madness/tree/HEAD/skills/loops/repo-cleanup-loop)

## Features

- **Whole-repo inventory:** Classifies every branch, open pull request and worktree into a per-item record that starts unreviewed.
- **Recover before delete:** Salvages commits that exist only on unmerged branches and logs where they were saved before any removal.
- **One class per pass:** Removes a single category of safely removable items each pass, then re-scans the full repository state.
- **Delegated post-merge cleanup:** Hands merged-branch, gone-ref and stale-worktree handling to the git-post-merge-cleanup skill.
- **Human checkpoints:** Pauses on ambiguous items such as stale PRs with local work, long-lived shared branches and dirty worktrees.
- **Loop safety caps:** Applies pass limits, no-progress detection and budget ceilings to keep scheduled runs bounded.

## Good for

- Run a weekly cleanup of merged and stale branches across the repository
- Check which open pull requests have no recent activity and flag them for review
- Find worktrees with uncommitted changes and list them without deleting anything
- Save unmerged branch commits to a recovery ref before pruning old branches
- Set up a scheduled repository hygiene check that reports what it changed

## Install

### Claude Code

This skill ships in the `skill-madness` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ivy00johns/Skill-Madness
/plugin install skill-madness@skill-madness
```

Or copy only this skill to `~/.claude/skills/repo-cleanup-loop`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/repo-cleanup-loop &&
cp -R "$tmp/skills/loops/repo-cleanup-loop" ~/.claude/skills/repo-cleanup-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/repo-cleanup-loop` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/repo-cleanup-loop` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/repo-cleanup-loop &&
cp -R "$tmp/skills/loops/repo-cleanup-loop" ~/.agents/skills/repo-cleanup-loop &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/repo-cleanup-loop` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/repo-cleanup-loop` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/repo-cleanup-loop &&
cp -R "$tmp/skills/loops/repo-cleanup-loop" ~/.cursor/skills/repo-cleanup-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/repo-cleanup-loop` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ivy00johns/Skill-Madness.git --path skills/loops/repo-cleanup-loop
```

Or copy the folder to `~/.gemini/skills/repo-cleanup-loop` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/repo-cleanup-loop`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/repo-cleanup-loop &&
cp -R "$tmp/skills/loops/repo-cleanup-loop" ~/.copilot/skills/repo-cleanup-loop &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/repo-cleanup-loop` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git
```

Then copy `Skill-Madness/skills/loops/repo-cleanup-loop` into your agent's skills folder as `repo-cleanup-loop`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Repo cleanup loop delete unmerged work?

No. It never force-deletes unmerged work, does not use force pushes or forced worktree removal on unmerged work, and recovers valuable commits before any removal.

### Is Repo cleanup loop the same as git-post-merge-cleanup?

No. The post-merge skill is a one-off tidy after merges. This skill is a recurring, whole-repository loop that covers pull requests and commit trails too, and it delegates the branch and worktree cases to the post-merge skill.

### How is Repo cleanup loop triggered?

It is user-driven and disables automatic model invocation. You run it weekly with a loop or schedule command, or invoke it directly by name.

### What does Repo cleanup loop need to run?

It uses Read, Edit, Bash, Grep and Glob tools, the git command line, and gh for listing pull requests. It requires Claude Code and a starter plan or higher.

### How do I install Repo cleanup loop in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/repo-cleanup-loop to use it in all your projects, or to .claude/skills/repo-cleanup-loop in one project. Or install the skill-madness plugin, which includes it: /plugin marketplace add ivy00johns/Skill-Madness, then /plugin install skill-madness@skill-madness.

### Does Repo cleanup loop run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Repo cleanup loop?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Repo cleanup loop?

The closest alternatives to Repo cleanup loop are Git post merge cleanup, Self healing loop, Git branch cleanup, Git clean worktrees and Review workflow.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Git post merge cleanup](https://ai-powered.com/skills/git-post-merge-cleanup): Git post merge cleanup is an open-source agent skill for developer tools.
- [Self healing loop](https://ai-powered.com/skills/self-healing-loop): Self healing loop is an open-source agent skill for developer tools.
- [Git branch cleanup](https://ai-powered.com/skills/git-branch-cleanup): Git branch cleanup is an open-source agent skill for developer tools.
- [Git clean worktrees](https://ai-powered.com/skills/git-clean-worktrees): Git clean worktrees is an open-source agent skill for developer tools.
- [Review workflow](https://ai-powered.com/skills/review-workflow): Review workflow is an open-source agent skill for developer tools.
- [Code reachability audit](https://ai-powered.com/skills/code-reachability-audit): Code reachability audit is an open-source agent skill for developer tools.
- [Check a stale branch is not undoing newer main work](https://ai-powered.com/skills/check-a-stale-branch-is-not-undoing-newer-main-work): Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools.
- [Fix PR](https://ai-powered.com/skills/fix-pr): Fix PR is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/repo-cleanup-loop
