Did Claude Code save your passwords? Check in a minute
When you pick “Yes, and don’t ask again” in Claude Code, it saves that exact command. If the command had a password or API key in it, the key was saved too. Here’s how to check in under a minute, with nothing to download.
Check it in 3 steps
- Open Claude Code in your project and type
/permissions. It lists every command you’ve told it to stop asking about. - Look for anything that shouldn’t be written down. A password, a token, or a long random string. For example:
Bash(PGPASSWORD=hunter2 psql -h db.example.com) Bash(curl -H "Authorization: Bearer sk-live-4f9a…" https://api.example.com) - Found one? Change that password or key first, then delete the rule. Deleting the rule alone isn’t enough, because the old key may already be copied somewhere.
Do this in each project where you use Claude Code. Nothing there? You’re fine.
One more thing if you use git
Those rules live in a file called .claude/settings.local.json inside your project. Claude Code normally keeps it out of git, but not always. If you ever committed it, assume the key is public and change it. Then add .claude/settings.local.json to your project’s .gitignore.
Stop it happening again
Keep passwords and keys out of the commands you approve. Put them in environment variables or a secrets manager, so the command says $PGPASSWORD instead of the password itself. If a command has to include a secret, choose “Yes” once rather than “don’t ask again”.
What happened
In early November 2026, the security firm Apiiro searched public GitHub for this file. According to the Cloud Security Alliance’s summary, 1,122 of 104,185 public copies held at least one real secret: 1,379 in total, including 379 database passwords. GitGuardian later counted 31,088 secrets in these files across public repositories, 5,343 of them still working when found.
Questions
I never committed settings.local.json. Am I safe?
Probably safer, not finished. Claude Code adds the file to your global git excludes when it first writes it, which keeps it out of most commits. That setting lives on your machine, not in the repository, so a teammate’s clone, a CI job, an npm package or a Docker image doesn’t get it. The secret is also still sitting in plain text on your disk. Remove it and keep the credential out of commands.
Is this only a Claude Code problem?
Apiiro compared 16 coding agents and found Claude Code was the only one confirmed to save the full approved command in a project file by default. Other agents keep settings in folders such as .cursor, .gemini and .codex, and GitGuardian recommends treating those like .env files too.
Won’t my secret scanner catch this?
Not reliably. On Apiiro’s 1,122 files with secrets, gitleaks flagged 564 and TruffleHog flagged 643, and 215 were flagged by neither, according to the Cloud Security Alliance’s summary. A password typed into a command doesn’t have a recognizable format. So read your saved commands yourself; it takes a minute.
Does DriftLock stop Claude Code from saving secrets in this file?
No. DriftLock doesn’t change what Claude Code writes when you approve a command, so use the check on this page for that. DriftLock covers the other ways agents leak secrets: it keeps .env files, SSH keys and cloud credentials away from the model, removes recognizable keys from command output before the model reads it, and locks network commands for the rest of a session after an agent reads something suspicious.
Keep secrets away from your agents in the first place
DriftLock guards Claude Code, Copilot CLI and other AI coding agents on your Mac. It keeps .env files, SSH keys and cloud credentials away from the model, removes hidden instructions from what agents read, and locks network commands for the rest of a session after an agent reads something suspicious. The agent can’t turn it off. It doesn’t change what Claude Code saves when you approve a command, so do the check above too.
We’ll only email you about DriftLock, and we never share your address.
Sources
- Apiiro: Coding agents leaking secrets to GitHub via “Don’t ask again” (original research)
- Cloud Security Alliance research note: Approved once, leaked forever
- GitGuardian: Claude Code settings.local.json secrets on GitHub and Docker Hub
- CSO Online: Claude Code’s “don’t ask again” button has a secrets-spilling problem
- Claude Code docs: settings files
- GitHub docs: removing sensitive data from a repository