detect-secrets
$ detect-secrets Official Low RiskYelp's enterprise secret-scanning CLI combining entropy heuristics and provider regex detectors to flag hardcoded API keys, private keys, and tokens without scanning git history by default. detect-secrets scan writes structured JSON directly to stdout, while detect-secrets audit is interactive.
brew install detect-secrets Scans workspace files offline and emits JSON baselines in under a second; never send repo secrets through MCP.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
detect-secrets scan natively outputs clean JSON to stdout, but detect-secrets audit is interactive-TTY only and scan exits 0 even when secrets are found.
detect-secrets scanoutputs JSON natively to stdoutdetect-secrets auditblocks on interactive stdin promptsscanexits 0 unless wrapped withdetect-secrets-hook
Hashes detected secrets in JSON baselines instead of leaking raw secret values; purely offline.
- Stores SHA-1 hashes rather than plaintext secrets in baselines
Available via Homebrew, PyPI, and uvx, requiring Python.
- Standard Python package via
brew,pip, oruvx
Great baseline workflow for pre-commit, though gitleaks and trufflehog cover full git history and live verification better.
- Strong baseline-diffing for incremental CI and pre-commit
Created by Yelp (Yelp/detect-secrets) under Apache-2.0, with moderate maintenance cadence.
- Official
Yelp/detect-secretsrepository
Detailed README covering plugins, baselines, and pre-commit integration.
- Official README at github.com/Yelp/detect-secrets
Security, Auth & Guardrails
Offline local scanner; stores only hashed secret fingerprints in .secrets.baseline.
Apache-2.0 open-source Python CLI; completely free.
# detect-secrets Agent Rules - Use `detect-secrets scan <path>` for non-interactive JSON output; NEVER invoke `detect-secrets audit`, which requires an interactive TTY. - Never print raw matched secrets back to external logs; inspect only filenames, types, and line numbers.
Agent-Ready Command Recipes
Safe Read-Only Queries
detect-secrets scan src/
Scans src/ and prints a structured JSON report containing results with hashed secrets and line numbers.
detect-secrets scan --baseline .secrets.baseline
Updates or verifies findings against .secrets.baseline (redirect stdout or avoid overwriting if checking read-only).
Controlled Writes & Previews
detect-secrets scan > .secrets.baseline
Writes the JSON baseline file for pre-commit hook enforcement.
Strengths for Agents
- +
detect-secrets scanoutputs clean JSON directly to stdout without extra flags and hashes secret values. - + Baseline file model suppresses known test fixtures cleanly in CI.
Caveats & Pitfalls
- !
detect-secrets auditis strictly interactive and will hang headless agents. - !
detect-secrets scanexits0even when secrets are detected (must parseresultsJSON or usedetect-secrets-hook).