Guides / Key-scanning tools
Tools that find API keys in AI-written code
AI coding sessions commit fast, and keys go with them. Five scanners compared on price and strengths, a setup that costs nothing, and the security numbers to track every month.
Catch keys at four points, not one
Where a leaked key can be stopped
- 1On the laptopA pre-commit hook blocks the commit that contains a key.
- 2On pushGitHub push protection blocks known key formats.
- 3In the historyA full scan finds keys committed months ago.
- 4In productionAlerts, rotation and audit logs limit the damage.
The tools, compared
| Tool | Licence or price | Best at | Note |
|---|---|---|---|
| Gitleaks | MIT, free | Pre-commit hooks and scanning full git history | Fast, simple, no account needed |
| TruffleHog | AGPL-3.0, free | Verifying whether a found key is still live | Scans git, GitHub, S3, Docker images; 800+ secret types |
| GitGuardian (ggshield) | Free for up to 25 developers | Monitoring every repository with alerts and a dashboard | Public monitoring is a paid feature |
| GitHub secret scanning | Free on public repositories | Blocking known key formats on push | Private repositories need Secret Protection: $19 per active committer per month |
| Semgrep Secrets | Teams plan, $15 per contributor per month | Following a secret through the code | Validates keys locally; not in the free edition |
A setup that costs nothing
For a small team, this combination covers the first three points for free:
# .pre-commit-config.yaml: block commits that contain keys
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleakspip install pre-commit && pre-commit install # once per laptop
gitleaks git -v # scan the full history now
trufflehog git file://. --results=verified # which found keys still work
- Turn on push protection for your account and for public repositories.
- Run the history scan once now, then in CI on every pull request.
- Treat a verified result as an incident: rotate first, then clean the history. See the first hour after a leak.
Keeping track of security over time
| What to track | Where | Target |
|---|---|---|
| Open secret alerts | GitHub Security tab, GitGuardian dashboard | None older than a week |
| Keys older than their rotation date | Infisical, AWS Secrets Manager, Azure Key Vault | None |
| Who read which secret | Vault audit logs | Reviewed monthly |
| Dependencies with known vulnerabilities | GitHub Dependabot alerts | Critical ones fixed within a week |
| AI spend against limits | Claude Console, OpenAI, AWS Budgets | No surprises |
Related guides
- Automatic secret rotation with Infisical
- What to do when a key reaches GitHub
- The CTO's guide to apps your staff build with AI
Sources
Checked on 2 December 2026. Prices and product names change; the linked pages are the reference.
How I help
I scan the full history of every repository, rotate what is live, and set up the hooks and alerts so it does not happen again.
- History scan and cleanup: every repository, verified results, rotation and history rewrite.
- Guardrails: pre-commit hooks, CI scanning, push protection, Claude Code deny rules.
- Operate: monthly security numbers as part of running your systems.
Done by a Claude Certified Architect and Certified Lovable Expert. Everything stays in your accounts.
Questions
Which secret scanner should a small team start with?
Gitleaks as a pre-commit hook and in CI. It is free, fast and needs no account. Add TruffleHog to check whether found keys are still live.
Does GitHub scan private repositories for free?
No. Push protection and secret scanning are free on public repositories. Private repositories owned by an organization need GitHub Secret Protection, $19 per active committer per month.
What is the difference between Gitleaks and TruffleHog?
Gitleaks finds key-shaped strings quickly. TruffleHog also tests whether each key still works, which tells you what to rotate first.
Is GitGuardian free?
Its Starter tier is free for up to 25 developers and covers monitoring of internal repositories. Monitoring public exposure is a paid feature.
Start with a conversation
Thirty minutes, no charge. Tell me what you have built and where it stopped. If I am not the right person, I will say so and point you somewhere better.
Calendar not loading? Open the booking page or email me.