/history-scrub:history-scrubfrom history-scrub
This skill should be used when a literal that must not be public — a client or employer name, a real identity, an internal hostname, a leaked value — has landed in a PUBLIC git repo's history and has to come out of it. Triggers on "scrub this from git history", "rewrite history to remove X", "this name must not be in the public repo", "purge the client name from main", "force-push a cleaned history", "remove sensitive data from the repo". Census first, fix the tip forward, back up, rewrite the minimal range, prove the tree is unchanged, push with a pinned lease — then clean the places a rewrite cannot reach.
Ships in history-scrub. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Removing a literal from a public repo's history is three jobs, and a rewrite does only the middle one: stop the bleeding (tip + PR text), rewrite (commits), chase the copies a rewrite cannot touch (PR refs, cached views, forks, other clones).
A token, key or password is compromised the moment it was pushed — scrapers index public pushes within minutes. Rotate it at the issuer before anything below; the rewrite is hygiene, not remediation. GitHub's own guidance says Support assists with removal mainly when rotation cannot mitigate the risk. A name or hostname cannot be rotated — that is when the rewrite is the remediation.
git fetch origin
git log --all -i -G '<term>' --format='%h %ad %s' --date=short # diffs (content)
git log --all -i --grep '<term>' --oneline # commit MESSAGES
git log --all -i -G '<term>' --format='== %h' --name-only # WHICH files
git grep -i -c '<term>' origin/<default> -- . # live tree
-G hits that git show does not print are files git classes as binary, or very long
single-line files (minified HTML). Use --name-only to see which; do not conclude "false
positive" because the diff looks clean.gh pr view <n> --json title,body,comments), release notes, issues.gh pr ready <n> --undo) so auto-merge
cannot land mid-edit; fix them, or merge/close them. GitHub's guidance is to merge or close
open PRs before rewriting — every rewritten SHA strands a PR built on it.claude:work:oauth, not claude:<client>:oauth), and
migrate any runtime state keyed by the old name.gh pr edit <n> --body-file <clean.md>. The forge keeps the
edit history, visible to anyone — note it for § 6.Done right, the tip tree after the rewrite equals the tip tree before it — which is the check in § 4.
Backup to a PRIVATE repo, by SHA, before rewriting:
git push [email protected]:<owner>/<repo>-prerewrite-backup.git <old-tip-sha>:refs/heads/prerewrite-<YYYY-MM-DD>
and confirm with git ls-remote that the branch points at <old-tip-sha>.
Rewrite. Preferred (GitHub's recommendation): git filter-repo --replace-text <expressions.txt> in a fresh clone (filter-repo refuses a non-fresh one). Where a
fresh clone is unavailable (a sandboxed agent session limited to its own worktree), the
fallback rewrites only a branch over the minimal range:
git switch -c scrub origin/<default>
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --tree-filter \
'test -f <path> && perl -pi -e "s/<old>/<new>/g" <path>; true' \
-- <last-clean-sha>..scrub
git update-ref -d refs/original/refs/heads/scrub # drop filter-branch's backup ref
Replace with the SAME generic value the fix-forward used, so history and tip agree.
git grep -i -c '<term>' $(git rev-list <last-clean-sha>..scrub) -- . # expect: no output, exit 1
git log --format=%B <last-clean-sha>..scrub | grep -ci '<term>' # expect: 0
git rev-parse <old-tip-sha>^{tree} scrub^{tree} # expect: the SAME hash twice
git rev-parse 'scrub~<N>' # expect: <last-clean-sha>
An identical tip tree proves the rewrite changed history and nothing the code does. If the trees differ, stop: the fix-forward and the rewrite disagree.
git push --force-with-lease=<default>:<old-tip-sha> origin scrub:<default>
Pin the lease to the backed-up SHA, not a bare --force-with-lease: a bare lease compares
against whatever origin/<default> your last fetch saw, so a background fetch can silently
re-arm it over a peer's push. A protected branch needs an admin bypass; the push output lists
the rules it bypassed. Bare --force is never needed.
| Copy | What happens | Action |
|---|---|---|
| Other checkouts / worktrees | pull --ff-only now FAILS (diverged) | git fetch && git reset --keep origin/<default> — --keep refuses to clobber local changes |
| Open PR branches | still on old SHAs | rebase onto the new default (not merge) |
GitHub refs/pull/* | read-only, keep the old commits reachable | GitHub Support |
| PR "Files changed", cached SHA views, PR body edit history | still served | GitHub Support |
GitLab refs/merge-requests/* | push-delete REJECTED ("deny deleting a hidden ref"), even after the MR is deleted | keep the project private, or rebuild it clean before it goes public |
| Forks, others' clones | untouchable | accept, or ask owners |
git show — see § 1.refs/pull/ read-only, cached views and PR references need Support, collaborators must
rebase: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository--replace-text: https://github.com/newren/git-filter-repogit push --force-with-lease=<ref>:<expect>: https://git-scm.com/docs/git-pushWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub kattakath/skills --plugin history-scrub