daymade/claude-code-skills/github-sensitive-data-cleanup
Claude Code and agent skill by daymade/claude-code-skills
- community
Checking that the SKILL.md file is still in the repository.
Scans and removes sensitive data (secrets, API keys, private domains/IPs, PII) from GitHub repository history, then verifies and force-pushes safely. Use for 清理敏感数据 / 历史重写 / 泄露, "scan sensitive data", "clean git history", "remove secrets from repo", or before any force push to a public repo. Not for local-only Git recovery (use git-safety-net) or ordinary repository setup (use auto-repo-setup).
Install
npx vskill@latest install daymade/claude-code-skills/github-sensitive-data-cleanupSKILL.md
The same SKILL.md was published earlier as daymade/claude-code-skills/github-sensitive-data-cleanup.
GitHub Sensitive Data Cleanup
Overview
This skill guides you through safely removing sensitive data from a Git repository's history and pushing the cleaned history to GitHub. It encodes the hard-won lessons from real incidents: scan first, backup before rewriting, verify after rewriting, and never force-push to a public repo without checking its visibility and fork count.
The bundled scripts automate the mechanical parts:
scripts/scan_repo.py— scan the repo for secrets and private context.scripts/rewrite_history.py— create a backup and rewrite history with
git-filter-repo.
scripts/verify_cleanup.py— confirm the sensitive content is gone.scripts/safe_push.py— verify repo visibility and push safely.
This skill is conservative by design. If any safety check fails, it stops and asks for human confirmation rather than continuing.
When to Use This Skill
Trigger this skill when the user:
- Says "scan sensitive data", "扫描敏感信息", "看看仓库有没有泄露".
- Wants to "clean git history", "sanitize history", "rewrite history",
"remove secrets from history".
- Has accidentally pushed a secret, private domain, internal IP, or PII to a
public repository.
- Is about to force-push to a public repository (even without sensitive data).
- Mentions
git filter-repo,BFG,git-filter-branch, or history rewrite.
Prerequisites
Install these tools once per machine:
The scripts assume git-filter-repo and gitleaks are on PATH. The skill will check this before running destructive operations.
Safety Rules (Non-Negotiable)
- Scan before you decide. Never rewrite history based on a hunch.
- Create a backup before rewriting. Use
git bundleor a fresh bare clone. - Verify repo visibility with `gh repo view` before any push. Do not infer
public/private from the URL or directory name.
- Never use `--no-verify` to bypass hooks. If the PII Guard hook fails,
fix the underlying issue or add an allowlist; do not bypass.
- Use one explicit lease bound to the saved remote commit. A rejected
lease stops the push; never fall back to --force or refresh the expected commit to bypass concurrent work.
- Verify after rewriting. A clean
git logis not enough; re-run the
scanner and do an AI semantic review.
- Public repos with forks need extra care. Forks and clones may retain old
history. Verify the named exposure and ownership before choosing a route; contact owners only within the authorized recipient/message scope.
Workflow
Step 0: Confirm the repo path and current branch
Use an exact repository root. Scan and verification accept ordinary, linked worktree and bare roots. Rewrite requires an independent clone: linked roots and ordinary or bare repositories with attached worktrees are refused. A bare mirror has no working-tree status to check; verify its Git identity instead.
Step 0.5: Bind each exposed surface
The acting agent records the known finding's exact public locations and the authorized remediation scope in private task evidence. Follow the finding, not an unbounded inventory of every repository. Keep these surfaces distinct:
| Surface | Deciding evidence and remediation owner | |
|---|---|---|
| Current files and hosted publication text | Read the named published files, PR title/body or other affected text. Ordinary corrections close only these current values; use github-ops for hosted edits. | |
| Git objects and refs | Bind file blobs, commit messages and the affected branch/tag history to immutable objects. This Skill owns an explicitly authorized rewrite and exact-ref readback. A clean tip does not prove clean ancestry or removal of an old object. | |
| PR body edit history | Inspect revisions of the named PR even when its current body is corrected. Use github-ops's PR body edit-history cleanup in its Pull Request Operations reference; it owns exact revision selection, private backup, deletion authorization and preservation readback. | |
| Cached views, PR Git references, forks and clones | Check the known locators and ownership separately. Git rewrite or branch deletion does not establish erasure here; third-party copies and GitHub-controlled references may require a separate route. |
Distinguish an object retained in a private backup from one still publicly obtainable. When claiming anonymous access, test the exact locator without authentication and compare the returned content with the intended immutable object; an authenticated read, error page or redirect alone does not prove anonymous exposure or removal. Include releases, attachments or logs only when the finding points to them, and leave uninspected surfaces unverified.
For each named surface, report what was inspected, what the result proves, and what remains public or unverified. The bundled Git scanners do not inspect hosted PR revision history or prove removal from caches/forks. No finding within a completed scope means stop that audit; it does not convert excluded or unknown surfaces into clean ones. Once the approved changes are verified, report residuals rather than silently expanding into a rewrite, deletion or external message.
Step 1: Scan for sensitive data
Run the scanner to find what needs to be removed:
The scanner auto-loads repo-specific patterns from .pii-patterns in the repo root. If that file contains real private domains, do not commit it — add it to .gitignore or keep it outside the repo. rewrite_history.py will abort if the working tree has untracked files.
To enable Layer 3 (private infrastructure context from your gitleaks config and an optional identities file):
The --gitleaks-config flag reads private-domain-context and private-ip-context rules from your private gitleaks config. The real patterns stay in your private config; nothing is copied into this public skill.
Review /tmp/scan-report.json. It includes:
gitleaksfindings (secrets, API keys, tokens).- Custom pattern matches (internal IPs, phone numbers, PII).
- Layer 3 context matches (private domains, IPs, identities from your config).
- A reminder to do an AI semantic review for content that regex cannot catch.
Check that the scan completed successfully before interpreting its findings. An execution error leaves the scan incomplete. Zero findings still proceeds to Step 1.5; it does not authorize a clean result or a history rewrite.
Step 1.5: AI semantic review (Layer 4)
Regex scanners (Layers 1-3) cannot catch novel private context: real names, project codenames, transcript snippets, internal meeting references, or architecture descriptions. You must do an AI semantic review.
Use the prompt in references/ai_semantic_review_prompt.md on the frozen refs and file set for this task, including material with no scanner hits. Scanner findings prioritize inspection; they do not define its coverage. Record inspected items, findings and unreviewed coverage outside the public repository.
If the completed scan and semantic review find nothing sensitive in that scope, stop. Do not rewrite history. Incomplete coverage remains unverified, not clean.
If you skip this step, you may push private context that gitleaks never knew to look for.
Step 2: Classify findings and choose a remediation
For each finding, decide:
- Rotate the credential (always do this for live secrets first).
- Remove from history (for private domains/IPs, PII, or already-rotated
secrets that still reveal internal context).
- Add to `.gitignore` or allowlist (for false positives only).
Select the route for the observed surface: correct current hosted text or clear approved PR body revisions through github-ops; use Steps 3–7 only for the separately authorized Git rewrite. A PR revision-content approval is not permission to rewrite branches or tags.
Live secrets must be rotated before history cleanup. Removing history does not invalidate a secret that has already been exposed.
Verify ownership claims before choosing a route. The route depends on who controls the resource: a fork/branch/document you control allows self-serve deletion; a third party's forces the GitHub Support / owner-cooperation route. Treat an audit report's annotation of who owns an account, fork, or document as an unverified claim, however confidently it is written — check gh api repos/<owner>/<repo>, gh auth status, or ask the user. (2026-09-18: an inherited report labeled an external contributor's fork as the user's own agent account, silently downgrading the route from "support ticket" to "delete it yourself" — it would have failed at execution time.)
Step 3: Prepare a replacements file
Create a text file with one replacement per line in git-filter-repo --replace-text format:
Replace these with your actual sensitive strings. Do not commit the real values; keep the replacements file outside the repository.
Use literal: for exact string matches. For regex replacements, use regex: (only if you are confident in the pattern).
Save this file outside the repo, e.g. /tmp/sensitive-replacements.txt.
Step 4: Save the publication target, then back up and rewrite
Before rewriting, save these observed values in the existing task state outside the repository: the selected remote name and verified transport configuration, the fully qualified GitHub target (HOST/OWNER/REPO), the exact destination branch ref, and its full remote commit SHA. Keep credentials out of this state; retain the configured credential mechanism. Resolve the selected remote's single push URL, including configured push URLs and URL rewrites. Reject URLs containing credentials before passing them to another command or saving them; keep authentication in the existing credential mechanism. Check that the verified credential-free URL resolves unchanged before querying its branch. A changed resolution is unknown and stops the snapshot. A plain ls-remote origin can follow a different fetch URL:
Require one verified push URL and a successful ref query with exactly one matching full SHA/ref row. An absent branch or failed query is not a saved preimage. Do not derive this value from the rewritten local branch or a stale remote-tracking ref. If this task resumes after rewriting, reuse the saved target/preimage; missing state stops the push.
--yes confirms the displayed rewrite target and backup paths. It does not authorize rewriting shared history or bypassing git-filter-repo's native fresh-clone checks. Preserve pending work in the original checkout and use the independent clone route below when necessary.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinggithub-sensitive-data-cleanup/SKILL.md
Popularity
- Repository stars
- 1,254
- Repository forks
- 205
- 7-day trend score
- 36
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/daymade/claude-code-skills/github-sensitive-data-cleanup)