secret-hygiene
Skill16 starsChanged 6 months agoMITView on GitHub
Find, rotate, and prevent leaked credentials across repositories and disk. Covers leak detection with gitleaks and trufflehog, rotation order (the leaked secret first, then outward), git history purge with git-filter-repo, and prevention via pre-commit scanning. Invoke when a secret was committed to git, when a private repo went public, or as periodic audit.
- Reads credentials
- Deletes or force-pushes
- Installs packages
- Commits and pushes
5 other projects use a version of this.
Adopted by
Most recently taken up by
- sentimony/skillstheir own version, first seen Nov 1, 2026
- ShendLlapashtica/leak-guardtheir own version, first seen Nov 1, 2026
- Mcpgate-de/maisecretstheir own version, first seen Oct 23, 2026
- 26zl/universal-agent-skillstheir own version, first seen Oct 6, 2026
- dfrysinger/skillstheir own version, first seen Aug 2, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Mcpgate-de/maisecrets★ 8same name
- sentimony/skills★ 7same name
- dfrysinger/skills★ 3same name
- 26zl/universal-agent-skills★ 2same name
- ShendLlapashtica/leak-guard★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository37 other files it gives its agents.
- agent-client-securitySkill
- ai-agent-guardrailsSkill
- android-securitySkill
- api-securitySkill
- auth-hardeningSkill
- backend-architectureSkill
- backup-disaster-recoverySkill
- cloudflare-hardeningSkill
- codebase-auditSkill
- dach-complianceSkill
- dependency-supply-chainSkill
- distributed-system-auditSkill
- dns-domain-securitySkill
- docker-container-securitySkill
- email-deliverability-securitySkill
- file-upload-securitySkill
- gdpr-technical-controlsSkill
- github-actions-securitySkill
- honeypot-tarpitsSkill
- incident-responseSkill
- ios-securitySkill
- kubernetes-securitySkill
- llm-app-securitySkill
- llm-coding-failure-modesSkill
- log-strategySkill
- mcp-securitySkill
- message-bus-securitySkill
- nextjs-securitySkill
- object-storage-securitySkill
- payload-cms-securitySkill
- postgres-hardeningSkill
- prompt-injection-defenseSkill
- rag-securitySkill
- site-server-auditSkill
- stripe-webhook-securitySkill
- vps-hardeningSkill
- wordpress-hardeningSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 33
Keep this in a password manager or a private repo — never in plaintext on disk.
- Distinctive: line 73
When a secret leaks, rotate outward from the access it grants.
- Distinctive: line 111
Every collaborator must git clone fresh.
- Distinctive: line 156
Commit a placeholder file with the keys but not the values:
- Distinctive: line 168
Never bake secrets into Docker images (use runtime env, mounted files, or a secret store)
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Secret Hygiene
A practical workflow for credential management: detecting leaks, rotating cleanly, and preventing recurrence.
When to invoke
- A secret was committed to git, or a private repo went public
- A contributor leaves the project, or access scope changes
- A credential turned up in a public dump, paste, or leak feed
- Periodic audit (quarterly is reasonable)
- Onboarding a repo, hosting account, or VPS you inherited
Step 1 — Inventory what you have
You cannot rotate secrets you cannot enumerate. Build a list, even a rough one.
- Hosting panel: <provider> creds in: 1Password vault X
- DB user: <name> creds in: server .env, 1Password
- API keys:
- Stripe live + test creds in: backend .env, Stripe dashboard
- Mailgun creds in: backend .env
- GitHub PAT creds in: ~/.gitconfig (BAD — move to keychain)
- SSH keys: ~/.ssh/id_* on machines: workstation, CI, VPS
- CI secrets: GitHub Actions visible at: repo/settings/secretsKeep this in a password manager or a private repo — never in plaintext on disk.
Step 2 — Scan for leaks (local + repos)
Local filesystem
# Files commonly containing secrets
find ~/Code -maxdepth 4 -type f \( -name '.env*' -o -name 'credentials*' -o -name 'secrets*' \) -not -path '*/node_modules/*' 2>/dev/null
# Permissions check — .env should be 600
find ~/Code -name '.env*' -not -path '*/node_modules/*' -exec stat -f '%Lp %N' {} \; 2>/dev/null
# Did you commit a .env by accident?
cd ~/Code/<repo>
git log --all --full-history -- '.env*' 2>/dev/nullGit history
# Quick grep across all history for high-signal patterns
git log -p --all -S 'AKIA' # AWS access key
git log -p --all -S 'sk-' # OpenAI / many SaaS
git log -p --all -S 'ghp_' # GitHub PAT
git log -p --all -S 'xoxb-' # Slack bot token
git log -p --all -S 'BEGIN RSA PRIVATE KEY'
git log -p --all -S 'BEGIN OPENSSH PRIVATE KEY'
# Better: dedicated scanners
gitleaks detect --source . --report-format json --report-path gitleaks.json
trufflehog git file://. --jsonHosted (GitHub)
GitHub runs secret scanning for public repos automatically. For private repos with paid tiers, enable it. Push protection blocks future leaks at git push time — turn it on.
Step 3 — Rotation order
When a secret leaks, rotate outward from the access it grants. Common order:
- The leaked secret itself — invalidate first.
- Anything that secret could have been used to read (e.g. a leaked DB password → audit recent DB queries, then rotate DB user).
- Anything that secret could have been used to write (e.g. a leaked API key with write scope → check for unauthorized writes, then rotate).
- Adjacent secrets stored in the same place — if a
.envleaked, assume every value in that.envleaked. - Inbound credentials that depend on the rotated outbound credential (downstream services, webhooks).
For each rotation, log: what, when, by whom, who was notified.
Step 4 — Purging git history (last resort)
Rewriting history is disruptive — every collaborator must re-clone, and tags/CI references may break. Do it only if a high-value secret is in history and rotating is genuinely insufficient (rare; usually rotation is enough).
Modern tool: git-filter-repo
# Install once: brew install git-filter-repo
# Backup first
git clone --mirror git@github.com:owner/repo.git repo-backup.git
# Remove a specific file from all history
cd repo-clone
git filter-repo --invert-paths --path .env
git filter-repo --invert-paths --path config/secrets.yml
# Or replace a literal string everywhere
echo 'AKIAIOSFODNN7EXAMPLE==>REDACTED' > replace.txt
git filter-repo --replace-text replace.txt
# Force-push (coordinate with the team — everyone re-clones after this)
git push --force --all
git push --force --tagsAfter force-push:
- Every collaborator must
git clonefresh; rebasing existing forks is fragile - Any CI/CD that pinned a commit SHA may break
- GitHub may still serve the old commit by SHA for a while — open a support ticket if cleanup is critical
- Rotate the secret anyway — assume it was already harvested before the purge
Step 5 — Prevention
Pre-commit scanning
Install once per workstation:
# Option A: gitleaks pre-commit hook
brew install gitleaks
gitleaks protect --staged --no-bannerOr via pre-commit framework — example .pre-commit-config.yaml:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleaks.gitignore baseline
# Never commit these
.env
.env.*
!.env.example
*.pem
*.key
*.p12
id_rsa
id_ed25519
credentials.json
config/secrets.yml.env.example convention
Commit a placeholder file with the keys but not the values:
# .env.example
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
STRIPE_SECRET_KEY=sk_test_REPLACE_ME
GITHUB_TOKEN=ghp_REPLACE_MEServer-side secrets
.envpermissions:chmod 600 .env, owned by the app user- Never bake secrets into Docker images (use runtime env, mounted files, or a secret store)
- For CI: use the platform's secret store (GitHub Actions secrets, GitLab CI variables) — never echo them into build logs
Token scope minimization
- GitHub PATs: prefer fine-grained tokens, scoped to a single repo/org with the minimum scopes
- Database users: separate read-only and read-write users for separate processes
- Cloud IAM: avoid root keys; use scoped service accounts with explicit, minimal IAM
Quick reference — common token prefixes
Useful for grep-based scans:
| Prefix | Provider |
AKIA, ASIA | AWS access key |
ghp_, gho_, ghu_, ghs_, ghr_ | GitHub tokens |
xoxb-, xoxp-, xoxa- | Slack tokens |
sk_live_, sk_test_ | Stripe |
key- (Mailgun), re_ (Resend) | Mail providers |
sk-, sk-proj- | OpenAI / Anthropic-style |
glpat- | GitLab PAT |
dckr_pat_ | Docker Hub PAT |
npm_ | npm tokens |
-----BEGIN OPENSSH PRIVATE KEY----- | SSH private key |
What this skill will not do
- Help retrieve or use credentials that are not yours.
- Scan repositories you do not have authorization to scan.
- Recommend storing secrets in source control "just for now" — there is no "just for now" with secrets.
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.

