repo-cleaner is a Go-native CLI that hunts down multi-ecosystem build artifacts, presents them in a live terminal UI, and runs safe deletes once the user approves. It also exposes its scan/clean tools via an MCP-compatible RPC over stdio with policy-driven access control.
- Live cleanup UI: streaming scan, async metadata, a fixed control band, adaptive mode/status band, size/date sort controls, pauseable output, and immediate delete confirmation feedback.
- Workspace aware: enforces repo boundaries, respects include/exclude filters, and supports
fd,find, or the built-in Go backend. - MCP policy enforcement: the stdio toolset requires
rolemetadata and consults an SQLite table (access_rules) to decide who (owner/admin/staff) may callscan_artifactsorclean_artifacts. - Installation: distributed via
npx repo-cleanerbut also available as a compiled Go binary undercmd/repo-cleaner.
npx repo-cleaner cleanup --fastKey flows:
scan: enumerate cleanup candidates, optionally with--json.cleanup: live TUI with streaming metadata, sort/search/paging, and immediate apply.clean: scripted deletes using--pathsor--interactive.review: text-based toggle/filter workflow.install: builds/copies the CLI (viago build), asks to run a scan, and installs your choice of MCP client (codex or claude).install-tools: (macOS) addsfindutils,fd,ripgrep,fzf.
Flags:
--fast: skip byte-size math on large workspaces.--engine go|fd|find|auto: pick the discovery backend.--include/--exclude: comma-separated type filters (node,rust,go) or glob patterns.
When no root is provided, repo-cleaner treats your current working directory as the workspace root and descends into nested repositories or project folders (you can still pass an explicit root if you need to scope the scan). The mode/status band in the TUI keeps the sort, filter, and selection context visible while you work, and docs/UX.md records the flow-driven reasoning behind that layout.
- Discovery engines:
autotriesfd, thenfind, and falls back to Go. Benchmarks indocs/perf.mdshowfindas the fastest backend on~/dev/repos,fdslightly slower, and the Go walker the most portable option.autoalready implements the fast/fallback strategy described there, so pointing people at that doc keeps them informed without extra configuration.
- Quick scan:
repo-cleaner scan . --fast --jsonfeeds automation with deterministic candidate lists. - Interactive cleanup:
repo-cleaner cleanupstreams the table, lets you/search, page with PgUp/PgDn, and shows per-path deletion status when Enter applies. - Scripted deletions:
repo-cleaner clean . --paths path1 path2 --trashfor CI or scheduled cleanups where you know what to remove. - Review filtering:
repo-cleaner review .uses text commands to filter by substring, toggle selection, and apply safely. - Workspace-aware scanning:
repo-cleaner scan ~/dev --engine godescends into nested repos and summarizes per-project candidates. - Policy-driven MCP: set
REPO_CLEANER_POLICY_DB, runrepo-cleaner installto scan and install an MCP client, and ensure owner/admin/staff rules from the DB gate each tool. - MCP automation: the MCP client uses stdio and the policy database to expose cleanup tools to Codex/Claude bots.
- Toolchain prep:
repo-cleaner install-tools macosinstallsfd,ripgrep,fzf, andfindutils. - Local CLI install:
make install(orrepo-cleaner installwhile developing) copies the fresh binary to~/.local/bin. - Size/date prioritization: inside cleanup you can toggle sorts (
1/2/3), pause refresh, and inspect aggregates before applying.
-
Provide a policy SQLite database via
REPO_CLEANER_POLICY_DB. -
Table schema:
CREATE TABLE access_rules ( role TEXT NOT NULL, tool TEXT NOT NULL, mode TEXT, allow INTEGER NOT NULL, PRIMARY KEY(role, tool, mode) );
-
Example entry:
(owner, clean_artifacts, trash, 1)allows owners to trash-clean selected paths. -
The MCP handlers automatically read
rolefrom each tool call and reject unauthorized requests.
- Build:
go build -o bin/repo-cleaner ./cmd/repo-cleaner - Tests:
go test ./... - Format:
gofmt -w ./cmd ./internal - Install CLI locally:
make install(copies the built binary to~/.local/bin)
MIT