# Claude Code secrets on GitHub: how to check, fix and prevent leaks

> The "don't ask again" prompt can save passwords into a settings file that gets committed. Anthropic says it is looking into it; here is how to check, rotate and stop it.

URL: https://claudegpt.si/news/claude-code-secrets-github-settings-local-json  
Published: 2026-11-09T22:58:30.743Z  
Updated: 2026-11-15T18:58:14.714Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: Claude Code, Anthropic, Security, GitHub  
Publisher: ClaudeGPT Si

## Key takeaways

- Choosing "Yes, and don't ask again" saves the approved command, with any password in it, to .claude/settings.local.json.
- Apiiro counted 1,379 secrets in 1,122 public copies of the file; GitGuardian, counting deleted versions too, found 31,088, with 5,343 valid.
- Anthropic's Boris Cherny said on November 7 that Claude Code has not scrubbed secrets and the team is looking into it.

Claude Code secrets on GitHub are a real problem: the "Yes, and don't ask again" choice on a permission prompt can save a full shell command, password included, into `.claude/settings.local.json`, and that file has been found in thousands of public repositories. The security firm Apiiro published the first count in early November, Ars Technica [reported on November 9](https://arstechnica.com/ai/2026/11/claude-code-settings-files-expose-thousands-of-secrets-on-github/) that Claude Code is exposing secrets this way, and GitGuardian has since published a far larger count. This guide shows how to check your repositories, what to do if you find a key, and how to set Claude Code up so it stops happening.

It is written for anyone who uses Claude Code in a git repository. Allow about 15 minutes for one repository, longer if you rewrite history.

## What happened

Claude Code asks before it runs most shell commands. One choice on the prompt is "Yes, and don't ask again". Anthropic's [settings documentation](https://code.claude.com/docs/en/settings) says Claude Code saves that approval as an `allow` rule in `.claude/settings.local.json`, at the root of the git repository.

The rule can be a pattern, such as `npm test *`, or one exact command. When it is an exact command, anything typed into it is saved in plain text, including database passwords and tokens.

## How many secrets leaked: two counts

Two security firms have counted, and their numbers differ because they measured different things.

**Apiiro**, as summarized by [The Hacker News](https://thehackernews.com/2026/11/claude-codes-dont-ask-again-file.html) (Apiiro's own post returned an access error when we tried to open it):

- 104,185 public copies of the file across 103,617 repositories, of which 1,122 (about 1.1%) held at least one secret, 1,379 distinct secrets in all. Apiiro did not test whether they still worked.
- The largest groups were 379 database passwords, 43 SSH logins, 42 GitHub, GitLab and npm tokens, and 23 AWS keys.
- Counting the shared `.claude/settings.json`, older versions and saved agent chat logs, 2,539 secrets across 1,994 repositories.
- In 539 of 1,105 repositories Apiiro traced, a commit with Claude as co-author had changed the file.

**GitGuardian**, in a [November 9 post](https://blog.gitguardian.com/claude-code-settings-local-json-secrets-docker-hub/) by researcher Guillaume Valadon, counted every version pushed to public GitHub from January 2025 to November 7, 2026, including versions later deleted:

- `.claude/settings.local.json`: 31,088 distinct secrets in 23,276 repositories, 5,343 of them valid when detected.
- `.claude/settings.json`: 8,271 distinct secrets in 6,839 repositories, 1,283 valid.
- Docker Hub: 613 distinct secrets, 99 valid, in 543 image repositories. Docker ignores `.gitignore`, so `COPY . .` can ship the file inside an image.
- Monthly occurrences peaked at 12,535 in April 2026 and fell to 959 in October. GitGuardian says it does not know why.

The gap is mostly method. GitGuardian watches pushes as they happen and keeps what was later deleted. Apiiro looked at files on GitHub now, plus their history, with a stricter filter.

## What Anthropic says

Boris Cherny, who leads Claude Code at Anthropic, [replied on Hacker News](https://news.ycombinator.com/item?id=50408126) on November 7. He wrote that "historically Claude Code has not done secret scrubbing" and that the team is "looking into what we can do to prevent this."

He made three more points. The file is meant to stay local and Claude Code gitignores it when it creates it, so he said these files were created by hand and checked in. He called permission rules outdated and recommended auto mode, which he said is on by default and free on all plans. And he urged everyone to turn on secret scanning on their code host, whatever agent they use.

His first point sits awkwardly with Apiiro's finding that Claude co-authored commits touched the file in 539 repositories. Both can be true: the docs describe a global git exclude on one machine, which does nothing for a teammate's machine or a file already tracked.

## Why the git protection does not always help

The docs say that the first time Claude Code writes the file in a repository that doesn't already ignore it, it adds `**/.claude/settings.local.json` to your global git excludes file. If you create the file by hand, you have to add it to `.gitignore` yourself.

That exclude lives on one machine and does not change the project's `.gitignore`. It also has no effect on a file git already tracks. If the file was committed once, it stays tracked. The docs add that a tracked local file is treated as repository-supplied and its allow rules wait until you trust the folder.

## How to check your repositories for Claude Code secrets on GitHub

1. Search your GitHub organization for `.claude/settings.local.json` and `.claude/settings.json`. The shared file is meant to be committed, but both firms found secrets in it.
2. In each local clone, run `git ls-files .claude`. Anything listed is in the repository.
3. Check history, because deleted files stay there: `git log --all --oneline -- .claude/settings.local.json .claude/settings.json`.
4. Open each file and read the `permissions.allow` list. Look for passwords, tokens, connection strings and `-p` flags inside commands.
5. Check forks and Docker images built from the repository.
6. Turn on GitHub secret scanning. [GitHub's docs](https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning) say it runs automatically for free on public repositories and scans the entire git history on all branches. Private repositories in an organization need GitHub Secret Protection on GitHub Team or Enterprise Cloud.

Do not rely on scanning alone. GitHub lists generic secrets such as connection strings, and AI detection of passwords, as separate features. Apiiro found that Gitleaks and TruffleHog together missed 215 of the 1,122 files, most of them passwords typed inside commands.

These are ordinary git commands. We did not run them against a test repository for this guide.

## How to fix it and rotate the keys

Rotate first, then clean up. [GitHub's guide to removing sensitive data](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository) says the same: once a secret is revoked or rotated it no longer grants access, and rewriting history may then be unnecessary.

1. Rotate every password, token and key the files ever held, including ones only in old commits.
2. Stop tracking the local file: `git rm --cached .claude/settings.local.json`.
3. Add `.claude/settings.local.json` to the repository's `.gitignore`, and `.claude/` to `.dockerignore`.
4. Delete every rule that contains a secret, through the file or `/permissions`.
5. Commit. Old commits still hold the file, which is why step 1 comes first.

To remove the file from history as well, GitHub recommends git-filter-repo 2.47 or later:

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

GitHub warns that the rewrite gives every affected commit a new hash, removes commit signatures, and can be undone by any collaborator who pulls and pushes an old copy. Copies in forks stay reachable, and removing cached views and pull request references takes a request to GitHub Support.

## How to configure permissions so it stops

- **Reference variables, not values.** Run `psql "$DB_URL"`, not a command with the password inline. The saved rule then holds only the variable name.
- **Read the rule before you accept it.** The prompt shows what it will save, such as "Yes, and don't ask again for: npm test *". If it contains a secret, choose plain "Yes".
- **Write standing rules in your user file**, `~/.claude/settings.json`, which is not inside any repository:

```json
{
  "permissions": {
    "allow": [
      "Bash(npm run lint)",
      "Bash(npm run test *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)"
    ]
  }
}
```

- **Block reads of secret files.** The [permissions documentation](https://code.claude.com/docs/en/permissions) says rules are checked in the order deny, ask, allow, and the first match wins, so an allow rule cannot override a deny rule.
- **Review what is saved.** Run `/permissions`. The dialog lists every rule and the file it comes from.
- **Keep your Anthropic key out of files.** The [authentication docs](https://code.claude.com/docs/en/authentication) describe `apiKeyHelper`, a setting that runs your own script to return an API key, for example a short-lived one from a vault.
- **Watch compound commands.** The docs say approving `git status && npm test` saves a separate rule for each part that needs approval, up to five rules.
- **Protect every repository by default.** Add `.claude/settings.local.json` to your organization's `.gitignore` templates and scan `.claude/` the way you scan `.env` files.

## What we don't know yet

Anthropic has said it is looking into the problem but has not said what it will change or when, and we found no change to the documented behavior as of November 15, 2026. GitGuardian's validity checks are a floor, and Apiiro did not test validity at all. Until Claude Code stops saving inline credentials, treat `.claude/` as a folder that can hold secrets. For more on Claude Code settings, see our guide to [checking token usage in Claude Code](https://claudegpt.si/news/check-token-usage-in-claude-code).

Update, November 15: This guide now includes Boris Cherny's November 7 response for Anthropic, GitGuardian's count of 31,088 secrets on GitHub and its Docker Hub findings, and GitHub's steps for secret scanning and removing the file from history. An earlier version said Anthropic had not publicly answered the findings.

## Frequently asked questions

### Is .claude/settings.local.json in .gitignore by default?

Not in the project. Anthropic's docs say Claude Code adds it to your global git excludes the first time it writes the file, which covers only your machine and not files already tracked. If you created the file by hand, add it to .gitignore yourself.

### What did Anthropic say about Claude Code leaking secrets?

Boris Cherny, who leads Claude Code, wrote on Hacker News on November 7 that Claude Code has not historically scrubbed secrets and the team is looking into preventing this. He also recommended auto mode and secret scanning.

### How do I see and remove saved Claude Code permissions?

Run /permissions in Claude Code. The dialog lists every rule and the settings file it comes from, and you can add or remove rules there.

### Do I need to rotate keys if I deleted the file?

Yes. Deleting a file does not remove it from git history, forks or Docker images built earlier. Rotate first, then clean up.

## Sources

- [Boris Cherny's reply on Hacker News](https://news.ycombinator.com/item?id=50408126), Hacker News
- [Claude Code settings.local.json secrets: 17 months of exposure on GitHub and Docker Hub](https://blog.gitguardian.com/claude-code-settings-local-json-secrets-docker-hub/), GitGuardian
- [Settings files and precedence](https://code.claude.com/docs/en/settings), Anthropic
- [Configure permissions](https://code.claude.com/docs/en/permissions), Anthropic
- [Authentication](https://code.claude.com/docs/en/authentication), Anthropic
- [About secret scanning](https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning), GitHub
- [Removing sensitive data from a repository](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository), GitHub
- [Claude Code's "Don't Ask Again" file exposes secrets in public GitHub repos](https://thehackernews.com/2026/11/claude-codes-dont-ask-again-file.html), The Hacker News
- [Claude Code is accidentally exposing secrets all over GitHub](https://arstechnica.com/ai/2026/11/claude-code-settings-files-expose-thousands-of-secrets-on-github/), Ars Technica
