Claude Code's "don't ask again" leaked your keys? Check .claude/settings.local.json
By Arif Khan, AIVolve LLC · Updated November 13, 2026
"I clicked 'Yes, and don't ask again' in Claude Code. Did my password or API key end up on GitHub?"
Short answer: it might have. When you pick "Yes, and don't ask again" on a command, Claude Code saves that command as an allow rule in .claude/settings.local.json in your project. If a password, token or key was typed into the command, it is saved too, in plain text. Claude Code tries to keep that file out of git, but the protection lives only in your own computer's git settings. On November 5, 2026, the security company Apiiro reported 1,122 public copies of the file on GitHub that hold at least one secret. Check your repo and its history now. If you find a secret, rotate it first, then stop tracking the file, add it to your project's .gitignore, and delete the secret rules on your computer.
What happened
Apiiro researchers Shmulik Cohen and Matan Giladi published the research on November 5, 2026, and The Hacker News covered it on November 7. What they report:
- They found 104,185 public copies of
.claude/settings.local.jsonon GitHub, in 103,617 repositories. - 1,122 of those files (about 1.1%) hold at least one secret. Together they hold 1,379 distinct secrets.
- More than a third open a database directly: 379 database passwords and 122 Supabase service-role keys. Another 103 are Supabase account tokens. The rest include 43 SSH logins, 42 GitHub, GitLab and npm tokens, and 23 AWS keys.
- Two common secret scanners, gitleaks and TruffleHog, both missed 215 of the 1,122 files. Most misses were passwords typed inside commands, like after
PGPASSWORD=ormysql -p. - Older versions of the file, which no longer exist in any current copy, held 734 more secrets in 509 repositories. Deleting the file did not remove them from git history.
Two honest caveats. Apiiro did not test whether any secret still works. It counted a value as a secret when it matched a known key format, or when a password or token sat next to a public server address, and an AI reviewer agreed. Apiiro also sells security products. Still, one company they notified confirmed its key had been live. I think that is reason enough for anyone who uses Claude Code to spend ten minutes on the checks below.
Anthropic's head of Claude Code, Boris Cherny, replied on Hacker News on November 7. According to Apiiro's update, he said the team is "looking into what we can do to prevent this", including "building in basic secret scanning". Until something ships, the checks are on you.
How a secret gets into the file
Claude Code asks before it runs most shell commands. Anthropic's permissions docs say that for a Bash command, "Yes, and don't ask again" lasts "permanently per repository and command", and that Claude Code "saves the rule to .claude/settings.local.json at the root of the git repository."
Sometimes the saved rule is a pattern, like npm test *. Sometimes it is the exact command. Ask Claude Code why login fails on staging, and the command it proposes may carry the database password from your config file, because the command can't work without it. Approve it for good, and the whole line, password included, is saved in the file's allow list.
Claude Code does try to keep the file private. Its settings docs say that the first time it writes the file in a git repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file. That works on your computer. Apiiro points out what it doesn't cover: a folder that becomes a repo later, a copy on another machine, or a file someone already committed. The rule never goes into the project's own .gitignore, so nothing travels with the project. In 539 of the 1,105 repositories with a secret that Apiiro traced, a commit co-authored by Claude had changed the file.
Step 1: Check whether the file is public, or ever was
Run these in your project folder, in a terminal. They only read; they change nothing.
Is the file tracked by git right now?
git ls-files ':(glob)**/.claude/**'
Any output means those files go to GitHub with every push.
Was it ever committed, even if it's gone today?
git log --all --oneline -- ':(glob)**/.claude/settings*.json'
Any output means a version of the file is in your history, and in every fork and clone made since.
Does that history contain anything that looks like a secret?
git log --all -p -- ':(glob)**/.claude/settings*.json' | grep -nE 'PGPASSWORD=|sshpass -p|mysql .*-p|://[^/ ]+:[^@ ]+@|Bearer |sk_live_|sk-proj-|sk-ant-|sb_secret_|eyJ|service_role|ghp_|npm_|AKIA'
This pattern catches the shapes Apiiro describes (passwords after PGPASSWORD=, sshpass -p or mysql -p, connection strings with a password, bearer headers) plus common key prefixes. It is a hint, not a guarantee. Read the allow lists yourself too. To check a file for known key formats without uploading it, paste it into our free leaked-keys checker.
If your code lives on GitHub, you can also search there. In GitHub's code search, try path:.claude/settings.local.json org:YOUR-ORG or path:.claude/settings.local.json user:YOUR-USERNAME, and the same with settings.json. Each hit in a public repository is a file anyone can read.
Other AI tool folders deserve the same look. Apiiro also found secrets in agent chat transcripts (.specstory, aider and Cursor exports), agent memory files and handoff notes, and recommends treating folders like .claude/, .cursor/, .gemini/ and .specstory/ like .env files. To see whether any of them are tracked:
git ls-files ':(glob)**/.cursor/**' ':(glob)**/.specstory/**' ':(glob)**/.gemini/**'
Step 2: Rotate every secret the file ever held, first
This is the step that actually fixes the leak. Removing the file does not, because older versions stay in git history, forks and clones.
For each secret you found, create a new one and retire the old one at the provider: change the database password, roll the API key, revoke the token. Then update the places your app reads it from (your host's environment variables, Supabase secrets, and so on).
If a Supabase service_role or secret key is on the list, follow Supabase's order, which matters: here's the step-by-step for Supabase keys. Apiiro counted 103 Supabase account tokens too. Those control every project in the account, so revoke them on your Supabase account's Access Tokens page as well.
Do the rotation before you clean up. Apiiro's advice is "rotate first, clean up second". Cleanup without rotation leaves a working key in public history.
Step 3: Stop tracking the file and ignore it in the project
git rm --cached .claude/settings.local.json
printf '\n.claude/settings.local.json\n' >> .gitignore
git add .gitignore
git commit -m "Stop tracking Claude Code local settings"
git push
git rm --cached removes the file from git but keeps it on your computer. The .gitignore line protects the project for everyone who clones it, not just your machine. If you prefer, open .gitignore in your editor and add the line .claude/settings.local.json by hand.
Leave .claude/settings.json alone if your team shares it on purpose. Anthropic's docs say that file is meant to be committed. Just make sure it holds no secrets: Apiiro found secrets in 298 of 76,011 shared copies, mostly inside allow rules.
Should you rewrite git history to remove old versions? It's optional. It can help, but it can't reach forks and clones that already exist, which is why rotation comes first.
Step 4: Clean the file on your computer, even if it was never committed
The file is plain JSON in your project folder. Apiiro notes it can leave your machine in other ways too: inside an npm package, a Docker image, a zip file or a synced folder. And a secret you approved once stays in the file until someone deletes the rule.
Find every copy on your computer (macOS or Linux):
find ~ -path '*/.claude/settings.local.json' 2>/dev/null
Open each one and read the allow list. Delete every rule that contains a password, token, key or connection string. In Claude Code, the /permissions command lists every rule and the settings file it comes from, and lets you remove rules.
Step 5: Keep secrets out of commands from now on
- Use environment variables. Put the secret in your
.envfile or your secrets manager and refer to it by name, likepsql "$DATABASE_URL". Then a saved rule records$DATABASE_URL, not the password. - Approve patterns, not one-off commands. A rule like
Bash(npm run *)covers your scripts without saving any arguments. Anthropic's docs sayBash(npm run:*)means the same thing. - Read the command before you pick "don't ask again". If you can see a password or key in it, choose plain "Yes" instead, so nothing is saved.
- Add a secret scanner that sees history. If you already use one, check that it catches passwords inside commands, not only known key formats. That's the gap Apiiro measured.
How to know you're done
git ls-files ':(glob)**/.claude/**'lists nosettings.local.json.git check-ignore -v .claude/settings.local.jsonprints the.gitignoreline that covers it.- Every secret that ever appeared in the file has been replaced, and the old one no longer works.
- The
allowlist in your local file holds patterns and variable names, not passwords.
A prompt for Claude Code, Cursor or Lovable
Security check for leaked secrets in AI tool settings. Work in two phases. Phase 1, read-only: list every tracked file under .claude/, .cursor/, .gemini/ and .specstory/ in this repo, and every commit in git history that touched .claude/settings.local.json or .claude/settings.json. Search the current files and that history for anything that looks like a password, token, API key or connection string (for example after PGPASSWORD=, sshpass -p, mysql -p, or in a Bearer header). Show me what you find with the secret values masked, and tell me which service each one belongs to. Change nothing. Phase 2, after I confirm I have rotated those secrets: stop tracking .claude/settings.local.json with git rm --cached, add .claude/settings.local.json to this repo's .gitignore, and show me the diff before committing. Do not delete any other files and do not rewrite git history.
FAQ
Does Claude Code save my passwords in settings.local.json?+
It can. When you choose "Yes, and don't ask again" on a command, Claude Code saves an allow rule in .claude/settings.local.json. If the saved rule is the exact command and a password or token was typed into it, that secret is saved too, in plain text.
Is .claude/settings.local.json ignored by git?+
Only on your computer. The first time Claude Code writes the file in a git repository, it adds it to your global git excludes. It doesn't add it to the project's own .gitignore, and that protection doesn't help a file that was already committed or a copy on another machine.
I deleted the file. Am I safe?+
Not yet. Older versions stay in git history and in any forks or clones. Rotate every password, token and key the file ever held first, then stop tracking it and add it to your project's .gitignore.
Should I commit .claude/settings.json?+
That file is meant to be shared with your team, so committing it is normal. Keep secrets out of it. Apiiro found secrets in 298 of 76,011 public copies of the shared file, mostly inside allow rules.
Do Cursor and other AI tools have the same problem?+
Apiiro says Claude Code is the only one of 16 coding agents it compared that is confirmed to save the full approved command in a project file by default. It also found secrets in agent chat transcripts, including Cursor exports, and recommends treating folders like .claude, .cursor, .gemini and .specstory like .env files.
Want a second pair of eyes?
Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day. Get a free X-ray →
Related: Alert: Claude Code may have saved your keys · Supabase anon key vs service_role key · Security audit prompts for AI-built apps · Is my Lovable app secure? The 15-minute check · Free leaked-keys checker
Written by Arif Khan, AIVolve LLC. VibeCoderSOS isn't affiliated with Anthropic, Apiiro or GitHub. Numbers are as reported by Apiiro on November 5, 2026 (updated November 8); commands were tested on November 9, 2026.
Need help?
Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day.
Get a free X-ray →