Who it is forA team lead who wants leaks caught before they reach the remote.
The problemSecrets pushed to a shared repo must be rotated, which is costly.
The outcomeCommits that fail when a new secret appears, while known baseline entries pass.
What you need first
- Python with pip (`pip install detect-secrets`) or Homebrew (`brew install detect-secrets`)
- A git repository to scan
- Optional: the pre-commit framework for the hook
Steps
- Add the Yelp/detect-secrets repo with
id: detect-secretsand args --baseline .secrets.baseline to .pre-commit-config.yaml, as in the README - Scan staged files by hand with
git diff --staged --name-only -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline - Scan all tracked files with
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline - Mark known false positives inline with a pragma: allowlist secret comment
Prompt for your agent
Set up Yelp/detect-secrets as a pre-commit hook in <my repo> using the README config, then run `git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline` and report any new findings.
Caveat. The README says it will not catch multi-line secrets or default passwords that do not trigger the KeywordDetector.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for Yelp/detect-secrets and "Block new secrets at commit time"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer