
I have clicked "Yes, and don't ask again" more times than I can count. It is the button that makes a long Claude Code session usable: approve npm test once, and the agent stops interrupting you every time it needs to run the suite. I clicked it on autopilot, the way you click through a cookie banner, and I never once thought about what the button actually does with the command I just approved.
Security firm Apiiro published research on November 5 that made me stop and open every repo I own. When you pick "don't ask again," Claude Code saves the approved command as an allow rule in .claude/settings.local.json, inside the project folder. The rule is the command itself, word for word. If the command had a database password, an API key, or an SSH login typed into it, that secret is now sitting in a plain JSON file in your repo tree. Apiiro searched public GitHub and found 104,185 copies of that file. In 1,122 of them — about 1.1 percent — there was at least one real secret. Those files held 1,379 distinct credentials between them, including 379 database passwords, 122 Supabase service role keys, 43 SSH logins for public servers, 42 GitHub, GitLab and npm tokens, and 23 AWS keys. The strongest cases Apiiro describes include a database vendor's own admin-level cloud key and the owner password of a medical-records database.
That count is only the current copies of one file. Count git history, the shared settings file teams commit on purpose, and saved agent chat logs, and the total reaches 2,539 secrets across 1,994 repositories, involving 63 organizations. When Apiiro checked, every file with a secret was still on its repository's default branch, and in half of those repositories it had been there for at least 217 days. Apiiro did not test whether the secrets still work, but one company they notified earlier in the week confirmed its key had been live.
I am not writing this because I found my own password on GitHub. I checked, and I did not. I am writing it because the mechanism is so ordinary that "I did not" is mostly luck, and because the protection I assumed was in place does not do what I thought it did.
How a secret lands in the file
The mechanism is not a bug in the usual sense. It is the feature working as designed, with a blind spot.
By default, Claude Code asks before it runs most shell commands. When you answer "Yes, and don't ask again," it writes an allow rule into .claude/settings.local.json at the root of the project, so matching commands run without asking in later sessions. That is documented behavior, in Anthropic's own permissions docs. The catch is what the rule contains. Sometimes the prompt offers a pattern, like npm test *, and the saved rule is a pattern. Sometimes it offers one exact command, and the saved rule is that exact command, verbatim — password and all.
The commands that leak are the ones every working developer types without thinking. A database password passed inline so a migration script can connect: PGPASSWORD=... psql .... A MySQL login with the password flag attached: mysql -u root -p.... An sshpass call, a curl -u user:pass, a connection string pasted into a one-off command because setting up the environment variable felt like more work than typing the URL. I have typed versions of all of these. The difference between a command I typed in a terminal and a command I approved in Claude Code is that the terminal forgets it when the session ends, and Claude Code writes it down in a file that lives next to my source code.
Apiiro reproduced the behavior with the current models, Opus 5.5 and Fable 5.1, so this is not a quirk of an old version. It is how the tool works right now.
The protection I was counting on does not travel
Claude Code does try to keep the file out of git. The first time it writes it inside a repository, it adds the file to your global git excludes — the core.excludesFile on your own machine. Git on that computer then ignores the file in every repository. That sounds like a fix, and on the one machine where it happened, it mostly is.
The problem is everything that setup does not cover. A global exclude lives in one user's git settings on one computer. It does not travel with the project, so a clone on a second machine, a teammate's laptop, or a fresh install has no such entry. It never untracks a file that is already in the index — anything committed before the rule existed stays tracked. And it does nothing at all if the file gets committed before Claude Code writes the exclude, or if the file is committed by something other than a careful git add.
That last case is the one that got me. In 539 of the 1,105 repositories Apiiro traced, a commit listing Claude as a co-author changed the file. Their reading, which I find hard to argue with, is that Claude Code often commits the file itself: the agent finishes a task, commits its work, and the settings file goes along with it, because nothing told git to leave it out. I have watched Claude Code commit at the end of a session. I have never once watched it check whether the commit included its own settings file. The global exclude protected my machine and did nothing for the repository.
Forks spread it further. 211 forks of 74 repositories carry the same secrets as the originals. Older versions of the file hold 734 more secrets across 509 repositories that are not in any current copy, usually because someone deleted the file and assumed that fixed it. Deleting the file does not fix it. Git history keeps the old versions, and forks keep their own copies. The researchers' advice is blunt and correct: rotate first, then clean up. A deleted file with a live password in its history is still a live password.
There is also a second file worth checking while you are at it. The shared .claude/settings.json is the one teams commit on purpose, and 298 of the 76,011 public copies Apiiro found held secrets too, mostly inside allow rules. Same mechanism, different file, and this one nobody even pretends is private.
Your secret scanner probably missed it
The instinct, once you hear about a leak like this, is to run a scanner and move on. Apiiro ran gitleaks and TruffleHog over every public copy of the file, without the tools' verification step. Of the 1,122 files that held a secret, gitleaks flagged 564 and TruffleHog flagged 643. Neither flagged 215 of them — nearly one in five.
The misses are not random. Scanners look for known key formats: an AWS key has a shape, a GitHub token has a prefix, a private key has a header. A password typed inside a command has no shape at all. PGPASSWORD= followed by an ordinary-looking word, or mysql -p with the password attached, reads to a scanner like an ordinary word in an ordinary command line. The secrets most likely to be missed are exactly the ones most likely to be in the file: passwords a human typed into a command, rather than keys a system generated in a recognizable format.
GitHub added its own partial answer this week — secret scanning that reads Actions logs, in public preview for Enterprise Cloud — but it only runs on workflows that finish after you turn it on, and it does not cover generic patterns or AI-detected secrets, so a password typed into a command will likely slip past that too. The honest conclusion is that no scanner I can run today will reliably tell me my repos are clean. The check has to be dumber and more direct than a scanner: open the file and read it.
The five-minute check I ran on my own repos
Here is what I actually did, in the order Apiiro recommends, because the order matters. Rotate first, clean up second. Cleaning up first and rotating later leaves a live secret sitting in git history while you feel safe.
First, I searched GitHub for the file. The search is for .claude/settings.local.json and .claude/settings.json across my organizations, and then git log --all -- .claude/settings.local.json in each repo, because a file that is gone from the current branch can still be sitting in history. If you only check the current checkout, you will miss the 734 secrets Apiiro found in older versions.
Second, for anything the search turned up, the rotation comes before any cleanup. Every password, token, and key the file has ever held gets rotated, even if the file was deleted months ago. This is the annoying part, and it is the whole point: deleting the file feels like fixing the problem, and it is not.
Third, the cleanup itself, which takes about a minute per repo: git rm --cached .claude/settings.local.json to stop tracking it, then add the file to the project's own .gitignore, so the protection travels with the clone instead of living in one person's global excludes. Then open the local file on your own machine and delete every rule that contains a secret, even if the file was never committed. A local copy still ends up in zips, Docker images, synced folders, and npm packages, and in September 2025 the Shai-Hulud worm ran TruffleHog over infected developer machines and flagged more than half of these files as containing secrets. The file does not need to reach GitHub to be a problem.
Fourth, the habit change, which is the only part that prevents the next leak. Keep secrets out of commands entirely: pass them as environment variables from a secrets manager, like $DB_URL, so the saved rule holds the variable name and not the secret. And approve patterns instead of single commands — Bash(npm run:*) rather than the exact line you just typed. A pattern rule cannot leak a password, because there is no password in it. I have also added a line to my AGENTS.md in every repo: never type passwords, tokens, or keys into shell commands. It is a suggestion to the model, not a wall, but it is one more place the rule exists, and the day I forget it is the day I need it written down somewhere.
The part nobody has fixed yet
The most uncomfortable detail in Apiiro's write-up is not the numbers. It is the timeline. A Claude Code user reported this exact behavior — approved commands with API keys and tokens stored word for word in settings.local.json — in a GitHub issue filed on August 11, 2025. An automated bot closed it as "not planned" on January 3, after 60 days without activity. The four related reports Apiiro cites have all been closed the same way, the most recent the day before their research published. None of them got a reply from Anthropic.
Of the 16 coding agents whose documentation Apiiro compared, Claude Code is the only one confirmed to save the full approved command in a project file by default. That is worth sitting with, because it reframes the story. This is not an industry-wide hazard that happened to catch Claude Code first. It is a design choice, specific to this tool, that has been reported for over a year and has not been changed.
I am not going to stop using Claude Code over this, and I do not think you should either. The "don't ask again" button is the reason long agent sessions work at all; without it, every session is a hundred permission prompts, and I would go back to running everything by hand. The trade-off is real, and for most of my work it is still worth it. But the trade-off has a price I was not paying attention to, and the price is that one careless approval, with a password in the command, becomes a permanent public record unless I catch it.
There is a sign of where this should go, and it arrived the same week. VS Code 1.146, released November 11, added a setting that masks environment variables in sandboxed agent sessions: the agent's tools get a placeholder, and the real value is only injected into outgoing HTTPS requests to hosts you name. The agent can use a token without ever seeing it. That is the right shape for the fix — the agent should not need the secret in its context to use it — and it is a setting Claude Code's own permission system could adopt for saved rules. Until it does, the fix is mine to make, five minutes per repo, starting with the file I assumed was already protected.
Check yours before your next allow rule. The button is still worth clicking. Just never click it on a command with a secret in it.
← Back to all posts