agentleFS
robinbrilrobinbril/claude-code-harness/skills/repo-hygiene/SKILL.md

repo-hygiene

Skill3 starsChanged 24 days agoMITView on GitHub

Read-only git/GitHub hygiene check for a repo - dev vs main drift, unmerged and dead branches (incl. squash-merged), merge conflicts per branch via side-effect-free git merge-tree, open PRs and failing GitHub Actions. Use when asked for a codehygiene check, repo health, "is alles gemerged", "loopt dev goed t.o.v. main", "dode branches opruimen", "zijn er merge conflicts", "falen de actions", stale branches or branch cleanup.

  • Commits and pushes

15 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Only side effect: git fetch --prune (updates remote-tracking refs).

    line 29
  2. Distinctive:

    Run the script on the repo.

    line 32
  3. Distinctive:

    Never delete protected branches or a branch with an open PR.

    line 46

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Repo hygiene

One deterministic script gathers everything; you interpret and propose cleanup. Nothing is deleted or merged without explicit per-action approval.

Quick start

~/.claude/skills/repo-hygiene/scripts/hygiene.sh <repo-path>

Env overrides: MAIN=main DEV=dev STALE_DAYS=30 PROTECT_RE='^(main|dev|release/.*)$'. Auto-detect: main = origin/HEAD; dev = first of dev, develop, development, acceptance, staging.

What it checks

  1. dev vs main: commits ahead/behind both ways, plus a dry-run merge dev -> main. main ahead of dev = hotfix not back-merged.
  2. Remote branches: DEAD (gemerged) = ancestor of main/dev; DEAD (PR gemerged, squash) = head of a merged PR with no open PR; STALE = unmerged and older than STALE_DAYS; conflict column = git merge-tree --write-tree against dev (or main). Exit 0 OK, 1 conflict, other = no merge-base (usually a branch from rewritten history).
  3. Local branches: upstream gone, or already merged into main.
  4. Open PRs: base, mergeable state, draft.
  5. Actions: latest run per workflow on main and dev, plus the last 20 failures anywhere.

Only side effect: git fetch --prune (updates remote-tracking refs).

Workflow

  1. Run the script on the repo. Long output: read it fully before summarising.
  2. Report as a short scorecard, worst first:
    • FAIL: failing workflow on main/dev, dev -> main conflict, main ahead of dev.
    • WARN: open PRs with CONFLICTING, stale unmerged branches with conflicts, PR stacks (PR whose base is another feature branch).
    • Cleanup: count of DEAD remote branches + local branches that can go.
  3. For each failing Actions run, fetch the cause before reporting it: gh run view <id> --log-failed | tail -40. Report cause + fix, not just "failed".
  4. Propose cleanup as ready-to-run commands, grouped, and ask before running:
    git push origin --delete <branch> <branch> ...
    git branch -D <branch> ...
    STALE branches with unique commits: list them, ask per branch (merge, rebase or delete). Never delete protected branches or a branch with an open PR.
  5. Merge conflicts: resolve them one branch at a time.

Gotchas

  • voor op base for a squash-merged branch is high but meaningless; the PR check is what counts.
  • ? (geen merge-base): branch predates a history rewrite; almost always safe to delete after confirming its PR is closed.
  • Without gh auth or a GitHub remote, sections 4-5 and squash detection are skipped.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.