You have clicked "Yes, and don't ask again" in Claude Code more times than you can count. Me too. It feels like a tiny productivity win.
Here is what happens next. Per the Claude Code permissions docs, when you pick that option on something like a Bash command, Claude Code saves the rule to .claude/settings.local.json at the root of your git repository. If the command you approved had a token in it, the rule can have the token too.
That is not a theory. Ars Technica reported on Nov 9, 2026 that researchers at Apiiro found over 100,000 Claude Code local settings files uploaded to public GitHub repos. Only about 1,100, from 63 organizations, held secrets such as API tokens, database passwords and private keys. Small share, real damage. And 215 of those secrets were not flagged by two popular scanners, gitleaks and TruffleHog.
Per the same report, a Claude Code team member said these files should pretty much never be checked into git, and that the team was looking into improvements. Behavior may have changed since, so check your version. In the meantime, here is a five-minute check you can run today.
Step 1: is the file tracked?
In each repo where you use Claude Code:
git ls-files .claude/settings.local.json If it prints the path, git is tracking it. No output is what you want. Then check history, because a file you deleted last month can still be in old commits:
git log --all --oneline -- .claude/settings.local.json Step 2: look for secrets in it
Scan the file with gitleaks. The --redact flag keeps the secret itself out of your terminal output:
gitleaks dir --redact -v .claude gitleaks git --redact -v . The first scans the folder as it is now. The second scans every commit.
I tested this on a throwaway repo where I committed a fake GitHub-style token inside an approved curl command. gitleaks flagged it as github-pat in .claude/settings.local.json on line 1. That is the happy path. The Apiiro numbers above are why you should not stop here. Scanners know patterns, and 215 secrets slipped past two of them.
So also read the file yourself. Open it and look at every Bash(...) rule for anything that looks like a key, a password or a URL with credentials in it. It is usually short.
Step 3: check all your repos at once
Point this at the folder where you keep code:
find ~/code -path '*/.claude/settings.local.json' -not -path '*/node_modules/*' 2>/dev/null | while read -r f; do repo=$(git -C "$(dirname "$f")" rev-parse --show-toplevel 2>/dev/null) || continue if git -C "$repo" log --all --oneline -- .claude/settings.local.json | grep -q .; then echo "IN HISTORY $repo" fi done Every line it prints is a repo where that file is, or once was, in git. Repos it does not list are fine on this check.
Step 4: fix it, in this order
- Rotate the secret first. Revoke it at the provider and make a new one. If it was ever pushed to a public repo, treat it as exposed, because other people can clone and fork it. Ars notes that secrets can persist in forks even after the file is removed from the original.
- Stop tracking the file:
git rm --cached .claude/settings.local.json echo '.claude/settings.local.json' >> .gitignore git add .gitignore git commit -m "Stop tracking local Claude Code settings" - Clean the file. Remove any rule that has a secret in it. You can see and manage rules inside Claude Code with
/permissions. - History is last, not first. Rewriting git history is messy and does not fix a secret that already left your machine. Rotation does. Rewrite only if you need to for compliance.
Claude Code's own docs add one more reason to keep the file out of git: if .claude/settings.local.json is tracked, it is treated as repository-supplied instead of your own, and its rules are held until you trust the folder. A tracked file is not how it is meant to be used.
If the thing that leaked was a wallet private key or seed phrase, moving funds comes before anything else, and the rotation advice above does not apply, because a key cannot be rotated the way an API token can. If you hold crypto and want the scam side covered too, the free Don't Get Drained guide is a short read on spotting fake support DMs and claim links.
Stop it happening again
- Keep secrets out of the command text. Write
curl -H "Authorization: Bearer $API_TOKEN" ...and keep the value in your environment. Since the command text is what gets saved, the rule then holds the variable name, not the token. - Look at the rule before you save it. The prompt shows what "don't ask again" will allow. If the command has a secret in it, pick "Yes" once instead.
- Deny reads of key files. The docs show a
Read(./.env)deny rule, plus patterns likeRead(./secrets/**). They are also clear that these rules are not a complete block, for example they do not stop a script that opens files itself. For a hard limit, turn on the sandbox. - Scan before you commit. gitleaks works with pre-commit. Put this in
.pre-commit-config.yaml, then runpre-commit install:
repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.24.2 hooks: - id: gitleaks Run pre-commit autoupdate to bump that version. You can also use gitleaks git --staged --redact . as a manual check.
- Turn on GitHub push protection. GitHub says its push protection for users is on by default and stops you pushing secrets to public repositories. It is another net, and like every scanner it only catches what it recognizes.
Which control catches what
| Control | Helps with | Does not help with |
|---|---|---|
.gitignore for the file | Accidental git add . | Files already committed earlier |
gitleaks dir / git | Known token formats, in files and history | Secrets in formats it does not know (the 215 above) |
| Pre-commit hook | Catching it before the commit exists | Anyone who skips the hook |
| GitHub push protection | Known secret types at push time | Unknown formats, and pushes where someone bypasses it |
| Env vars instead of inline values | Keeping values out of saved rules | A key you already typed in |
| Rotation | Any exposed API token or password | Wallet keys, and leaks you do not know about yet |
Want to go deeper?
Start with the free Agent Blast Radius Checklist. It is 9 pages for seeing what your coding agent can read, run and reach, then cutting it down.
If your agents also touch wallets, API tokens or signing power, Agent Security When Agents Hold Keys ($12) is the plain-English playbook for shrinking the blast radius. All ten PTS AI + blockchain guides are in one $39 bundle, and there is a free AI + Blockchain Map if you want a 10-minute start.
The newsletter is at https://paxtechservices.substack.com if you want more notes like this.
I'm PTS, an IT and security consulting shop. Corrections welcome in the comments. Not affiliated with Anthropic or GitHub. Educational only, not legal or financial advice.