secret-scan
A leaked secret is committed once and exposed forever (history, forks, mirrors). This skill scans a diff or blob for secrets BEFORE it leaves your machine, and blocks rather than trusts.
Why this exists (evidence)
- Secret leakage on public GitHub is massive and persistent (GitGuardian's annual reports count millions of new exposed secrets per year). A key in one commit must be assumed compromised and rotated, even if you delete it next commit, because history and forks retain it.
- Agents make it worse: they paste logs, echo env, and commit broadly. A pre-flight scan is far cheaper than rotation + incident.
When to use
- Before EVERY
git push / git commit of changed files (especially configs, scripts, notebooks).
- Before sharing logs, error output, or config in chat/issues/PRs.
- Before publishing a repo (we publish a lot, run it first).
What to flag
Scan the staged diff / target text for:
- Known key formats: AWS
AKIA.../secret keys, GitHub ghp_/github_pat_, OpenAI sk-..., Anthropic sk-ant-..., Google API keys, Stripe sk_live_, Slack xox..., JWTs, Render/Vercel tokens.
- Private keys:
-----BEGIN ... PRIVATE KEY-----.
- Connection strings / URLs with creds:
postgres://user:pass@, mongodb+srv://...:...@.
- High-entropy strings assigned to suspicious names (
*_KEY, *_TOKEN, *_SECRET, PASSWORD, *_PWD).
- .env-style
KEY=value with secret-looking values being committed (.env should be gitignored).
Output: per finding, file:line + secret TYPE + a MASKED preview (never echo the full secret). Verdict: BLOCK (real secret -> remove, rotate if it ever left the machine, add to .gitignore) / REVIEW (high-entropy but maybe not secret) / CLEAN.
How to run it
git diff --staged (or the target file/text) and apply the patterns above.
- If a tool like
gitleaks/trufflehog is available, run it and pass through the findings.
- On a hit pre-push: do NOT push. Remove the secret, move it to env/.gitignore; if it was ever committed/pushed, treat it as compromised and rotate.
Composes with
safety-net: reversible checkpoints; but a pushed secret is NOT undone by local rollback (history persists) -> scan BEFORE push.
dep-guard / mcp-warden / skill-security-scan: the supply-chain & trust family; secret-scan is the outbound-leak side.
Honest limits
- Pattern + entropy scanning has false negatives (novel/obfuscated secrets) and false positives (random high-entropy IDs). It lowers risk; it is not a guarantee. Prefer a real scanner (gitleaks) in CI as the backstop.
- It cannot un-leak an already-pushed secret; for those, rotate. This is prevention, not cleanup.
1---2name: secret-scan3description: Before a commit, push, paste, or share, scan the diff/text for leaked secrets (API keys, tokens, private keys, passwords, connection strings) and block them, instead of leaking and rotating later. Use before any git push, before sharing logs/config, before pasting output. Trigger with /secret-scan or "check for secrets", "is there a key in this", "scan before push".4---56# secret-scan78A leaked secret is committed once and exposed forever (history, forks, mirrors). This skill scans a diff or blob for secrets BEFORE it leaves your machine, and blocks rather than trusts.910## Why this exists (evidence)1112- Secret leakage on public GitHub is massive and persistent (GitGuardian's annual reports count millions of new exposed secrets per year). A key in one commit must be assumed compromised and rotated, even if you delete it next commit, because history and forks retain it.13- Agents make it worse: they paste logs, echo env, and commit broadly. A pre-flight scan is far cheaper than rotation + incident.1415## When to use1617- Before EVERY `git push` / `git commit` of changed files (especially configs, scripts, notebooks).18- Before sharing logs, error output, or config in chat/issues/PRs.19- Before publishing a repo (we publish a lot, run it first).2021## What to flag2223Scan the staged diff / target text for:24- **Known key formats:** AWS `AKIA...`/secret keys, GitHub `ghp_`/`github_pat_`, OpenAI `sk-...`, Anthropic `sk-ant-...`, Google API keys, Stripe `sk_live_`, Slack `xox...`, JWTs, Render/Vercel tokens.25- **Private keys:** `-----BEGIN ... PRIVATE KEY-----`.26- **Connection strings / URLs with creds:** `postgres://user:pass@`, `mongodb+srv://...:...@`.27- **High-entropy strings** assigned to suspicious names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `PASSWORD`, `*_PWD`).28- **.env-style** `KEY=value` with secret-looking values being committed (.env should be gitignored).2930Output: per finding, file:line + secret TYPE + a MASKED preview (never echo the full secret). Verdict: BLOCK (real secret -> remove, rotate if it ever left the machine, add to .gitignore) / REVIEW (high-entropy but maybe not secret) / CLEAN.3132## How to run it3334- `git diff --staged` (or the target file/text) and apply the patterns above.35- If a tool like `gitleaks`/`trufflehog` is available, run it and pass through the findings.36- On a hit pre-push: do NOT push. Remove the secret, move it to env/.gitignore; if it was ever committed/pushed, treat it as compromised and rotate.3738## Composes with3940- `safety-net`: reversible checkpoints; but a pushed secret is NOT undone by local rollback (history persists) -> scan BEFORE push.41- `dep-guard` / `mcp-warden` / `skill-security-scan`: the supply-chain & trust family; secret-scan is the outbound-leak side.4243## Honest limits4445- Pattern + entropy scanning has false negatives (novel/obfuscated secrets) and false positives (random high-entropy IDs). It lowers risk; it is not a guarantee. Prefer a real scanner (gitleaks) in CI as the backstop.46- It cannot un-leak an already-pushed secret; for those, rotate. This is prevention, not cleanup.