Keep keys out of git, out of the browser, out of the chat
Takes
25 min in 3 steps
Checked
19 Nov 2026
min
Your estimate is optional. Your review compares it with how long it took; nothing is scored.
When we audited our own repositories, we found committed .env files and databases, personal email addresses in example files, and keys pasted into chats. None of it was malicious. All of it was the default outcome of moving fast with an agent.
You'll needAny project with at least one secret. git. Prices checked this month are on Tools.
Search what's already there
Step 1 of 3, about 10 min
Run a scanner over the history, for example gitleaks: gitleaks git . (install from its GitHub releases). Anything real it finds must be rotated at the provider. Deleting the file is not enough: it's still in history.
The part of a video worth watching for this step
YouTube, AI Engineer. Published Nov 2026.Checked 19 Nov 2026
Optional. The step counts when you've done it, whether or not you watch. Minutes from the creator's chapters; our notes on this video.
the usual mistake
Thinking a deleted file is gone. git keeps every version until history is rewritten, and anyone who cloned already has it. It happened to us in INC-14, "Secrets in git, across dozens of repos".
Block it at commit time
Step 2 of 3, about 10 min
Add a pre-commit hook that runs the scanner on staged changes. With the pre-commit framework it's a few lines of config; or a plain .git/hooks/pre-commit script calling gitleaks git --pre-commit --staged. Then try to commit a file containing a fake key: sk_test_ followed by about 28 random letters and digits (a run of the same letter may not trigger it). The commit must be refused.
The part of a video worth watching for this step
YouTube, IndyDevDan. Published Jul 2025.Checked 19 Nov 2026
Optional. The step counts when you've done it, whether or not you watch. Minutes from the creator's chapters; our notes on this video.
An honest .env.example
Step 3 of 3, about 5 min
Paste this to your agent
List every environment variable this project reads. Write .env.example with each one, an empty value and a one-line comment. No real values, no real emails.
The part of a video worth watching for this step
YouTube, Tech With Tim. Published Jul 2026.Checked 19 Nov 2026
Optional. The step counts when you've done it, whether or not you watch. Minutes from the creator's chapters; our notes on this video.