Claude Code: keys in .claude/settings.local.json
When you approve a Bash command with "Don't ask again", Claude Code saves the command verbatim in an allow in the project's .claude/settings.local.json file. If the command contained a password or key, that gets saved too. The file is meant to stay local, but it can end up in : if it was created by hand, added with git add -f, or was already a tracked file. Apiiro's research found 1,379 real secrets (database passwords, SSH logins, tokens) in 1,122 public GitHub files, and 2,539 with a broader search. Secret scanners missed some of the files. The sources differ on the numbers: the newsletter says 1,122 files, other articles say 1,379 or 2,539 secrets; these are different measurements.
- K1aCheck run this in every project:
git ls-files | grep settings.local.jsonandgit log --all --oneline -- .claude/settings.local.json, then look in the file forBash(...)rules containing a password, a-pflag or a token. - K1bFix first rotate every key and password that ever appeared in the file, because deleting it doesn't invalidate copies already out there. Then:
git rm --cached .claude/settings.local.json, add it to.gitignore, and delete the rules containing secrets. - K1cGrantGuard Vanta's open-source tool reviews Claude Code's "always allow" rules and flags risky ones (hardcoded keys,
rm -rf,git push *). Run: ; to include project folders, add the--scanflag. It only reads, and deletes only after confirmation. github.com/OpenVanta/GrantGuard
1. Check: where settings.local.json files are on your machine, and whether they ended up in git.
find ~ -path '*/.claude/settings.local.json' -not -path '*/node_modules/*' 2>/dev/null
cd <project-folder> && git ls-files .claude/settings.local.json && git log --all --oneline -- .claude/settings.local.json
grep -nEi 'pass|token|secret|key|-p[^ ]' .claude/settings.local.json2. If you find a key or password: rotate it first (database password, SSH key, key), because deleting the file doesn't neutralize copies that already leaked.
3. Do it: remove the file from git and delete the allow rules that contain secrets.
git rm --cached .claude/settings.local.json
echo '.claude/settings.local.json' >> .gitignore
git commit -m "Remove settings.local.json from git"4. Verify: git ls-files .claude/ – the file is no longer listed; GrantGuard (K1c) reports no hard-coded keys.
Roll back: not needed; don't restore the old keys.
$DB_PASS), so the approved rule stores only the variable name, not the password itself. Type your question and open it in your favourite AI chat. The item's background is added automatically. Nothing is stored on our side.