// guide · Claude Code · secrets · Nov 10, 2026
Did Claude Code commit your secrets? Check .claude/settings.local.json in 2 minutes
Short answer
Clicking “Yes, and don't ask again” in Claude Code saves the approved command to .claude/settings.local.json, sometimes word for word, so a password or API key typed into that command ends up in the file. The file is only auto-ignored on the machine that created it. Run git ls-files | grep .claude/ and git log --all -- '*.claude/settings.local.json'. If it was ever committed with a secret, rotate the secret first, then untrack the file and add it to your repo's .gitignore.
What happened
Security firm Apiiro published research on November 5, 2026 that searched public GitHub for Claude Code's personal settings file (Ars Technica coverage). Its reported numbers:
- 104,185 public copies of
.claude/settings.local.json; 1,122 held at least one likely real secret (1,379 distinct secrets). - Counting git history, the shared
.claude/settings.jsonand saved agent transcripts: 2,539 secrets across 1,994 repositories. - Largest groups: 379 database passwords and 122 Supabase service_role keys, plus SSH logins, GitHub/npm tokens and AWS keys.
- 734 secrets survived only in older commits after the file was deleted, and forks carried copies too.
- gitleaks and TruffleHog together missed 215 of the 1,122 files (about 19%), mostly plain passwords with no key format.
Apiiro says it did not test whether the credentials worked, so these are likely secrets, not confirmed live ones. Supabase-heavy vibe-coded apps are squarely in the blast radius: a service_role key bypasses Row Level Security on every table.
Why the secret ends up in the file
Anthropic's settings docs say that when you choose “Yes, and don't ask again” on a Bash command, Claude Code saves the approval as an allow rule in .claude/settings.local.json at the root of the git repository. Ask Claude to “check the database” or “call the API” and the command it proposes often carries the credential inline. Approve it permanently and you get a file like this:
{
"permissions": {
"allow": [
"Bash(npm run test *)",
"Bash(PGPASSWORD=Sup3rS3cret psql -h db.abcd.supabase.co -U postgres)",
"Bash(curl -H \"Authorization: Bearer sk-live-...\" https://api.example.com/v1/*)"
]
}
}The same docs say Claude Code adds **/.claude/settings.local.json to your global git excludes the first time it writes the file. That protects the one machine. It does not protect a second laptop, a container or cloud dev box, a folder you turn into a repo later, a file you created by hand, or a file that is already tracked. Nothing in the repository itself says the file is private.
The 2-minute check
Run these in the root of each repo you have used Claude Code in. Start with anything public.
# 1. Is any Claude Code settings file tracked right now?
git ls-files | grep -E '(^|/)\.claude/'
# 2. Was settings.local.json EVER committed (any branch)?
git log --all --oneline -- '*.claude/settings.local.json'If either command prints anything, look inside the current file and every old version:
# 3. Secrets in the current file
grep -nE 'PGPASSWORD|sshpass|Bearer |sk-|sk_live_|ghp_|github_pat_|AKIA|eyJ|://[^:/@ ]+:[^@ ]+@' .claude/settings.local.json
# 4. Secrets in every old version (history survives deletes)
git log --all -p -- '*.claude/settings.local.json' '*.claude/settings.json' '*.mcp.json' \
| grep -nE 'PGPASSWORD|sshpass|Bearer |sk-|sk_live_|ghp_|github_pat_|AKIA|eyJ|://[^:/@ ]+:[^@ ]+@'Also open .claude/settings.json (the shared file teams commit on purpose) and any MCP config (.mcp.json, .cursor/mcp.json,.vscode/mcp.json). They should reference environment variables like ${GITHUB_TOKEN}, never raw tokens.
Fix it in the right order
- Rotate first. Change the database password, reset the Supabase service_role / secret key, revoke the GitHub or npm token, deactivate the AWS key. Deleting the file does not un-leak anything: history and forks keep it.
- Check usage logs for the old credential (Supabase logs, Stripe events, AWS CloudTrail, your AI provider's usage page).
- Untrack and ignore it at the repo level so the next clone is protected too:
# After rotating every secret you found:
git rm --cached .claude/settings.local.json
printf '\n# Claude Code personal settings (approved commands can hold secrets)\n.claude/settings.local.json\n' >> .gitignore
git add .gitignore
git commit -m "Stop tracking Claude Code local settings"- Clean the saved rules. Run
/permissionsin Claude Code and delete any rule with a secret in it (permissions docs). - Keep secrets in environment variables so future approvals save the variable name, not the value:
// Instead of approving a command with the secret inlined...
"Bash(PGPASSWORD=Sup3rS3cret psql -h db.abcd.supabase.co -U postgres)"
// ...export it in your shell or .env (gitignored) and approve the variable form:
"Bash(psql \"$DATABASE_URL\" *)"Rewriting history (for example with git filter-repo) is optional once the secrets are rotated. It removes the copy from your repo but not from forks, clones or caches; GitHub's guide to removing sensitive data covers the details.
Prompt to paste into Claude Code or Cursor
Check this repo for secrets saved by Claude Code or MCP configs:
1. List every tracked file under any .claude/ folder plus .mcp.json, .cursor/mcp.json and .vscode/mcp.json.
2. Show me any permissions.allow rule or MCP setting that contains a literal password, token, API key, JWT or a URL with user:password@. Redact the values when you show them.
3. Check git history for older versions of those files with secrets (git log --all -p).
4. Give me the list of keys I need to rotate, grouped by service. Do NOT rewrite git history or push anything until I confirm.
5. Then untrack .claude/settings.local.json, add it to .gitignore, and rewrite any rule that inlines a secret to read it from an environment variable instead.Check it automatically
RescueMyRepo's free scan flags a committed .claude/settings.local.json and any committed Claude Code settings or MCP config with live-looking keys (OpenAI, Anthropic, Stripe live, GitHub, Slack, AWS, Supabase service_role JWTs, database URLs with passwords and inlineKEY=value secrets), with the evidence redacted and a fix prompt for your AI tool. It also reads every earlier version of those files in your git history, so a key in a settings.local.json you already deleted or cleaned up still gets flagged, with the commit it lives in. A separate gitleaks pass scans the history for known key formats. It checks Supabase RLS, Stripe webhooks and unauthenticated AI routes in the same run.
FAQ
Why does .claude/settings.local.json contain my password or API key?
When Claude Code asks to run a shell command and you pick "Yes, and don't ask again", it saves that approval as a permissions.allow rule in .claude/settings.local.json. If the approved command had a secret typed into it, for example PGPASSWORD=... psql or curl -H "Authorization: Bearer ...", the rule can be the full command string, secret included.
Isn't settings.local.json gitignored automatically?
Only on the machine where Claude Code first wrote it. Anthropic's docs say Claude Code adds **/.claude/settings.local.json to your global git excludes file the first time it writes the file. That does not help on a second machine, in a container or CI checkout, for a folder that becomes a git repo later, for a file you created by hand, or for a file that is already tracked. Add it to the repository's own .gitignore too.
I deleted the file from my repo. Am I safe?
No. Deleting it in a new commit leaves every earlier version in git history, and forks keep their own copies. Apiiro reported 734 secrets that only survive in older commits. Treat any secret that was ever committed to a public repo as compromised and rotate it first.
Do gitleaks or TruffleHog catch these?
Not reliably. Per Apiiro's write-up, gitleaks flagged 564 and TruffleHog 643 of the 1,122 files with secrets, and 215 (about 19%) were caught by neither, mostly plain passwords after PGPASSWORD= or sshpass -p that have no recognizable key format. Grep the file and its history yourself as well.
What about .claude/settings.json and MCP config files?
The shared .claude/settings.json is meant to be committed, so it must never contain secrets; Apiiro counted secrets there too. MCP configs such as .mcp.json, .cursor/mcp.json and .vscode/mcp.json often hold API tokens for MCP servers. Reference environment variables (for example ${GITHUB_TOKEN}) instead of pasting values.
Does RescueMyRepo check for this?
Yes. The free scan flags a committed .claude/settings.local.json, and flags committed Claude Code settings and MCP config files that contain live-looking keys (OpenAI, Anthropic, Stripe live, GitHub, Slack, AWS, Supabase service_role, database URLs with passwords and KEY=value pairs). Since Nov 11, 2026 it also reads every earlier version of those files in the repo's git history, so a key in a settings file you already deleted or cleaned up is flagged too (the case Apiiro found most often). A separate gitleaks pass scans the history for known key formats.
Related
- Is your Lovable app one of the 7,403? Check your Supabase data isn't readable without a login
- Hiding Pro features in the UI isn't a paywall: enforce paid plans in Supabase RLS
- Don't store roles in Supabase user_metadata
Sources
- Ars Technica: Claude Code is accidentally exposing secrets all over GitHub (Nov 2026), reporting Apiiro's research
- Claude Code docs: Settings files and precedence
- Claude Code docs: Configure permissions
- GitHub docs: Removing sensitive data from a repository
Figures are Apiiro's as reported in public coverage, read Nov 10, 2026; not independently reproduced.