Claude Code settings.local.json is your private, per project settings file at .claude/settings.local.json. Claude Code writes your "Yes, and don't ask again" approvals into it as allow rules, and when the approved command had a password or token typed into it, that secret is saved in plain text. Never commit the file: add it to the repository's own .gitignore, search its current copy and its git history for secrets, rotate anything you find, and keep credentials in environment variables so a saved rule only holds a variable name.

This became urgent this week. Security firm Apiiro reported 1,122 public GitHub copies of the file holding at least one secret, out of 104,185 copies it found, and the Hacker News thread passed 400 points on November 7. Below is what the file does according to Anthropic's own docs, what we reproduced on a test repository, and a cleanup you can run in about ten minutes.

What Claude Code settings.local.json is for

Claude Code reads settings from several files. The two inside your project are easy to confuse. The settings documentation describes them like this:

FileWho it applies toMeant for git?
.claude/settings.jsonEveryone who clones the repoYes, commit it
.claude/settings.local.jsonYou, in this one projectNo, keep it local
~/.claude/settings.jsonYou, in every projectNot in any repo

The local file sits above the shared project file, so you can override a team setting (a different model, for example) without touching anyone else. Claude Code creates it the first time you give a standing approval on a permission prompt, and a few /config options such as Show tips also save there.

settings.local.json vs settings.json

Put team policy in settings.json: deny rules, hooks, plugins and the allow rules every teammate should share. Put anything personal or machine specific in settings.local.json. A good test is to ask whether the line would make sense on a colleague's laptop. If it names your database host, your SSH user or a path in your home folder, it belongs in the local file, and the local file belongs outside git. Apiiro also found secrets in 298 copies of the shared settings.json, mostly inside allow rules, so the shared file needs the same audit.

How "Don't ask again" ends up storing secrets

The permissions documentation is clear about what the button does. When you choose "Yes, and don't ask again" for a Bash command or a WebFetch domain, Claude Code saves an allow rule to .claude/settings.local.json at the root of the git repository, and that rule applies to future sessions anywhere in the repo, including worktrees. File edit approvals are not saved; they last until the session ends.

Sometimes the prompt offers a pattern, such as npm test *, and the saved rule is harmless. Other times the rule is the exact command. If that command was PGPASSWORD=... psql -h prod-db ... or sshpass -p ... ssh deploy@..., the password is now a line of JSON in your project folder. The docs add one detail that makes inline secrets worse: an allow rule does not match past a leading assignment of an environment variable outside a small known safe set, so a command that starts with a password assignment cannot be covered by a tidy prefix rule.

This is not new. A bug report from August 2025 described approved commands with API keys stored as is in this file. It was closed as not planned in January after a stale period. In the Hacker News thread, Boris Cherny of the Claude Code team wrote that the tool has not done secret scrubbing so far and that the team is prototyping fixes. As of 2.1.319, the latest release on November 8, the changelog lists no change to how approvals are saved.

Why the gitignore protection is not enough

Claude Code does try to keep the file out of commits. Per the settings docs, the first time it writes the file in a repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes file (core.excludesFile, or ~/.config/git/ignore by default). If you created the file by hand, it does nothing, and the docs tell you to add it to .gitignore yourself.

We tested what that means in practice with two simulated users on one Linux box:

  1. User A had the global exclude line. git add -A skipped the file, and git check-ignore -v named the global excludes file as the reason.
  2. User B, with no exclude line (think a teammate, a container or a CI runner), saw .claude/ as untracked and committed it with the same git add -A.
  3. Back on user A, the exclude line no longer helped. Git never ignores a tracked file, so A's next edit to the file showed up as modified and went into the next commit.

The protection lives in one person's git config on one machine. It does not travel with the repository, and it cannot undo a commit that already happened. Apiiro also reports that in 539 of the 1,105 repositories it traced, a commit listing Claude as coauthor had changed the file, so do not assume a human typed the git add.

How to audit your repositories

Run these from the root of each repository. First, is the file tracked anywhere, now or in the past?

git ls-files -ci --exclude-standard
git log --all --oneline -- .claude/settings.local.json .claude/settings.json

The first command lists tracked files that your ignore rules say should be ignored; a hit for .claude/settings.local.json means it is committed. The second lists every commit that ever touched either settings file, on every branch.

Common scanners are a start but not the finish. On our fake file, gitleaks 8.30.1 caught the GitHub style token and the AWS style key id, and TruffleHog 3.99.8 caught the token and the postgres URL. Neither caught the password after PGPASSWORD=, after sshpass -p, or glued to mysql -p. Apiiro saw the same gap at scale: of its 1,122 files, gitleaks flagged 564, TruffleHog 643, and 215 were flagged by neither. Passwords inside commands look like ordinary words.

So we wrote a small checker aimed at permission rules. It reads the allow, ask and deny lists of a settings file and prints any rule with an inline credential, skipping values that start with $:

import json, re, sys

