9io.ai / Blog

Secrets in Claude Code’s settings.local.json: check and clean up

Claude Code’s ‘don’t ask again’ saved approved commands, passwords included, in a file that got committed. What changed on 12 November and how to clean up.

Key takeaways

  • “Yes, and don’t ask again” saves the approved command, secret included, in .claude/settings.local.json.
  • Apiiro reports 1,122 public copies of that file holding a real secret, out of 104,185.
  • Claude Code 2.1.323 stops saving rules that look like secrets or would land in a tracked file.
  • The update doesn’t clean rules already saved, git history, forks or other agent files.
  • Rotate first, untrack second, and reference secrets as environment variables so approvals never record them.

Claude Code’s “Yes, and don’t ask again” button saves the approved shell command as an allow rule in .claude/settings.local.json. When that command carried a database password or an API token, the secret now sits in a JSON file inside your project. If the file gets committed, the secret is public. On 5 November 2026 the security firm Apiiro reported 1,122 public copies of the file on GitHub holding a real secret, out of 104,185 it found.1

Anthropic shipped a change a week later. From Claude Code 2.1.323 (12 November 2026), an approval that looks like it holds a secret, or that would be saved to a tracked settings.local.json, lasts for the session only.2 That stops new leaks of the obvious kind. It doesn’t touch rules you saved before updating, files already in git history or forks, or the other agent files Apiiro found secrets in.

This post covers how the leak happens, what Apiiro counted and how, what the update changes, how three other coding agents store their “always allow” choices, and the commands and CI check we’d run on any repository a coding agent has worked in. Facts are as of 17 November 2026.

How an approval turns into a stored password

Coding agents ask before they run shell commands. Claude Code’s prompt includes “Yes, and don’t ask again”, and its documentation says that option saves an allow rule in .claude/settings.local.json at the repository root.3 The rule is the command text, or a prefix of it ending in *.

The trouble starts when the command needs a credential to work. Ask the agent why a staging login fails and it may read a connection string from a config file and propose something like this:

PGPASSWORD=correct-horse psql -h db.staging.example.com -U app -c "select 1"

Approve it permanently and the password becomes part of the saved rule. Claude Code’s permission docs add a detail that makes this more likely: an allow rule won’t match past a leading assignment of an environment variable outside a short known-safe list.4 A prefix rule like Bash(psql *) can’t cover a command that starts with PGPASSWORD=..., so the rule that covers it is the literal line. That is our reading of the docs; Anthropic hasn’t described it that way.

The file is meant to stay on your machine. The first time Claude Code writes it inside a git repository, it adds **/.claude/settings.local.json to your global git excludes file.3 That protection belongs to one laptop. It doesn’t reach a teammate’s clone or a CI runner, and git ignore rules have no effect on a file that is already tracked.5 Before 2.1.323 it also missed folders that became repositories after the file was written.2

What Apiiro counted, and how

Apiiro sells application security products, and these numbers are its own. Nobody has published an independent recount. The researchers used GitHub code search on default branches between 1 and 3 November 2026, downloaded every match and classified each value. A value counted as a real secret when it matched a known provider key format, or when it was a password or token on the same line as a public host. They removed placeholders, default passwords, local hosts and keys that are public by design, and an LLM reviewer checked each remaining value against a written rubric. No credential was tried, so none of these is proven to work.1

Where Apiiro looked Copies checked Holding a real secret
.claude/settings.local.json (current) 104,185 1,122 files, 1,379 distinct secrets
Earlier versions of that file in git history 43,120 repos’ history 734 secrets in 509 repos, absent from current copies
Shared .claude/settings.json 76,011 298 files
Agent chat transcripts (SpecStory, aider, Cursor exports) 2,523 120 files in 87 repos
Agent memory files such as MEMORY.md 1,200 9 repos
Handoff and deploy notes 2,095 33 files
VS Code Copilot auto-approve settings 173 9 repos

Across all sources the total was 2,539 distinct secrets in 1,994 repositories. More than a third of the secrets in the main file open a database directly: 379 database passwords and 122 Supabase service-role keys. There were also 43 SSH logins, some of them root passwords passed to sshpass, and 23 AWS keys.1

