How do you keep an AI coding agent's saved approvals from committing secrets?
An agent that remembers an approval can save a secret into a file inside the repo. Keep that file out of git, and do not approve the literal command.
2 min readDEV GroupApplied AI · Security
Approvals can save the secret
Keep the file an agent uses to remember an approval out of git, and do not approve a command that has a secret written into it. An assistant that remembers an always-allow decision for one command can save the full command, including an inline password, API token, or database URL, in a local settings file inside the repository. A common path is .claude/settings.local.json. The file sits next to the code, so it is easy to commit and push. Public reporting on 9 November 2026 found 100,000 or more of those settings files in public GitHub repositories. About 1,100 of them, from 63 organizations, contained real secrets. A secret removed from the current file can persist in forks.
Keep the file out of git
Ignore agent-local settings in a global gitignore, so every repository on the machine skips files Git is not already tracking, and in the repository .gitignore, so the rule travels with the project. If an approval file is already tracked, remove it from the index with git rm --cached and commit that change. Until then, ignore rules do not apply, and a later edit can still commit a new secret. Approve a command pattern, not the literal command when that command contains a secret. Pass secrets through the environment or a secret manager. A secret placed in an argument is a secret the agent can save.
Scan, then rotate
Scan for secrets before commit, and again on the server with push protection, so a key that reaches a commit is rejected before it is public. When one leaks, rotate the credential first, then purge it from history. Deleting the file is not enough: forks and caches keep a copy. How to scope a credential and prove it no longer works is its own note. Keeping approval files out of git, approving patterns instead of secret-bearing commands, and scanning on the way to the remote are software work, and that is where we fit.
- Related: deciding whether an AI agent's action actually runs
- Related: why an AI agent's tool list can't be its permission system
- Related: keeping a dependency install from running with developer-machine secrets
- Related: keeping integration and automation tokens from becoming a breach
- How we work: scope, prototype, ship, run
- Coding agents saving command approvals in the repo? Start a conversation
Sources
- Public reporting on agent approval files committed with secrets. Public reporting. November 9, 2026.
Was this useful?
Related notes
Applied AI3 min read
How do you keep a stolen AI API key from running up the bill?
Stolen AI provider keys from a hosting breach ran up about $740,000. Cap each key's spend, watch usage like fraud, and rotate without a rebuild.
- Secrets
- Tokens
- Spend limits
- Monitoring
Applied AI1 min read
How do you stop an AI coding agent from installing an MCP server that will never get a patch?
A coding agent will install a package name from memory. Allow one MCP server per service, and reject archived packages before they run.
- MCP
- Agents
- Dependencies
Applied AI1 min read
How do you catch an AI feature that is confidently wrong while monitoring stays green?
Uptime stays green while an AI feature is confidently wrong. Measure whether the answer was right, and gate releases on real failures.
- Evaluation
- Monitoring
- Agents