Skip to main content
Blog
Back to Blog

Claude Code settings.local.json secrets: check, rotate and prevent

When Claude Code asks to run a shell command and you choose "Yes, and don't ask again", it saves that exact command as a permission rule in .claude/settings.local.json. If the command contained a password, token or connection string, the file now holds it in plain text. On November 5, 2026, the security firm Apiiro reported 1,122 public copies of this file on GitHub holding a real secret, and Anthropic's head of Claude Code said the team is looking at fixes. If you build with Claude Code and push to GitHub, this guide gives you a five-minute check, the order to rotate credentials, how to clean up, how to keep secrets out of approvals and which other agent files to look at. It is useful without a Soloop account and is not a security audit.

The short answer

Every Bash command you approve permanently is stored word for word in .claude/settings.local.json at the root of the repository. Claude Code adds that file to your global git ignore list the first time it writes it in a repository, which covers the usual case on the machine where you work. It does not cover a file that was committed before the ignore applied, a folder that became a repository later, a clone on another machine or a file someone added on purpose, and the ignore rule never travels with the repository.

Check whether the file is tracked or appears in your git history. If it ever held a secret that reached a remote, rotate the secret first; deleting the file does not remove it from history, forks or clones. Then untrack the file, add it to the repository's own .gitignore, delete secret-bearing rules from your local copies and stop typing secrets into commands.

How a secret gets into the file

Ask Claude Code to check why a staging login fails or to run a migration, and the command it proposes may need a credential from your config files, such as a database password after PGPASSWORD= or a bearer token in a curl call. Claude Code asks before running shell commands. After many prompts it is easy to approve a long line without noticing the secret in it. "Yes, and don't ask again" runs the command and stores it, secret included, as an allow rule so you are not asked again.

Apiiro reproduced this with Anthropic's current models, Opus 5.5 and Fable 5.1, and describes it as Claude Code's behaviour rather than the model's. In 539 of the 1,105 repositories with a real secret that it traced, a commit co-authored by Claude had changed the file. Claude Code users have reported the mechanism in GitHub issues since August 2025.

Where approvals go

Choosing "Yes, and don't ask again" for a Bash command saves an allow rule to .claude/settings.local.json, which Claude Code keeps at the repository root. Claude Code adds **/.claude/settings.local.json to your global git excludes file the first time it writes the file in a repository; if you create the file by hand, you must ignore it yourself.

Claude Code docs: Settings
Rule duration

A Bash "don't ask again" approval lasts permanently per repository and command. /permissions lists every rule and the settings file it comes from.

Claude Code docs: Permissions
Scale

104,185 public copies in 103,617 repositories; 1,122 (1.1%) hold a real secret, 1,379 distinct; 2,539 secrets in 1,994 repositories when history, shared settings files and agent transcripts are included. A real secret means a known key format or a password next to a public host, not a tested credential.

Apiiro, November 5, 2026

What was found

More than a third of the distinct secrets open a database directly: 379 database passwords and 122 Supabase service-role keys, plus 103 Supabase account tokens. The rest include API and AI model keys, 43 SSH logins, 42 GitHub, GitLab and npm tokens, 23 AWS keys and 6 private keys. Most belong to individual developers; 63 organizations were affected, from student groups to startups and agencies.

Larger files leak more: one in ten files over 8 KB held a real secret, against fewer than one in 500 under 500 bytes. In the median affected repository the file had been public for 217 days. Earlier versions held 734 secrets in 509 repositories that no current copy shows, usually because the file was deleted without rotating what it contained.

settings.local.json or settings.json?

.claude/settings.json is the shared project file: you commit it on purpose so collaborators get the same permissions and hooks. .claude/settings.local.json is yours for one project and should never be committed. Both can hold allow rules, so keep secrets out of both; Apiiro found real secrets in 298 of 76,011 public shared settings files.

Five-minute check

Run these from the root of each repository you have pushed. They only read; nothing is changed. The commands were tested with git on macOS.

  1. Is the file tracked now? git ls-files -- '*settings.local.json' prints any tracked copy at any depth. No output means none is tracked.
  2. Was it ever committed? git log --all --oneline -- '*settings.local.json' lists every commit that touched it, including ones that later deleted it. Any output means the contents are in history.
  3. Did a secret reach history? git log --all -p -- '*settings.local.json' | grep -nE 'PGPASSWORD=|sshpass -p|mysql .*-p[^ ]|[Bb]earer |://[^:/ ]+:[^@ ]+@' shows lines with a password in a command, a bearer header or a password in a connection string. It is a rough filter: also read the rules yourself for API keys.
  4. What ignores it? git check-ignore -v .claude/settings.local.json names the file and line that ignore it. If it points to your global excludes file rather than the repository's .gitignore, the protection exists only on this machine.
  5. What do your local copies hold? find ~ -path '*/.claude/settings*.json' -not -path '*/node_modules/*' 2>/dev/null lists every copy on your computer. Open each and read its allow list, or run /permissions inside Claude Code.
  6. On GitHub, search your account or organization's code for settings.local.json and check any forks of affected repositories.

What to rotate first

Treat anything that reached a remote as exposed, even if the repository is private now or the file is gone. Start with credentials that work from anywhere against a public host. For each one: issue a new credential, update the places that use it, revoke the old one and check the provider's access logs for use you do not recognise.

