Guide from the official docs

Claude Code "Don't ask again" can save your passwords in settings.local.json: where, why, how to fix

Claude Code saves 'Yes, and don't ask again' approvals in .claude/settings.local.json, sometimes with the password you typed. Where it lives, what Apiiro found, how to clean up.

By AideDex desk · published

This guide follows the official docs and announcements, linked inline. AideDex did not test these products and does not score them. How we check facts.

Last checked Nov 8, 2026. Dates below are UTC unless a time zone is named.

When you answer a Claude Code shell prompt with “Yes, and don’t ask again”, the tool saves an allow rule in .claude/settings.local.json at the root of your git repository (Permissions docs). If the prompt offered the exact command rather than a pattern, and that command had a password in it, the password goes into the file as plain text. On Nov 5 the security firm Apiiro reported that 1,122 of the 104,185 public copies of that file it found on GitHub held a real secret (Apiiro, The Hacker News). Below: which file gets written and why, what Apiiro counted and what it did not, whether Anthropic has changed anything, and the steps for checking and fixing your own repositories. Everything here is read from the sources named. Where we ran something ourselves, the text says so.

Which file Claude Code writes

Anthropic’s settings page lists four places Claude Code reads settings from. Three of them matter here (Settings docs):

FileWho it affectsCommitted to git?
~/.claude/settings.jsonYou, in every project on the machineNot in a repository
.claude/settings.jsonEveryone who works in the projectYes, the docs say to commit it
.claude/settings.local.jsonYou, in this one projectNo: “Claude Code keeps it out of git when it creates the file; if you create it by hand, add it to .gitignore yourself”

The permission prompt is what writes the third one. The settings docs say Claude Code creates .claude/settings.local.json “the first time you give a standing approval on a permission prompt, such as ‘Yes, and don’t ask again’ for a Bash command” (Settings docs). The permissions docs say the same from the other side: a permanent approval of a Bash command or a WebFetch domain is saved to that file “at the root of the git repository”, and it then applies to future sessions anywhere in the repository, including subdirectories and worktrees (Permissions docs). A file edit you approve is not saved; it lasts until the session ends.

A few details from the docs that decide where you will find the file:

  • Repository root, not the folder you started in. Release 2.1.211 of Jul 15, 2026 changed “always allow” rules to save at the repository root (Changelog). Before that, the file sat in the starting directory, and Claude Code still reads an old one there (Settings docs). A repository you used with an older version can therefore have two copies.
  • Worktrees use the file at the main checkout’s root.
  • Exceptions. Outside a git repository or on Windows, among other cases, Claude Code does not use the repository root (Permissions docs).
  • A compound command saves one rule per subcommand. Approving git status && npm test saves a rule for npm test, and up to 5 rules can come from one command (Permissions docs).

On settings.json versus settings.local.json: the first is for rules the team shares, the second for yours. Claude Code treats them differently when it comes to trust. It applies the local file’s allow rules without the workspace trust step, but only while the file stays untracked. If the file is tracked in git, the docs say it is treated “as repository-supplied instead” and its rules wait until you trust the folder (Permissions docs, Settings docs).

Why the file can hold a password

A Bash allow rule is a string match. The permissions docs say “a rule with no * matches one exact command”, and that Bash(npm run build) matches exactly npm run build (Permissions docs). The prompt can offer a pattern. The docs’ example shows “Yes, and don’t ask again for: npm test *”. They also say a saved rule “covers only what its option named” (Permissions docs). When the option names the whole command, everything typed into the command is part of the rule.

Apiiro describes what that looks like in practice. Ask Claude Code to check a database or call an API, and the command it proposes carries the secret from your config file, because the command cannot work without it. Pick “Yes, and don’t ask again” and the exact command, secret included, goes into the file (Apiiro). Its examples of what survives scanners are PGPASSWORD=, sshpass -p, mysql -p and bearer headers in curl. The Hacker News summarises the same mechanism (The Hacker News).

