Repository branch/worktree cleanup sweep
State: open/verified · Kind: module · Audience: user
Summary
Section titled “Summary”- A read-only sweep that inventories a repository’s local branches, worktrees and remote branches and classifies each as safe-to-delete, safe-to-keep or needs-investigation, backed by PR-merge state and default-branch ancestry, emitting the literal command to act on each verdict rather than acting itself.
- Ships as both an importable library (
sweepRepo/sweepRepos) and a CLI (repo-cleaner) that can target the current checkout, named repositories, or every checkout found under a directory.
Statement
Section titled “Statement”Point repo-cleaner at one or more repositories and it classifies every local branch, worktree, and
remote branch using two signals — a merged pull request (gh pr list) and ancestry of the default
branch (git merge-base --is-ancestor) — either of which settles the verdict alone. Everything else
falls to needs-investigation with the reasons spelled out, and a worktree with uncommitted or
unpushed work is never proposed for removal. It never deletes anything; it reports facts and the
command a human or another system would run.
What it provides
Section titled “What it provides”- Discovery and classification of local branches, worktrees, and remote branches against merged-PR
and ancestry signals, degrading to git-only evidence without
gh. - Multi-repo scope resolution: a bare invocation sweeps the current checkout, named paths sweep exactly those repos, and a directory argument is walked for checkouts under it, with worktrees collapsed into their parent repository.
- Text, JSON, and commands-only render modes, plus a search-cost summary so a misconfigured scope is caught rather than silently under-swept.
- An extension seam (
investigationPartsas a list of sentences) letting a host with extra knowledge — an issue tracker, a task corpus — re-rank and annotate rows without reaching into classification.
Underlying implementation
Section titled “Underlying implementation”- packages/ts/repo-cleaner/ (sweep.ts, branches.ts, worktrees.ts, discover.ts, prs.ts, resolve.ts, render.ts, config.ts, cli.ts)
- Consumed as a library by SDLC’s
sdlc project cleanup(solutions/ontological/lib/services/project/cleanup/index.ts), which layers its own task corpus on top of this sweep’s verdicts.
Locations
Section titled “Locations”packages/ts/repo-cleaner/packages/ts/repo-cleaner/sweep.ts#sweepRepopackages/ts/repo-cleaner/sweep.ts#sweepRepospackages/ts/repo-cleaner/cli.ts