Remove references to blocklisted terms from git history and source files. Use when user says /reference-cleaner, 'clean references', 'remove mentions of X', 'scrub project names from history', or asks to sanitize a repo before publishing.
Remove all references to blocklisted terms from a git repository's source files, commit messages, and file history. Designed for sanitizing repos before open-sourcing or publishing.
The user provides a blocklist of terms to remove. Each term can be:
yarli, ralph)YRLI-\d+ for tranche IDs)Optionally, the user provides a whitelist of terms that look similar but should be preserved (e.g., sw4rm is OK, yarli is not).
ORIGINAL_HEAD=$(git rev-parse HEAD)
echo "Original HEAD: $ORIGINAL_HEAD"
echo "To restore: git reset --hard $ORIGINAL_HEAD"
For each blocklisted term, search all tracked files:
git ls-files | xargs grep -li '<term>' 2>/dev/null
Categorize matches into:
Present a table:
| Action | Path | Term | Context |
|--------|-----------------------------|---------|----------------------------------|
| DELETE | .yarli/tranches.toml | yarli | Orchestration config file |
| EDIT | src/rest.rs | YRLI | Comment references (YRLI-58) |
| RENAME | bin/yarli-lint-tranches.sh | yarli | Script name contains term |
git log --format="%H %s" | grep -iE '<term1>|<term2>|...'
Present commits that need message rewrites.
Ask the user to approve the plan. Show:
git rm files marked for deletion(TERM-XX) from commentsTERM-XX: prefixes from comments<blocked>_haake_import_v1 -> haake_import_v1)Use git-filter-repo --message-callback with a Python callback that:
TERM-XX references via regexgit-filter-repo --message-callback '
import re
m = message.decode("utf-8")
# ... replacements ...
return m.encode("utf-8")
' --force
Use git-filter-repo --invert-paths to remove deleted files from all historical commits:
git-filter-repo --invert-paths \
--path-glob '.yarli/*' \
--path 'yarli.toml' \
... \
--force
git ls-files | xargs grep -liE '<terms>'git log --format="%B" | grep -iE '<terms>'git log --all --diff-filter=ACDMR --name-only --format="" | grep -iE '<terms>'pre-clean-backup tag before any destructive operationgit status --porcelain shows uncommitted changesyarli_config), rename the identifier. Verify with cargo check / npm run build / equivalent.User: /reference-cleaner
Claude: What terms should I remove from this repository?
User: termA, termB, termC, TERMA
Claude:
Original HEAD: a1b2c3d4...
To restore: git reset --hard a1b2c3d4...
Scanning tracked files for: termA, termB, termC, TERMA
Found references in 36 files:
- DELETE: 25 files (orchestration configs, scripts, docs)
- EDIT: 11 files (source comments, identifiers, .gitignore)
Found references in 8 commit messages.
[Table of changes...]
Approve this plan? [Approve / Cancel]