This was reported earlier. Issue #5544, filed Aug 11, 2025, says approved commands “including API keys, secret tokens, authorization headers” are stored “verbatim” in the file, in permissions.allow (GitHub). Apiiro says Anthropic never answered the issues on this, which include that one (Apiiro).

The git protection, and where it stops

The settings docs say Claude Code adds **/.claude/settings.local.json to your global git excludes file the first time it writes the local file in a repository that does not already ignore it. That file is core.excludesFile if your global git config sets it, otherwise ~/.config/git/ignore (Settings docs). The Hacker News repeats this from the docs (The Hacker News).

On the machine where we checked, which has Claude Code 2.1.319 installed, ~/.config/git/ignore contains that exact line. We read the file; we did not trigger a new prompt to watch Claude Code write it. In a scratch repository with that global ignore in place, git add -A skipped the file and git check-ignore -v named the global file as the reason (git 2.43.0).

Apiiro points out why it still leaks. The exclude lives in one user’s git settings on one computer. It does not cover “a folder that becomes a repo later, a clone on another machine, or a file someone already committed”, and Claude Code never writes the rule to the repository’s own .gitignore, so nothing in the project protects it (Apiiro, The Hacker News). In 539 of the 1,105 repositories Apiiro traced, a commit co-authored by Claude changed the file, which it reads as Claude often committing the file itself. A user on issue #11982 reported the same gap in November 2025: the file was not added to the project’s .gitignore (GitHub).

What Apiiro found

Apiiro’s post is dated Nov 5, 2026, and The Hacker News covered it on Nov 7. The numbers match between the two (Apiiro, The Hacker News):

WhatCount
Public copies of .claude/settings.local.json on GitHub104,185, in 103,617 repositories
Copies holding at least one real secret1,122 (1.1%)
Distinct secrets in those copies1,379: 636 provider keys, 743 passwords or tokens for public hosts
Including history, shared settings.json and saved agent chat logs2,539 secrets in 1,994 repositories
Secrets only in older versions of the file734, in 509 repositories
Forks carrying the same secrets211 forks of 74 repositories
Shared .claude/settings.json copies with a secret298 of 76,011
Organizations affected63

Inside the 1,379: 379 database passwords, 43 SSH logins, 42 GitHub, GitLab or npm tokens, 23 AWS keys. Every file with a secret was still on its repository’s default branch on Nov 2, and in the median repository it had been there 217 days.

Three limits from Apiiro’s own method section matter for how you read this. First, “real secret” means a value in a known provider format, or a password or token on the same line as a public host, after an independent AI reviewer agreed. It does not mean a credential known to work, and Apiiro says it used or tested none of them. Second, the data was collected Nov 1 to 3 through GitHub code and commit search, so it is a snapshot. Third, the history count is “a floor”. One of the organizations Apiiro notified confirmed its key had been live (Apiiro).

Scanners did not catch all of it. Of the 1,122 files, gitleaks flagged 564 and TruffleHog 643 without their verification step, and 215 were flagged by neither, mostly passwords typed inside a command (Apiiro, The Hacker News).

Has Anthropic changed it?

We found no change. Release 2.1.319 of Nov 6 is the newest entry in the docs changelog, and the GitHub releases page and API listed it as the newest release when we checked on Nov 8 (Changelog, GitHub releases). Neither it nor any earlier entry we searched for “secret” and “settings.local” mentions redacting or refusing to save a secret in an allow rule. The permissions and settings pages we read on Nov 8 describe the behaviour above without a warning about secrets.

The bug reports are closed without a fix. GitHub shows #5544 closed as not planned on Jan 3, 2026, and #11982 closed as not planned on Mar 5, 2026 (GitHub, GitHub). The Hacker News says the same bot closed all four related reports it cites, and Apiiro says three were closed automatically as inactive or duplicate. GitHub’s event log shows github-actions[bot] closing both #5544 and #11982 (The Hacker News, Apiiro, GitHub). We found no public statement from Anthropic about Apiiro’s report as of Nov 8. If one appears or a release changes the behaviour, this page needs updating.