Three findings matter more than the totals. The rate climbs with file size: one in ten files over 8 KB held a secret, against fewer than one in 500 under 500 bytes, so long-running projects with years of approvals are the risk. The files had sat there a long time, with the median affected file first committed 217 days before the scan. And in 539 of the 1,105 affected repositories Apiiro traced, a commit co-authored by Claude had changed the file, which means the agent often committed its own settings along with the code.1

None of this is new as a bug report. A GitHub issue from August 2025 described approved commands with credentials being stored verbatim in the permissions list.6

Why secret scanners missed a fifth of them

Apiiro ran gitleaks and TruffleHog over all 104,185 files. Of the 1,122 files with a real secret, gitleaks flagged 564 and TruffleHog 643, and 215 were flagged by neither tool.1

The gap is in what scanners look for. They are tuned to key formats: a provider prefix followed by a long random string. A password after PGPASSWORD= or sshpass -p, or inside a user:password@host connection string, is an ordinary word in an ordinary command line. GitHub’s push protection has the same split. It blocks known provider credentials wherever push protection is on, while generic patterns such as database connection strings also have to be enabled in the repository’s or organisation’s security settings.7

So a team that relies on default secret scanning will catch the AWS key in an allow rule and may miss the Postgres password next to it. The CI check later in this post looks for the command-line shapes directly.

What Claude Code 2.1.323 changed

Apiiro shared the research with Anthropic before publishing. According to Apiiro, Boris Cherny, who leads Claude Code, replied on Hacker News on 7 November that the team was “looking into what we can do to prevent this”.1 Releases 2.1.323 and 2.1.325 followed on 12 and 13 November. The relevant changelog entries:2

Version and date Change
2.1.323, 12 November “Don’t ask again” keeps a rule for the session only, without saving it, when the rule looks like it holds a secret or would be saved to a tracked settings.local.json
2.1.323, 12 November Fixed the file not being ignored globally when the folder became a git repository later, or on a new machine
2.1.323, 12 November Fixed prompts offering “don’t ask again” for commands that write to .git or .claude
2.1.323, 12 November Claude Code’s own ripgrep and most internal git commands run without most of its sign-in tokens and API keys
2.1.325, 13 November Fixed a committed settings.local.json being treated as the user’s own when Claude Code started in certain subfolders

Claude Code already treated a tracked settings.local.json as repository-supplied and held its rules until you trusted the folder.4 The new behaviour also stops it adding approvals to such a file.

The release notes leave questions open. They don’t say how Claude Code decides a rule “looks like” a secret, and Apiiro’s scanner results show how hard that is for passwords inside commands. They don’t mention removing rules saved before the update. Nothing in a client update can reach git history, forks, Hugging Face Spaces or the shared settings.json your team commits on purpose. Run claude --version, update if you’re below 2.1.323, and then do the clean-up below anyway.

How other coding agents store “always allow”

Apiiro compared 16 coding agents from their documentation and found Claude Code to be the only one confirmed to write the full approved command to a project file by default.1 We checked the docs for three that teams often run alongside it.

Agent Where a persistent approval goes What it records
Claude Code .claude/settings.local.json at the repository root An allow rule: the command, or a prefix ending in *3
OpenAI Codex User layer, ~/.codex/rules/default.rules; repository rules load only when the project’s .codex/ is trusted A prefix_rule over the command’s arguments8
Gemini CLI “Allow for all future sessions” is off by default; workspace policy files are disabled for now, so policies live in ~/.gemini/policies/ A policy rule in TOML910
VS Code Copilot “Always Allow” updates chat.tools.terminal.autoApprove, a user setting in Copilot sessions A command, or a regex between slashes11

A user-level file is harder to commit by accident, but it is still plain text on the laptop. Apiiro points out that malware already sweeps developer machines for credentials, and the 2025 Shai-Hulud npm worm ran TruffleHog over its victims’ files.1

Check a repository in five minutes

Run these from the root of each repository a coding agent has worked in. The first lists tracked copies of the local file, the second finds any commit that ever touched one, and the third shows whether your machine’s excludes cover it:

