Load this skill when you need to scan a codebase, directory, or git repo for leaked secrets/tokens/keys (before publishing a repo, before a release, or during security review).
The scanner is static and offline by design: patterns come from the gitleaks v8.30.3 default config, the canonical open-source secret-detection rule set, and detection uses the same Shannon-entropy gating semantics as gitleaks. No network calls are made — a format match is reported as potential, not verified.
scripts/secret_scanner.py — pure Python 3 stdlib (no dependencies).
| Source | Command |
|---|---|
| File | python3 secret_scanner.py --path path/to/file |
| Directory (recursive) | python3 secret_scanner.py --path path/to/dir |
| Git repo (tracked files) | secret_scanner.py --git /path/to/repo |
| stdin (blob) | cat file | secret_scanner.py |
Critical: AWS Access Key ID (AKIA/ASIA/ABIA/A3T…) & secret key,
GitHub PAT classic/fine-grained/refresh tokens, OpenAI (sk-*T3BlbkFJ*),
Anthropic (sk-ant-api03-…AA), Stripe (sk_live_/rk_live_),
Google API key (AIza…), private keys (PEM/OpenSSH/PGP blocks).
High: Slack app/bot/user tokens and webhooks, Perplexity (pplx-…).
Medium: JWT, generic keyword-anchored API keys.
$VAR, ${VAR}, ``, %VAR%, true/false/null,
****, EXAMPLE, xxxx, your-, placeholder, TODO — never reportednode_modules/, vendor/, .git/, lockfiles
(package-lock.json, go.sum, poetry.lock, …), minified JS, binaries,
images, fonts--json / --markdown / text (default) report formats--redact N — mask secrets in output (keeps first N chars; CI-safe)--max-mb N — skip huge files (default 10 MB)--exit-code — exit 1 when findings present (CI gate), else 0# Full directory scan, JSON report for CI
python3 secret_scanner.py --path ./my-repo --json --redact 8 --exit-code
# Scann only tracked files of a repo
python3 secret_scanner.py --git /Users/me/projects/lovii_demo
# Markdown human-readable report
python3 secret_scanner.py --path ./app --markdown > scan-report.md
.env.example contains a real key
instead of a YOUR_KEY placeholder.EXAMPLE suffix) is automatic.Full deep dive with upstream sources in references/canonical-patterns.md.
Key canons:
config/gitleaks.toml) — the canonical regex
set; entropy per-rule minimumsdetect/utils.go#L117-L134; skip when
entropy <= rule.Entropy (strictly greater)git filter-repo/BFG for history)SKILL.md — this fileskill.json — manifestscripts/secret_scanner.py — the stdlib scanner (pattern table + entropy +
allowlists)references/canonical-patterns.md — gitleaks/Detect-secrets/TruffleHog/
SkillSpector deep dive with per-rule regexes and sourcesFull source depth — in references/canonical-patterns.md. Backbone:
| Analog | What we borrow |
|---|---|
| gitleaks (GitHub, MIT) | Pattern table, entropy thresholds, global/path allowlists, redaction, exit-code CI model |
| TruffleHog v3 | Typed-detector philosophy; `verified` vs `unverified` framing (we stay offline) |
| Yelp detect-secrets | Quoted-string scanning to cut noise; keyword-anchored entropy |
| NVIDIA SkillSpector | Two-stage analysis; severity scoring; false-positive baseline/suppression |
# For opencode
cp -r skills/secret-scanner ~/.config/opencode/skills/
# For other agents
# Copy the skill folder to your skills directory; requires Python 3.
Security note: this tool finds potential secrets. It never comments them out, does not attempt to “verify” them online, and never rewrites source files. Operators must rotate real secrets and scrub history manually — see
references/canonical-patterns.md→ Remediation workflow.