Claude Code settings.local.json secrets: check your repo and fix it
Claude Code settings.local.json secrets are an easy leak to miss. When you pick "Yes, and don't ask again", Claude Code can save the exact command in .claude/settings.local.json, password and all. Security firm Apiiro found 1,122 public copies of that file on GitHub with at least one secret inside. Here is how to check your repo and its history, what to rotate, and how to keep secrets out of the file from now on.
QUICK CHECKLIST
- Check if .claude/settings.local.json is tracked
- Search git history for old versions
- Rotate every secret the file ever held
- git rm --cached it and add it to .gitignore
- Delete allow rules that contain secrets
- Approve patterns, not single commands
How Claude Code settings.local.json secrets happen
Claude Code asks before it runs most shell commands. If you choose "Yes, and don't ask again", it saves an allow rule in .claude/settings.local.json in your project, so the same command runs without asking next time.
Sometimes the rule is a pattern, like npm test *. Sometimes it is the exact command you approved. If that command had a password or token typed into it, for example PGPASSWORD=... psql or sshpass -p ..., the secret is now in a plain JSON file in your project folder.
Claude Code tries to keep the file out of git. The first time it writes the file in a repo, it adds it to your global git excludes on that computer. That protects you on that one machine. It doesn't help if the file was already committed, if you created it by hand, or if a teammate clones the repo on a machine without that exclude, because the project's own .gitignore never mentions it.
What Apiiro found on public GitHub
Apiiro searched public GitHub and found 104,185 copies of the file in 103,617 repositories. About 1.1% of them, 1,122 copies, held at least one secret, 1,379 different secrets in total. They didn't test whether the secrets still worked, but one company they notified confirmed its key had been live.
| Secret type | Count in public files | What it opens |
|---|---|---|
| Database passwords | 379 | Your data, directly |
| SSH logins | 43 | Public servers |
| GitHub, GitLab, npm tokens | 42 | Code and packages |
| AWS keys | 23 | Cloud accounts |
Selected counts from Apiiro's scan of 1,122 files with secrets, as reported by The Hacker News on Nov 7, 2026.
Two more numbers matter for you. Older versions of the file held 734 more secrets in 509 repos that no current copy has, usually because the file was deleted. And common scanners missed many of these files: of the 1,122, gitleaks flagged 564 and TruffleHog 643, and neither flagged 215. Most misses were passwords typed inside commands, which look like ordinary words to a scanner that hunts for known key formats.
So "my secret scanner was green" is not enough here. Open the file and read it.
Check your repo in two minutes
Run these in the root of each repo you use with Claude Code.
# 1. Is the file tracked right now? git ls-files .claude/ # 2. Was it ever committed? (also finds deleted versions) git log --all --oneline -- .claude/settings.local.json .claude/settings.json # 3. Show what old versions contained git log --all -p -- .claude/settings.local.json | grep -Ei 'password|passwd|token|secret|key|sshpass|PGPASSWORD|mysql -p|://[^ ]*:[^ ]*@' # 4. Why is it ignored on this machine? (global exclude vs .gitignore) git check-ignore -v .claude/settings.local.json
If step 4 points to a global excludes file and not to your repo's .gitignore, the protection lives only on your computer.
On GitHub, search your account or organization for the file across all repos. Code search only covers the current default branch, so step 2 is still needed per repo:
path:.claude/settings.local.json org:YOUR-ORG
Also open the file on your own laptop, even if it was never committed. It is plain JSON, and it can end up in a zip, a Docker image, an npm package or a synced folder.
Fix it: rotate first, then clean up
Do these in order. Rotation comes first, because cleaning git doesn't make a leaked secret safe again.
Rotate every secret the file ever held
Change each database password, token, SSH login and API key found in the current file and in old versions. Start with anything paired with a public server address, because those give direct access. See rotate keys after a breach.
Stop tracking the file
Run
git rm --cached .claude/settings.local.json, then add.claude/settings.local.jsonto the repo's own.gitignoreand commit both. Your local copy stays.Clean the local file
Open
.claude/settings.local.jsonand delete every allow rule with a password, token or key in it. Delete rules you don't remember approving, too.Check the shared settings.json
Teams commit
.claude/settings.jsonon purpose. Apiiro found secrets in 298 copies of it, mostly in allow rules. Make sure it only holds patterns and variable names.Decide on history
If the repo is public or has forks, assume the old secret is known, even after a rewrite. Rewriting history is optional once you have rotated. See find secrets in git history.
Do the same in every repo where you used Claude Code, not just the one that made the news for you.
Stop it happening again
Keep secrets out of the commands you approve. Put them in env vars or a secrets manager and refer to them by name, so the saved rule holds $DATABASE_URL and not the password.
Approve patterns instead of one-off commands. A rule like Bash(npm run test:*) is safe to save. A rule with a full connection string in it is not.
Add these lines to every project's .gitignore, so the protection travels with the repo:
.claude/settings.local.json .env .env.*
The same goes for other agent folders. Treat .cursor/, .gemini/ and agent chat logs like .env files: they can hold secrets on your laptop and in your repo. For the wider setup, see the Cursor and Claude Code security checklist.
Fix prompt you can paste
Paste this into Claude Code or Cursor in a repo you own. It reports first and changes nothing until you approve.
Audit this repo for secrets saved by AI coding tools. Do not change any files yet. Only report, and mask every secret value (show at most the first 4 characters). 1. Is .claude/settings.local.json tracked by git? Was it ever committed? Check git history including deleted versions. 2. List every allow rule in .claude/settings.local.json and .claude/settings.json that contains a password, token, API key, connection string with credentials, sshpass, PGPASSWORD or mysql -p. Give file and line. 3. Check .mcp.json, .cursor/mcp.json and .cursor/ for hardcoded tokens. 4. Does the project .gitignore list .claude/settings.local.json and .env files? Then propose, without applying: which secrets I must rotate (I will do that myself), the git rm --cached command, the .gitignore lines to add, and replacement allow rules that use patterns and env var names instead of secrets. Wait for my approval before editing anything.
Check the agent's answer against the commands above. An agent can miss a file it was told to skip.
What Leakcade checks
Leakcade's paid scan reads a public GitHub repo. It flags a tracked .claude/settings.local.json, and looks for secret-shaped values in .claude/settings.json, .claude/settings.local.json, .mcp.json and .cursor/mcp.json, including keys inside allow rules. It also checks git history for deleted copies of the local file. Values stay masked in the report, and each finding comes with a fix prompt.
A plain password typed into a command can look like any other word, so a clean result is not proof. Read the file yourself, and rotate anything you are unsure about. Leakcade can't see files on your laptop, so the local check above still matters.
Further reading
- The Hacker News: Claude Code's "Don't Ask Again" file exposes passwords and keys in 1,122 public copies
- Claude Code docs: Settings
- Claude Code docs: Security
- Git docs: git check-ignore
- GitHub docs: Code search syntax
FAQ
Is .claude/settings.local.json ignored by git automatically?
Only on your computer. Claude Code adds it to your global git excludes the first time it writes the file, but not to the project's .gitignore. If it was already committed, or a teammate clones the repo, it can still be tracked. Add it to .gitignore yourself.
I deleted the file. Am I safe?
No. Old versions stay in git history and in forks. Rotate every secret the file ever held, then stop tracking it.
Will gitleaks or TruffleHog catch it?
Not reliably. In Apiiro's test, neither tool flagged 215 of the 1,122 files with secrets, mostly passwords typed inside commands. Open the file and read it.
Want a second pair of eyes?
We review your whole repo and write a fix prompt for every finding. $19, report within an hour.
Check my repoLeakcade is an automated check. It can miss vulnerabilities and is not a substitute for a professional security audit or pentest. Provided as is. You stay responsible for your code. Where the law allows, our liability is limited to what you paid ($19). Terms