Who it is forA small team that keeps finding API keys in pull requests after the fact.
The problemCatching secrets in review is too late: once pushed they are in history and must be rotated.
The outcomeCommits that contain hardcoded secrets fail locally with a Detect hardcoded secrets message.
What you need first
- Homebrew, Docker, Go to build from source, or a release binary
- pre-commit if you want the hook
- Read access to the repos or folders you scan
Steps
- Install pre-commit from the pre-commit website
- Create .pre-commit-config.yaml at the repo root with the Gitleaks repo, a rev and the Gitleaks hook id
- Update to the latest version with
pre-commit autoupdate - Install the hook with
pre-commit install - Try a commit with a fake secret to confirm it fails; SKIP=Gitleaks bypasses the hook when you truly need to
Prompt for your agent
Set up gitleaks/gitleaks as a pre-commit hook in <repo>: write .pre-commit-config.yaml, run pre-commit autoupdate and pre-commit install, then prove it works by trying to commit a file with a fake API key. Do not commit the test file.
Caveat. Anyone can skip a local hook, so pair it with the GitHub Action or a CI scan for real enforcement.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for gitleaks/gitleaks and "Stop secrets before they are committed"
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