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.
- Check 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. - Fix 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. - GrantGuard 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
$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.