Order for rotating credentials found in settings.local.json
DimensionWhy it comes firstWhat to do
Database passwords and Supabase service-role keysDirect read and write access to your data; the most common category Apiiro found.Change the password or roll the key, update your app's environment, then review recent connections.
Cloud keys (AWS and similar)Can create resources and run up bills as well as read data.Deactivate the key, create a new one with the least access it needs and check billing and activity logs.
SSH logins and private keysA server login, sometimes as root, to a public host.Change the password or remove the key from authorized_keys, prefer key-based login and review recent logins.
GitHub, GitLab and npm tokensCan push code or publish packages under your name.Revoke the token, create a narrower one and check recent pushes and package versions.
API and AI model keysUsually billable usage and access to whatever the service holds.Roll the key in the provider dashboard and set a usage limit where the provider offers one.

Clean up the repository and your machine

  1. Untrack the file without deleting your copy: git rm --cached .claude/settings.local.json, then commit.
  2. Add **/.claude/settings.local.json to the repository's own .gitignore so the rule travels with every clone, then commit that too.
  3. Open each local copy and delete every rule that contains a secret, or remove it in /permissions. A rule approved once stays until someone deletes it.
  4. Decide whether to rewrite history. Rotation is what makes an exposed secret useless; rewriting history removes the old values from your repository but not from forks or clones that already exist.
  5. Check other places the file can leave without git: a published npm package, a Docker image built with a copy of the whole folder, a zip archive or a synced folder.

Stop the next leak

The lasting fix is to keep secrets out of the commands you approve. Put credentials in environment variables or a secrets manager and refer to them by name, so a saved rule records $DATABASE_URL instead of the password. Wrap routine tasks in a script and approve the script, or approve a pattern such as Bash(npm run *), instead of approving a long literal command.

Illustrative example, not a real credential. Before: "Bash(PGPASSWORD=example-not-real psql -h db.example.com -U app -c \"select 1\")" is saved with the password in it. After: a package script named db:check runs psql "$DATABASE_URL" -c "select 1", the variable lives in your untracked .env, and the saved rule is "Bash(npm run db:check)".

  • Add **/.claude/settings.local.json to every repository's .gitignore and to any project template you reuse.
  • Add deny rules such as Read(./.env) and Read(./.env.*) so Claude Code's file tools do not read your secret files.
  • Read the whole command before choosing "Yes, and don't ask again"; approve once when a command contains a credential.
  • Install a pre-commit hook that refuses a staged settings.local.json (copy it below).
  • Keep the secret scanning your code host offers switched on; public GitHub repositories are scanned automatically.
  • Use a scanner in pre-commit or CI that also catches passwords inside commands, not only known key formats.

Copy the pre-commit hook

Save this as .git/hooks/pre-commit in each repository and make it executable. It blocks any commit that stages the file, wherever it sits in the repository. Hooks are local to your clone, so the .gitignore line above is still needed.

Download Markdown

Check the other files agents write

The same habit, a secret typed into a command an agent then records, leaks through other files. Apiiro checked these public files on GitHub; treat agent folders such as .claude/, .cursor/, .gemini/ and .specstory/, and agent memory files, as secret-bearing, like .env.

Shared .claude/settings.json

298 of 76,011 files held a real secret, mostly in allow rules as exact command lines.

Agent chat transcripts

120 files in 87 repositories, from .specstory, aider and Cursor exports (2,523 checked).

Agent memory files

9 repositories, in files such as MEMORY.md (1,200 checked).

Handoff and deploy notes

33 files (2,095 checked); a third of those with a secret were written by the agent.

What Anthropic has said

On November 7, 2026, Boris Cherny, Anthropic's head of Claude Code, replied on Hacker News that Claude Code has historically not scrubbed secrets but that the team is looking into prevention, naming auto mode catching this and basic built-in secret scanning as options to prototype. According to Apiiro's summary, he also said Claude Code gitignores the file when it creates it, so he believes exposed copies were created by hand and checked in, and recommended the secret scanning that code hosts provide.

As of November 10, 2026, we had not seen a released fix. Until one ships and you have updated, assume the behaviour described here still applies.

Copy the checklist

Use one copy per repository. Record what you found and what you rotated so you can answer a customer or collaborator who asks later.

Download Markdown

Where Soloop fits

Soloop does not scan repositories for secrets, read your Claude Code settings or rotate credentials. Use the commands above, your code host's secret scanning and your providers' dashboards for that.

Soloop is for what comes after the build: according to the Soloop manual, it can research a market with sources, write and publish X posts and replies through a connected account, send outreach through a connected Gmail account and prepare Google Ads search campaigns after setup and payment, with actions waiting for your approval by default. Do not paste secrets into any AI tool's prompt, including Soloop's.

Sources, limitations and refresh

The Claude Code Settings and Permissions documentation and Apiiro's report were read on November 10, 2026. Apiiro's figures come from read-only GitHub searches on November 1 to 3, 2026; it did not test whether any credential worked. Anthropic's response is cited from Apiiro's summary of the Hacker News thread. The commands, rotation order, example and hook are editorial guidance tested on a sample repository, not a security audit or a statement from Anthropic.

This guide will be reviewed by February 10, 2027, or sooner if Claude Code ships secret scanning or changes where approvals are stored.

Secret scanning on GitHub

Public repositories are scanned for secrets automatically at no cost; secrets matching a partner's format are reported to that provider.

GitHub Docs: About secret scanning
Product capability

The Soloop manual describes research with sources, X posting through a connected account, Gmail outreach and Google Ads search campaigns after setup and payment; approval comes first by default. It does not scan repositories.

Soloop product manual