Repo scrub
Find what shouldn't leave the repository, and fix the safe parts. Catches the problems that most
often surface too late: a key committed to .env, no LICENSE, and unclear authorship.
Two passes. Run it on your own repository before publishing or transferring it — it is offline (git + regex, no network). Run it again on any repository you receive, since you can't verify someone else's scrub.
Workflow
Scan first (report only):
python3 scripts/scrub_repo.py /path/to/repoReports secrets in tracked files (redacted, with file:line),
.envfiles, git-history leak hits, LICENSE presence, and bot/suspect committers.Rotate any leaked key first — a human step the tool can't do. Assume anything found is compromised and rotate it at the provider before touching the repository.
Apply the safe fixes:
python3 scripts/scrub_repo.py /path/to/repo --fix --license MIT --owner "Your Name"Untracks
.env, adds.env/.env.*to.gitignore, writes a values-blanked.env.example, and scaffolds a LICENSE if missing. Add--redact-codeto also replace secrets found in tracked source withREDACTED_SECRETin the working tree (review the diff before committing).History leaks are reported, never auto-rewritten — that's destructive and needs a force-push. The scan prints the exact
git filter-repocommand; run it deliberately, after rotating the key.Authorship — for bot or non-employee committers (CI bots,
test@example.com, agent accounts), confirm the code's provenance is what you think it is.
Safety
- Never commits secrets, never force-pushes, never rewrites history on its own.
--fixonly untracks/ignores.env, writes.env.example, and adds a LICENSE.--redact-codeedits the working tree only — nothing is committed.- License scaffolds are stubs (the proprietary one is complete; MIT/Apache are pointers) — confirm the choice yourself; picking a license is not the tool's call.