agentleFS
milad-ahmdmilad-ahmd/agent-skills/skills/env-secrets-guard/SKILL.md

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

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
  1. Distinctive:

    Stop secrets from leaving the machine, and clean up properly if they already have.

    line 8
  2. Distinctive:

    Run the bundled scanner first.

    line 12
  3. Very specific:

    Add a .env.example with variable names and empty values.

    line 44
  4. Distinctive:

    Only then, if the user wants it, rewrite history with git filter-repo or BFG.

    line 50
  5. Distinctive:

    Never print, log or commit full secret values.

    line 58
  6. Distinctive:

    Treat anything ambiguous as real until the user confirms it's a placeholder.

    line 60

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 history

For 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 secrets

Otherwise, 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.example with 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

  1. Rotate or revoke the key first. History rewriting does not un-leak a key that has already been pushed.
  2. Only then, if the user wants it, rewrite history with git filter-repo or 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.