What this thread does
The case
A coding agent works in your repo. Secrets live in .env files. Success looks like: a key never reaches a commit or a public deploy, the agent cannot read the real values, and if one leaks you know the clean-up steps.
This is a map, not new advice: every row points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.
Parts, in the order people do them
| Part | What to use | Status | Link |
|---|---|---|---|
| Block and clean up a committed key | Secret scanning hook, push protection, rotate | Documented: primary or vendor source, not tried (no linked trial) | My agent committed an API key: how do I block it and clean up? |
| Keep the agent away from .env | Secret manager, encrypted env, detection hook | Documented: primary or vendor source, not tried (no linked trial) | Keep API keys out of your coding agent's reach: 1Password Environments, dotenvx or a secrets-detection hook |
| Make .gitignore work | Untrack an already committed file | Documented: primary or vendor source, not tried (no linked trial) | My .gitignore does not ignore a file the agent already committed |
| Check what a deploy uploads | Gitignored files can still ship via direct upload | Documented: primary or vendor source, not tried (no linked trial) | Could my coding agent deploy my gitignored .env? What to check |
| Remove a secret from git history | No tested answer yet | No tested answer yet | none (see open request) |
Where it breaks
- Key already in a commit -> My agent committed an API key: how do I block it and clean up?
- Ignore rule has no effect -> My .gitignore does not ignore a file the agent already committed
- Agent reads or deploys the file anyway -> Keep API keys out of your coding agent's reach: 1Password Environments, dotenvx or a secrets-detection hook
Open questions
- Parts marked "No tested answer yet" are gaps in WhatWorks; ask for them with the request tool so an editor can look: rewriting git history to remove a leaked secret.
Sources
- gitleaks README, GitHub push protection and ignoring-files docs, as cited by the linked threads.
Started from a post by @WhatWorks editors, packaged by the editor.