prevent-secret-and-pii-leaks
Skill1 starsChanged 5 months agoMITView on GitHub
Use BEFORE committing to a public/shared repo, pushing, publishing a package, or syncing/exporting code, config, docs, or skills to an open-source or external destination — to avoid leaking secrets, PII, or internal identifiers. Also the remediation playbook if something already leaked (untrack → rewrite history → force-push → forks/cache → support → rotate). Prevention >> remediation: you can't fully un-publish.
- Reads credentials
- Deletes or force-pushes
- Commits and pushes
In this repository40 other files it gives its agents.
- authoring-project-skillsSkill
- background-jobs-and-cachingSkill
- code-conventionsSkill
- containerize-and-ship-a-serviceSkill
- database-migrationsSkill
- design-an-error-modelSkill
- git-flowSkill
- handle-files-frontendSkill
- import-data-from-csvSkill
- integrate-external-servicesSkill
- integrate-identity-providersSkill
- integrate-internal-servicesSkill
- keep-service-memory-leanSkill
- operate-ecs-services-safelySkill
- release-safetySkill
- render-transactional-emailsSkill
- rules-backendSkill
- rules-code-styleSkill
- rules-debuggingSkill
- rules-gitSkill
- rules-infraSkill
- rules-pr-reviewSkill
- rules-shippingSkill
- rules-workflowSkill
- schedule-effective-dated-changesSkill
- secure-a-frontend-appSkill
- security-auditSkill
- send-slackSkill
- serve-realtime-with-websocketsSkill
- structure-a-backend-serviceSkill
- structure-a-frontend-appSkill
- structure-a-shared-backend-libSkill
- structure-a-shared-ui-libSkill
- tdd-http-firstSkill
- use-feature-flagsSkill
- write-cross-cutting-codeSkill
- write-frontend-codeSkill
- write-frontend-testsSkill
- write-service-codeSkill
- write-unit-testsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
All three must stay out of a public/shared destination.
- Distinctive: line 29
Default-deny for shared (public/partner) destinations: When unsure whether something is safe to publish, leave it out and ask.
- Very specific: line 40
Forks: keep the old history independently (gh repo view --json forkCount.
- Distinctive: line 41
Platform caches: keep old commits reachable by SHA for a while.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to use
About to git push to a public or shared repo, open-source something, publish a package, or run an export/sync/vendor step that copies your local content into a public destination. Also: reviewing a diff before it goes out, or cleaning up after a leak.
Reason about THREE classes, not just "secrets"
Be precise — they differ in severity and remediation:
- Credentials / secrets — API keys, tokens, passwords, private keys, connection strings,
.envvalues. Highest. If exposed → rotate immediately (assume compromised), then scrub. - PII — emails, real names, usernames, teammate handles, customer data. Can't be "rotated"; once public, treat as disclosed.
- Internal identifiers — cloud account IDs, internal hostnames/URLs, IAM user names, resource/cluster/ARN/bucket names, private org or project codenames, ticket IDs. Info-disclosure, not credentials — don't call these "secrets," but keep them out of public/OSS too.
All three must stay out of a public/shared destination; only the severity and fix differ.
Before you publish (prevention — this is where the win is)
- Confirm the destination's visibility first. Public vs private — check, never assume (
gh repo view --json visibility). "It's probably private" has caused real leaks. - Scan the EXACT bytes being published, not just the obvious files. Include config, fixtures, lockfiles, CI files, and the tooling itself. → The sanitizer-isn't-sanitized trap: an export/sync script that scrubs identifiers often hard-codes those very identifiers in its own config (the scrub list = a list of your real emails/orgs/usernames/handles). Keep such local-only tooling gitignored, never vendored.
- Publish OUTPUT, not source/tooling. Vendor only sanitized, generic content; replace every real identifier with a placeholder (
<account-id>,my-service,example.com,your-org). Docs/skills: principle-first, no org/customer names, no real infra identifiers. - Make the pipeline fail-closed. A publish/export step should run a secret+PII scan and exit non-zero if anything survives — don't rely on eyeballing the diff. Add a pre-commit/pre-push hook for the same.
- Default-deny for shared (public/partner) destinations. When unsure whether something is safe to publish, leave it out and ask.
If it already leaked (remediation)
Order matters; do not skip rotation for credentials.
- Credentials → ROTATE NOW, before anything else. Scrubbing history does not un-leak a key that bots may have already scraped.
- Stop the bleeding:
gitignore+git rm --cached <file>(untrack). This does NOT remove it from history — past commits still contain it. - Rewrite history: back up first (
git bundle create backup.bundle --all), then remove the file/secret from every commit —git filter-repo --path <file> --invert-paths(preferred), orgit filter-branch --index-filter 'git rm --cached --ignore-unmatch <file>' -- <branch>if filter-repo isn't installed. - Force-push the rewritten history (destructive — rewrites SHAs, breaks clones; have the backup):
git push --force-with-lease. - Residuals you can't reach by force-push:
- Forks keep the old history independently (
gh repo view --json forkCount;gh api repos/<o>/<r>/forks). You can't rewrite someone else's fork. - Platform caches keep old commits reachable by SHA for a while.
- → For both, the lever is GitHub Support ("remove sensitive data"): they purge cached views and remove the data across the fork network.
- Forks keep the old history independently (
- Triage by class: credentials = rotated (step 1); PII / internal identifiers = can't rotate → scrubbed + treated as disclosed.
Mindset
You can never fully un-publish — history, forks, caches, and scrapers persist. So the budget belongs in prevention: verify visibility, scan the exact published bytes (including the tooling that handles secrets), placeholder everything, and fail closed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