git ls-files | grep -E '(^|/)\.claude/settings\.local\.json$'
git log --all --oneline -- '*settings.local.json'
git check-ignore -v .claude/settings.local.json

Then read the files on your own machine, including in projects that were never pushed. Apiiro found most of the secrets in large, old allow lists, and a rule stays until someone deletes it:

find ~ -path '*/.claude/settings.local.json' -not -path '*/node_modules/*' 2>/dev/null

Open each one and read the allow list. Look for anything after PGPASSWORD=, MYSQL_PWD= or sshpass -p, Authorization: Bearer headers, -p flags on database clients, and URLs of the form scheme://user:password@host. Do the same for the shared .claude/settings.json, .vscode/settings.json, saved agent transcripts and any memory or handoff notes the agent writes.

Rotate first, then clean history

GitHub’s guidance on removing sensitive data starts with the step people skip: revoke or rotate the secret first. Once it no longer works, rewriting history may not be worth the side effects.12 GitHub lists the side effects. Every collaborator has to re-clone or clean their copy, a stale clone pushed back restores the secret, commit signatures are lost, and forks keep the old commits unless their owners act.

In practice, for each secret you find:

  1. Rotate or revoke it at the provider, and check the provider’s access logs for use since the file was first committed.
  2. Delete the rule from your local file.
  3. Untrack the file with git rm --cached .claude/settings.local.json, add **/.claude/settings.local.json to the repository’s own .gitignore, and commit both.
  4. Rewrite history with git-filter-repo only if the repository needs a clean history for other reasons, and follow GitHub’s steps for clones and forks.

Keep secrets out of the commands an agent runs

The lasting fix is upstream of any settings file. If the secret never appears in the command, no approval can record it.

Put credentials where the tool already knows to look, such as ~/.pgpass for Postgres, an SSH key loaded in ssh-agent, or an environment variable set by your secrets manager before the session starts. Then the command reads psql "$DATABASE_URL" and the saved rule records the variable name. Prefer prefix rules you write yourself, such as Bash(npm run *), over literal commands approved from a prompt.4 Add Read deny rules for .env and secrets folders so the agent’s file tools can’t open them in the first place; Claude Code’s docs give a paste-ready example.4

Where you have a choice, keep approvals short-lived. VS Code’s security guidance recommends granting tool and terminal permissions per session.13 In Claude Code’s auto mode a classifier reviews actions instead of prompting you; Cherny recommended it over permission rules, though Apiiro reports he agreed that auto mode can surface the same problem when it asks about a sensitive command.1

If you run agents in CI, the same thinking applies to the pipeline’s own secrets. Our post on coding agents and pull requests from forks covers which tokens a workflow should never hand to an agent.

A CI check for passwords inside commands

Default scanners look for key formats, so add a check for the command-line shapes. This script fails the build when a settings.local.json is tracked, or when an agent file holds a credential typed into a command. We wrote it for this post and tested it on a throwaway repository; tune the paths and patterns to your own tools.

#!/usr/bin/env bash
# Fail the build if agent files are tracked that shouldn't be,
# or if any agent file holds a credential typed into a command.
set -uo pipefail

if git ls-files | grep -E '(^|/)\.claude/settings\.local\.json$'; then
  echo "settings.local.json is tracked: untrack it and rotate what it held" >&2
  exit 1
fi

pattern='PGPASSWORD=[^$ ]|MYSQL_PWD=[^$ ]|sshpass -p *[^$ -]|[Bb]earer [A-Za-z0-9._-]{8,}|://[^:/ ]+:[^@$ /]+@'
if git grep -nIE "$pattern" -- '*.claude/*' '*.specstory/*' '*.vscode/settings.json' '*MEMORY.md'; then
  echo "an agent file holds a literal credential: use env vars, then rotate it" >&2
  exit 1
fi

The [^$ ] after the variable prefixes lets PGPASSWORD=$PGPASS through and stops a literal value. Run it as a pre-commit hook too, so the secret never reaches the remote. Our earlier post on agent config files that run code has a fuller CI sketch for hooks and MCP entries, and the two checks sit well in the same job.

