env-secrets-guard
Skill5 starsChanged 16 days agoMITView on GitHub
Scans a repository and its git history for leaked secrets (API keys, tokens, passwords, private keys), fixes .gitignore and env handling, and guides safe key rotation. Use before pushing, before open-sourcing a repo, or when the user asks to check for leaked keys or secrets.
- Reads credentials
In this repository56 other files it gives its agents.
- docs/llms.txtllms.txt
- a11y-fixerSkill
- ad-copy-generatorSkill
- agent-guardrailsSkill
- agent-memory-keeperSkill
- ai-slop-detectorSkill
- api-to-sdkSkill
- app-store-optimizerSkill
- architecture-doctorSkill
- brand-voice-guideSkill
- bug-detectiveSkill
- changelog-from-gitSkill
- codebase-explainerSkill
- codebase-time-machineSkill
- commit-craftSkill
- competitor-spySkill
- content-repurposerSkill
- cost-cutterSkill
- demo-recorderSkill
- dependency-doctorSkill
- dockerize-anythingSkill
- durable-agent-workflowsSkill
- e2e-flow-testerSkill
- email-campaign-writerSkill
- gh-actions-auditorSkill
- hook-generatorSkill
- incident-commanderSkill
- influencer-outreachSkill
- instagram-growth-managerSkill
- landing-page-roasterSkill
- launch-post-writerSkill
- meeting-notes-to-ticketsSkill
- merge-conflict-resolverSkill
- migration-wizardSkill
- plan-grillerSkill
- prompt-injection-scannerSkill
- pr-reviewer-proSkill
- readme-glow-upSkill
- roast-my-githubSkill
- screenshot-to-componentSkill
- seo-blog-writerSkill
- skill-creator-proSkill
- skill-finderSkill
- skills-doctorSkill
- social-analytics-reporterSkill
- social-media-calendarSkill
- social-media-managerSkill
- sql-optimizerSkill
- startup-idea-validatorSkill
- tdd-loopSkill
- terse-modeSkill
- test-gap-hunterSkill
- tiktok-viral-creatorSkill
- ui-tasteSkill
- youtube-script-writerSkill
- youtube-seo-optimizerSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
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
- could be automatic: a setting could enforce it
- Distinctive: line 8
Stop secrets from leaving the machine, and clean up properly if they already have.
- Distinctive: line 12
Run the bundled scanner first.
- Very specific: line 44
Add a .env.example with variable names and empty values.
- Distinctive: line 50
Only then, if the user wants it, rewrite history with git filter-repo or BFG.
- Distinctive: line 58
Never print, log or commit full secret values.
- Distinctive: line 60
Treat anything ambiguous as real until the user confirms it's a placeholder.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Env Secrets Guard
Stop secrets from leaving the machine, and clean up properly if they already have.
1. Scan
Run the bundled scanner first. It needs only Python 3 and never prints full secret values:
python3 scripts/scan_secrets.py . # tracked files
python3 scripts/scan_secrets.py . --history # + every commit in git historyFor deeper coverage, also use a dedicated scanner if one is installed:
gitleaks detect --source . --redact -v # working tree + history
trufflehog git file://. --only-verified # verified live secretsOtherwise, search manually (working tree and history):
git grep -nIE '(AKIA[0-9A-Z]{16}|sk-[A-Za-z0-9_-]{20,}|ghp_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{50,}|xox[baprs]-[A-Za-z0-9-]+|AIza[0-9A-Za-z_-]{35}|sk_live_[0-9a-zA-Z]{24,}|-----BEGIN [A-Z ]*PRIVATE KEY-----)'
git log -p --all -S 'PRIVATE KEY' --oneline | head -50
git ls-files | grep -iE '(^|/)\.env(\..*)?$|\.pem$|\.p12$|\.keystore$|id_rsa|credentials|service-account.*\.json'Also check: hard-coded password=/secret=/token= values, connection strings with credentials embedded, google-services.json/GoogleService-Info.plist and mobile signing files.
2. Report (never print full secrets)
Show at most the first 4 characters followed by ****, plus the file:line and, for history hits, the commit.
Classify each hit: 🔴 live credential · 🟠 likely real · 🟢 test/example/placeholder.
3. Fix
- Move the values into environment variables or a secret manager, and load them through the project's existing config pattern.
- Add a
.env.examplewith variable names and empty values. Add.env*(except the example) and key files to.gitignore. - Untrack committed files without deleting them locally:
git rm --cached <file>.
4. If a secret was ever pushed
- Rotate or revoke the key first. History rewriting does not un-leak a key that has already been pushed.
- Only then, if the user wants it, rewrite history with
git filter-repoor BFG. Explain that this requires a force-push and that every collaborator must re-clone. Never force-push without explicit confirmation.
5. Prevent
Offer to add a pre-commit hook (for example gitleaks protect --staged) and a CI secret-scanning step.
Rules
- Never print, log or commit full secret values. Always redact them.
- Rotate first, clean up second. Never force-push or rewrite history without explicit confirmation.
- Treat anything ambiguous as real until the user confirms it's a placeholder.
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.

