Guide · November 9, 2026
Claude Code settings.local.json secrets: check your repo and rotate
When Claude Code asks to run a command and you pick “Yes, and don't ask again”, it saves an allow rule to .claude/settings.local.json. For a one-off command, that rule is the exact command — so a password or key you typed inline (PGPASSWORD=…, sshpass -p …, postgres://user:pass@…) is now sitting in a plain-text JSON file in your project.
Claude Code adds that file to your machine's global git excludes the first time it writes it, but not to the project's .gitignore. A file you created by hand, a clone on another machine without that exclude, or a git add -f can still commit it. Apiiro's November 2026 research counted 104,185 public copies on GitHub; 1,122 held at least one secret, and both gitleaks and TruffleHog missed 215 of those (mostly inline passwords). (The Hacker News summary, Claude Code settings docs)
Agent folders are .env files. Treat .claude/, .cursor/ and agent transcripts like secrets until you've checked them.
1. Is the file in git, now or ever?
git ls-files .claude
git log --all --oneline -- .claude/settings.local.json .claude/settings.json
Any output means it's tracked or was. On GitHub, also search your account or org for the filename settings.local.json in path .claude.
2. Look for inline credentials
grep -nE 'PGPASSWORD=|sshpass -p|mysql .*-p[^ ]|://[^:/ ]+:[^@ ]+@|sk_live_|sk-|service_role|_TOKEN=|_SECRET=|PASSWORD=' \
.claude/settings.local.json .claude/settings.json 2>/dev/null
Check the local file even if it was never committed — it's still a secret on disk that other tools and agents can read.
3. Rotate first, then clean up
- Rotate every password, token and key the file ever held. History and forks keep the old copy, so deleting the file revokes nothing.
- Stop tracking it:
git rm --cached .claude/settings.local.jsonand add.claude/settings.local.jsonto the project's.gitignore. - If it's in history, purge it:
git filter-repo --path .claude/settings.local.json --invert-paths, then force-push (and tell collaborators to re-clone). - Delete the saved rules that contain secrets from your local copy.
4. Stop it happening again
- Never type secrets into commands. Use env vars —
psql "$DATABASE_URL"— so a saved rule stores the name, not the value. - Approve patterns (
Bash(npm run:*)) instead of single literal commands. - Run secret scanning on
.claude/,.cursor/and other agent folders in pre-commit and CI, including history, and make sure the rules catch inline passwords, not just key prefixes. - Update Claude Code regularly (
claude update, thenclaude --version); recent releases fixed permission-check bypasses. - If you rely on hooks to block risky commands: a
PreToolUsehook only blocks on exit code 2 (exit 1 is a non-blocking error), and a missing or crashing hook lets the call through unless you set"onFailure": "block"(v2.1.295+). (Claude Code hooks reference)
Check the rest of the app
A leaked database password usually isn't the only hole. Run the free live-site check for keys in your public JavaScript, exposed /.env / /.git, and Supabase tables readable while logged out. The paid repo report now also flags committed .claude/settings*.json files with inline credentials, including ones left in git history.
The VibePreflight team