Handing the new hire the keys
Watch it happen
Alice asks the assistant to add a feature. It tidies up with “add everything”, and the file holding the vault key goes into a public parcel.
Alice has a new assistant, an AI coding tool. Its desk sits next to a file holding the key to the vault. Alice wants a new feature built.
Alice says: Please add payments.In bank terms and app terms
| In the bank | In your app |
|---|---|
git add . swept up by an agent | |
Are you exposed?
You paste logs, config or error output into an AI chat without checking for keys first. Your .env file is not in .gitignore, or an agent commits with “add everything”. The same key has lived for months and you’ve never replaced it.
Keep secrets out of the repo and harder for the AI to read: list .env in .gitignore, and add deny rules in your tool (in Claude Code, "Read(./.env)" under permissions.deny, which covers its file tools and common shell commands like cat but not every script it could run). Turn on secret scanning and push protection in your repository host (they are off by default for repositories, and private repos need GitHub Secret Protection), so pushes containing a recognised key pattern are blocked. People with write access can bypass a block, so treat it as a safety net, not the only guard. If a key ever leaks, revoke and replace it right away. Deleting it from the code or history is not enough.
Ask your AI tool to fix it
Paste this into Cursor, Claude, Lovable, Bolt or whatever you build with.
Audit this project for leaked secrets. Search the code, config files, docs and git history for API keys, tokens and passwords. Make sure .env files are in .gitignore, move any hard-coded secret into an environment variable, and list every key you found so I can revoke and replace it. Do not print the key values: show only the file and line number, and a masked prefix at most. Do not commit or push anything.Where this comes from
The facts, figures and fixes on this page were checked against these sources on 25 Oct 2026. They are linked so you can check for yourself.
- The State of Secrets Sprawl 2025GitGuardian23,770,171 new secrets found in public GitHub commits in 2024
- About push protectionGitHub DocsPush protection blocks pushes containing secrets before they reach the repository
- About secret scanningGitHub DocsScans full Git history for hardcoded credentials; advises revoking or replacing exposed ones
- Secrets Management Cheat SheetOWASPExposed keys should be revoked immediately; hardcoded secrets in source code are a common problem
- Best practices for preventing data leaks in your organizationGitHub DocsRevoke exposed credentials; git revert leaves the sensitive commit in history
- Claude Code settingsAnthropicpermissions.deny rules such as Read(./.env) stop Claude Code reading .env files
Spot a mistake or something out of date? Report a correction · How these guides are made and checked
The free, open-source scanner checks for most of the problems in these guides.