SECRET = re.compile(
    r"PGPASSWORD=[^\s$]"
    r"|sshpass\s+-p\s*[^\s$]"
    r"|mysql\b.*\s-p[^\s$]"
    r"|://[^/\s:@]+:[^@\s$][^@\s]*@"
    r"|(authorization|bearer|token)[:= ]+[^\s$'\"]{12,}"
    r"|\w*(key|token|secret|password)\w*=[^\s$]"
    r"|--password[= ][^\s$]"
    r"|AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}",
    re.IGNORECASE,
)

for path in sys.argv[1:]:
    with open(path) as f:
        perms = json.load(f).get("permissions", {})
    for kind in ("allow", "ask", "deny"):
        for rule in perms.get(kind, []):
            if SECRET.search(rule):
                print(f"{path}: {kind}: {rule}")

Save it as audit_claude_rules.py and run it on the live file, then on every old version git still holds:

python3 audit_claude_rules.py .claude/settings.local.json .claude/settings.json
for c in $(git rev-list --all -- .claude/settings.local.json); do
  git show "$c:.claude/settings.local.json" > /tmp/old.json 2>/dev/null &&
    echo "commit $c" && python3 audit_claude_rules.py /tmp/old.json
done

On our test repo it flagged all six fake credentials and left Bash(npm test *), Bash(psql "$DATABASE_URL" ...) and a WebFetch domain rule alone. It is a pattern list, not a guarantee, so read the whole file by eye as well. It is short.

How to clean up: rotate first

Order matters. GitHub's guide to removing sensitive data says the first step for a leaked credential is to revoke or rotate it, and that rotation may be all you need. Rewriting history cannot reach clones and forks other people already have.

  1. Rotate every password, token and key the file ever held, current or historical. Start with anything paired with a public host, such as a database or SSH server, because those work for anyone who finds them.
  2. Untrack the file and make the ignore travel with the repo:
echo ".claude/settings.local.json" >> .gitignore
git rm --cached .claude/settings.local.json
git commit -m "Stop tracking local Claude Code settings"

--cached removes the file from git but leaves your copy on disk, so your approvals keep working. In our test, git log -p --all still found the fake password in three places after this commit, which is why step 1 comes first.

  1. Edit the local file. Delete every rule that contains a secret, even if the file was never committed. It can still end up in an npm package, a Docker image, a zip or a synced folder.
  2. Rewrite history only if you need to, using git-filter-repo as GitHub describes, and coordinate with everyone who has a clone.

How to stop it happening again

  • Keep secrets out of command text. Use psql "$DATABASE_URL" or a script that reads from your secret manager. A saved rule then holds a variable name.
  • Approve patterns, not one off commands. Prefer Bash(npm run lint *) over a full command line. The docs explain where the * goes and why Bash(git *) is broader than it looks.
  • Add the line to every .gitignore template your team or org uses, and treat .claude/, .cursor/ and .gemini/ folders like .env files in commit hooks and CI scanning.
  • Block reads of secret files. A Read deny rule such as Read(./.env) keeps Claude's file tools away from them; the settings reference has a ready example.
  • Run risky sessions in a sandbox with throwaway credentials. Our comparison of E2B vs Daytona vs Modal covers hosted options.

Other agents have their own approval stores. Apiiro says that of 16 coding agents whose documentation it compared, Claude Code is the only one confirmed to save the full approved command in a project file by default. Check how Codex, Cursor and Gemini CLI store yours anyway, because the habit of typing secrets into commands is the real problem.

This is the third Claude Code security story in two weeks, after the tampered Cursor extension and the account email in User Agent headers. If you are new to how agent permission prompts work, our plain English guide to agentic coding explains the modes.

FAQ

Should I commit .claude/settings.local.json?

No. Anthropic's docs describe it as personal settings for one project. Commit .claude/settings.json for shared team rules and keep the local file out of git with a line in the repository's own .gitignore.

Does Claude Code gitignore settings.local.json automatically?

Partly. When Claude Code first writes the file in a git repository, it adds **/.claude/settings.local.json to your global git excludes. That covers only your machine, does nothing for a file you created by hand, and cannot untrack a file that was already committed.

Where are "Don't ask again" approvals stored?

As allow rules in .claude/settings.local.json at the root of the git repository. Bash commands, WebFetch domains and web search approvals are saved there permanently; file edit approvals last only until the session ends. Use /permissions to view and remove them.

Does deleting the file fix a leak?

No. Old versions stay in git history and in any forks or clones. Rotate the exposed credentials first, then untrack the file, and rewrite history only if you still need to.

Will gitleaks or TruffleHog find these secrets?

Some of them. They catch known key formats well but often miss plain passwords typed into commands, such as after PGPASSWORD= or sshpass -p. Add a check for permission rules like the script above.

Does auto mode avoid the problem?

Not fully. Auto mode cuts down on prompts, but when it does ask and you pick a standing approval, the rule is saved the same way. The safe habit is the same in every mode: no secrets in command text.