Checklist for teams using coding agents

  • Update Claude Code to 2.1.323 or later on every machine, including CI images.
  • Add **/.claude/settings.local.json to every repository’s .gitignore and to your project templates.
  • Search each organisation’s repositories, and their history, for settings.local.json; rotate everything you find before cleaning up.
  • Read the allow lists on developer laptops and delete rules that contain secrets, even in projects that were never pushed.
  • Treat .claude/, .cursor/, .gemini/, .vscode/settings.json, transcripts and agent memory files as places secrets can land, and scan them for passwords inside commands.
  • Set credentials as environment variables or tool config before the session, so commands carry variable names and approvals stay safe to store.
  • Prefer session-scoped approvals and rules you write by hand over permanent approvals clicked from a prompt.

  1. Apiiro, “Coding Agents Are Leaking Your Secrets to GitHub” (5 November 2026, updated 8 November), https://apiiro.com/blog/coding-agents-leaking-secrets-github-dont-ask-again ↩↩↩↩↩↩↩↩↩

  2. Claude Code changelog, versions 2.1.323 (12 November 2026) and 2.1.325 (13 November 2026), https://code.claude.com/docs/en/changelog ↩↩↩

  3. Claude Code docs, “Settings”: project local settings and where Claude Code keeps the local file, https://code.claude.com/docs/en/settings ↩↩↩

  4. Claude Code docs, “Permissions”: wildcard patterns, environment variable assignments, Read deny rules and “When your local settings file needs trust”, https://code.claude.com/docs/en/permissions ↩↩↩↩

  5. Git documentation, “gitignore”: files already tracked by Git are not affected, https://git-scm.com/docs/gitignore ↩

  6. GitHub issue anthropics/claude-code #5544 (August 2025), https://github.com/anthropics/claude-code/issues/5544 ↩

  7. GitHub Docs, “Push protection”, https://docs.github.com/en/code-security/secret-scanning/introduction/about-push-protection ↩

  8. OpenAI Codex docs, “Rules”, https://developers.openai.com/codex/rules ↩

  9. Gemini CLI docs, “Settings”: security.enablePermanentToolApproval defaults to false, https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/settings.md ↩

  10. Gemini CLI docs, “Policy engine”: the Workspace tier is currently non-functional, https://geminicli.com/docs/reference/policy-engine ↩

  11. VS Code docs, “Manage approvals and permissions”, https://code.visualstudio.com/docs/agents/run/approvals ↩

  12. GitHub Docs, “Removing sensitive data from a repository”, https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository ↩

  13. VS Code docs, “Security” for agents, https://code.visualstudio.com/docs/agents/run/security ↩

Frequently asked questions

Is .claude/settings.local.json safe to commit?

No. It holds your personal allow rules, and a rule saved from “Yes, and don’t ask again” is often the full command, including any password or token typed into it. Add **/.claude/settings.local.json to the repository’s own .gitignore.

Does Claude Code gitignore settings.local.json automatically?

When Claude Code first writes the file in a git repository, it adds it to your global git excludes file on that machine. That doesn’t travel with the repository, doesn’t help a file someone created by hand, and does nothing for a copy that is already tracked.

Did Anthropic fix the ‘don’t ask again’ secret leak?

Partly. Claude Code 2.1.323, released on 12 November 2026, keeps an approval for the session only when the rule looks like it holds a secret or would be saved to a tracked file. Rules saved before the update, git history and forks still need cleaning by hand.

How do I check if my Claude Code settings leaked a secret?

Run git ls-files and git log --all for settings.local.json in each repository, then read every allow rule in every copy on your machine. Look for passwords after PGPASSWORD= or sshpass -p, bearer tokens and connection strings with a password in them.

Do gitleaks or TruffleHog catch these secrets?

Not all of them. In Apiiro’s run, gitleaks flagged 564 and TruffleHog 643 of 1,122 files with a real secret, and 215 files were flagged by neither. Passwords typed inside commands have no provider format for a scanner to match.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO. We work by the hour, and plans start at $5,000. Send us a note about your product. The reply comes from the person who'd do the work.