How to check and fix your repositories

The order matters. Apiiro says “rotate first, clean up second”, and GitHub’s own docs give the same priority.

  1. Find the files. On your machine, look for .claude/settings.local.json in every project, and for old copies in a starting subdirectory. Open each one and read the allow list. Look for passwords, tokens, keys and connection strings (Apiiro). For each repository you push to GitHub, search your organization for .claude/settings.local.json and .claude/settings.json; each hit in a public repository is readable by anyone.

  2. Check whether git ever saw the file. These four commands answer it. The first shows what is tracked now. The second lists every version of the file stored anywhere in history, deleted or not. The third lists commits where a given string was added or removed, and the fourth lists the revisions that contain it:

    git ls-files .claude
    git rev-list --all --objects | grep settings.local.json
    git log --all --oneline -S'PGPASSWORD'
    git grep -l 'PGPASSWORD' $(git rev-list --all)
    

    We ran all four in a scratch repository (git 2.43.0). After untracking the file, git ls-files no longer listed it, but the object listing, the pickaxe search and the revision search still found it in history, and the old revision still held the planted test password.

  3. Rotate every credential the file ever held. GitHub’s remediation guide says “it is not sufficient to simply remove the secret from your codebase” and “the most important remediation step is revoking the secret with the secret’s provider” (GitHub Docs). GitHub’s secret scanning page says that once a credential is revoked, scrubbing git history “is time-intensive and often unnecessary” (GitHub Docs). GitHub’s remediation guide also asks you to review the secret provider’s audit logs for use of the exposed credential (GitHub Docs). Apiiro says to start with credentials paired with a public server, since those give direct access (Apiiro).

  4. Stop git tracking the file and ignore it in the repository. GitHub’s docs: to ignore a file that is already checked in, untrack it first with git rm --cached FILENAME, then add the rule to .gitignore and commit that file (GitHub Docs). Apiiro gives the exact command for this file: git rm --cached .claude/settings.local.json, plus a line in the repository’s own .gitignore (Apiiro). In our scratch repository the file stayed on disk after git rm --cached, and git check-ignore -v then named .gitignore as the rule. If you do not want a shared .gitignore line, GitHub also documents .git/info/exclude for rules that stay in your local clone.

  5. Remove it from history if you have to. GitHub’s guide uses git-filter-repo, version 2.47 or later for its sensitive-data flag. It removes the file from every branch and tag, then force-pushes all refs:

    git-filter-repo --sensitive-data-removal --invert-paths --path .claude/settings.local.json
    git push --force --mirror origin
    

    Plan for what that does not reach: clones and forks, cached views by commit hash on GitHub, and pull requests that reference the old commits. GitHub Support can remove cached views and pull request references, but it says it only helps when rotating the credential cannot mitigate the risk (GitHub Docs, git-filter-repo README). We did not run this step: git-filter-repo is not installed on our machine.

  6. Clean the file on your own computer. Even if it never reached GitHub, delete each rule that contains a secret (Apiiro). The permissions docs say you can manage rules with /permissions inside a session (Permissions docs).

  7. Keep secrets out of the command line. Apiiro’s advice is to reference a secret as a variable such as $DB_URL, so the saved rule holds the name and not the value, and to approve patterns like Bash(npm run:*) instead of single literal commands (Apiiro, The Hacker News). The Twelve-Factor App makes the same case for config in environment variables, noting they are unlikely to be checked into a repository by accident (12factor.net), and GitHub’s guide lists environment variables and a secrets manager as the way to avoid hardcoding (GitHub Docs). We have not tested what rule Claude Code saves when a command uses a variable, so check the file after your next approval. The permissions docs also show how to stop Claude’s file tools from reading a secrets file, with a rule such as Read(./.env) under deny.

  8. Turn on scanning that sees passwords as well as key formats. GitHub secret scanning runs on public repositories for free, scans the full history on all branches, and on organization-owned private repositories needs GitHub Secret Protection (GitHub Docs). Push protection for users is on by default on GitHub.com and stops you pushing supported secrets to public repositories; blocking unstructured secrets such as passwords found by AI is in public preview (GitHub Docs). Given the 215 files that gitleaks and TruffleHog both missed, Apiiro tells security teams to make sure the scanner catches PGPASSWORD=, sshpass -p, mysql -p and bearer headers, and to add the agent folders to pre-commit and CI scans (Apiiro). GitHub says you can add custom patterns, which are regular expressions you write yourself.

Apiiro also says .claude/, .cursor/, .gemini/ and .specstory/ folders, plus agent memory files, should be treated like .env files (Apiiro). In its sample, 120 saved agent chat transcript files in 87 repositories held a real secret.

For other things Claude Code does with your account details, see Claude Code sent users’ email addresses to websites. How agents handle credentials in general is in How AI agents handle your passwords and payments, and the risks of linking mail are in Is it safe to connect Gmail to an AI agent?. Agents that run commands on your behalf can also be steered by hostile text, which AI agents and prompt injection covers. AI agent memory explains what else agents keep between sessions, Can an AI agent log into your bank? covers accounts with a second factor, and Anthropic’s other agent has its own page: Claude Cowork safety.

Administrators can stop the saving at the source: with allowManagedPermissionRulesOnly in managed settings, Claude Code hides the always-allow choices and stops saving new rules. Which keys do that, and where the file goes, is in Claude Code managed settings.

FAQ

Is there a settings.local.json in my home folder too?

There can be one at ~/.claude/settings.local.json, but the docs say Claude Code reads it only in sessions you start in your home directory itself. To apply permission rules in every project, they point you to ~/.claude/settings.json (Permissions docs). A project approval is saved in that project’s own file, not in the home one.

Does starting Claude Code in a subfolder, or using /cd, change which file gets written?

Starting in a subdirectory of a git repository still reads and writes the file at the repository root. After you move a session with /cd, Claude Code reads both project files from the new directory and places the local file by the same rules, and the docs say that needs v2.1.246 or later (Settings docs). If you move between folders a lot, check each project for its own copy.

My repository is private. Do I still need to rotate?

GitHub says to rotate a credential immediately when an alert fires, and Apiiro lists ways the file leaves a private repository: an npm package, a Docker image built with a copy command, a zip archive or a synced folder (GitHub Docs, Apiiro). Apiiro’s counts cover public GitHub only. If a password was ever typed into an approved command, rotating costs less than finding out later.

Sources

15 pages
  1. Apiiro: Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub (Nov 5, 2026) apiiro.com
  2. The Hacker News: Claude Code's Don't Ask Again File Exposes Passwords and Keys in 1,122 Public Copies on GitHub (Nov 7, 2026) thehackernews.com
  3. Claude Code Docs: Settings files and precedence code.claude.com
  4. Claude Code Docs: Configure permissions code.claude.com
  5. Claude Code Docs: Changelog code.claude.com
  6. GitHub: Claude Code releases github.com
  7. GitHub: anthropics/claude-code issue #5544, approved commands with credentials stored in settings.local.json (Aug 11, 2025) github.com
  8. GitHub: anthropics/claude-code issue #11982, local settings file not added to .gitignore (Nov 19, 2025) github.com
  9. GitHub Docs: Ignoring files docs.github.com
  10. GitHub Docs: Removing sensitive data from a repository docs.github.com
  11. GitHub Docs: Remediating a leaked secret in your repository docs.github.com
  12. GitHub Docs: Secret scanning docs.github.com
  13. GitHub Docs: Push protection docs.github.com
  14. GitHub: newren/git-filter-repo README github.com
  15. The Twelve-Factor App: III. Config 12factor.net

Spotted something wrong or out of date? Report an error · Corrections log