Claude Code’s “Don’t Ask Again” Secret Leak

If you use Claude Code in a business repository, check whether .claude/settings.local.json is tracked by Git or has appeared in the repository’s history. An approval meant to save you from repeating a prompt can leave a credential inside that local file—and a public repository can then expose it.
This is not Claude Code automatically uploading your passwords. The failure requires the file to reach a public repository or another public artifact. But checking only the current files is not enough: a credential removed from the latest commit may still be present in an earlier one.
What the approval actually saves
Choosing “Yes, and don’t ask again” for a Bash command can save an allow rule in .claude/settings.local.json. If the approved command contains an embedded API key, that key can end up in the rule. The risk comes from persisting a command that should have been treated as sensitive—not from a separate request to publish a secret.
For example, imagine approving a command shaped like this:
curl -H "Authorization: Bearer EXAMPLE_TOKEN" example.invalid
EXAMPLE_TOKEN is a placeholder, not a working credential. The important detail is that the credential appears in the command text. If an approval rule retains that text, the local settings file becomes a place to look for secrets even though its purpose is permissions.
Anthropic’s Claude Code settings documentation distinguishes two files that are easy to confuse:
| File | Intended role | Review before committing? |
|---|---|---|
.claude/settings.local.json |
Developer-local settings, including saved approvals | Yes. Treat it as local and potentially sensitive. |
.claude/settings.json |
Project settings a team may share, including permissions and hooks | Yes. Shared does not mean safe without review. |
According to Anthropic’s documentation, Claude Code adds the local settings file to the developer machine’s global Git excludes when it first writes the file in a repository. That protection has boundaries: a file created by hand must be excluded separately, and an exclude rule does not make a file that Git already tracks disappear from the repository.
The practical rule is to keep credentials out of command text and out of approval rules. Use the credential-handling method appropriate to the tool you are running rather than pasting a token into a command and making that exact command a standing permission. An environment variable may keep the literal token out of the command you approve, but it is not a complete security boundary: the process still receives the credential, and logs or command output may expose it.
How widespread was the exposure?
The reported findings establish that this is worth checking; they do not establish that every detected credential worked or was used by an attacker. The studies also counted different things, so their totals should not be treated as competing estimates of one current inventory.
In its report published on November 9, 2026, VentureBeat described Apiiro’s examination of 104,185 publicly accessible copies of .claude/settings.local.json across 103,617 GitHub repositories. Apiiro reported 1,122 accessible local settings files containing sensitive credentials and classified 1,379 distinct credentials in those files. Its broader count—covering file history and other AI-tool records—was 2,539 across 1,994 public repositories.
Apiiro also reported finding 734 credentials in earlier file versions that no longer appeared in current copies. That is the reason a clean-looking file today cannot close an investigation by itself.
Separately, GitGuardian reported 31,088 distinct secrets in local Claude Code settings files across 23,276 public GitHub repositories during its stated observation period, with 5,343 valid when detected. GitGuardian explains that its monitoring of versions as they were pushed differs from Apiiro’s focus on current copies, conservative filtering, and separate history review.
These figures do not tell you whether your repository is affected. They do tell you what to inspect: the local settings file, commits that previously contained it, and any other artifact to which your development process may have copied it.
Check your repositories without printing secrets
Start by identifying exposure, not by dumping file contents into a terminal, ticket, or chat. Run the checks below from the root of each repository where someone has used Claude Code. Repeat them for relevant public repositories under both company and personal accounts; a developer’s fork can matter even when the main repository is private.
# Is the local settings file tracked in the current checkout?
git ls-files -- .claude/settings.local.json
# Has it appeared in history reachable from local refs?
git log --all --oneline -- .claude/settings.local.json
# Would Git currently ignore this path if it were untracked?
git check-ignore -v --no-index .claude/settings.local.json
Read the results separately:
git ls-filesprints the path: Git currently tracks the file. An ignore rule will not protect that tracked copy.git logshows commits: Review the file’s history through an access-controlled process. The current version may be clean while an earlier version contains a credential.git check-ignoreshows a rule: That tells you about ignore behavior now. It does not prove that the file was never committed, pushed, packaged, or copied elsewhere.
A local checkout may not contain every branch, fork, or artifact that was published. Check the repository and its relevant history on GitHub as well. If your team publishes build artifacts or container images, include any process that copies the working tree into those outputs; the Git checks above address Git, not every route to publication.
Avoid copying suspected values into a shared incident channel. Record the affected repository, path, commit reference, credential owner, and remediation status instead. Give the person authorized to rotate the credential enough information to identify it through the provider’s own controls.
For teams, make this a repeatable repository check rather than an instruction everyone must remember. A simple CI guard can fail when the local settings path is tracked:
if git ls-files -- .claude/settings.local.json |
grep -q .; then
echo "Local Claude Code settings must not be tracked."
exit 1
fi
This guard detects one file path in the current checkout. It will not find a secret in a different file, a prior commit, or a published artifact. Keep your broader secret-scanning and review process.
If you find a credential, rotate it first
Treat a credential found in a public file or public history as exposed. Revoke or rotate it before trying to clean up Git history. That is the order GitHub recommends in its guidance on removing sensitive data: removing a string from a repository does not invalidate a password or token that someone may already have copied.
Work through the response in this order:
- Identify the credential and its owner. Determine which service issued it, what it can access, and who has authority to revoke it. Do not assume a token is harmless because it looks old.
- Revoke or rotate it through the issuing service. Update the legitimate application or workflow that depends on it. If the credential grants access beyond the task that needed it, review that scope as part of replacement.
- Check for use you cannot explain. Use the relevant provider’s available access records and involve the person responsible for that service. A public leak is evidence of exposure, not proof of misuse.
- Remove the file from tracking and correct the workflow. If it is tracked, removing it from the latest commit is necessary but does not erase earlier copies. Add an appropriate repository ignore rule for future local files, and review whether anyone is placing credentials in approved command text.
- Assess history, forks, clones, and other copies. Follow GitHub’s removal guidance if history cleanup is warranted, coordinating before disruptive changes to shared branches.
GitHub explicitly warns that rewriting repository history does not remove sensitive data from other users’ clones or forks. History cleanup is therefore containment and housekeeping, not a substitute for rotation.
If the file was committed but you see no obvious token, do not immediately close the case. Look for service-specific credential formats, connection strings, and commands that may expose credentials indirectly. Have someone who understands the services involved review the findings; a pattern-based scanner cannot decide every case.
Build defenses at each point of failure
No single ignore rule or scanner can guarantee that a secret stays out of a repository. Build controls around the full path: how a command is written, how approval is granted, where settings are stored, what Git tracks, and what gets published.
At command approval: Inspect the command before choosing “don’t ask again.” A one-time task involving a credential is a poor candidate for a durable approval. Narrow permissions to the commands the work actually needs, and revisit saved approvals when the workflow changes.
At repository setup: Keep .claude/settings.local.json local. Anthropic documents automatic global exclusion when Claude Code first writes the file in a repository, but do not rely on that condition if the file was created manually or tracked earlier. Make the intended rule visible in your repository setup and verify the result with Git. Review shared .claude/settings.json separately: teams may commit it, but its permissions and hooks deserve deliberate review.
Before a push: Check the staged files and run secret scanning. Do not limit inspection to files named .env; local tool settings can also contain sensitive command text. GitHub says secret scanning is free for public repositories, making it a sensible layer for public projects.
After a push: Treat scanner alerts as work to investigate, not as a complete inventory. In Apiiro’s test of the 1,122 affected files, neither gitleaks nor TruffleHog flagged 215 of them. That does not make scanning useless; it means a clean scan is not proof that an unusual credential or approval rule is safe.
A practical ownership split for a small team is straightforward. The developer checks commands and staged changes. The repository maintainer enforces tracked-file checks and reviews shared settings. The owner of each external service controls credential scope and rotation. One person may hold all three roles in a small business, but the checks still need to happen.
Decide what needs action today
If your team has never used Claude Code in a repository, this specific local-file check may not apply. The broader lesson still does: inspect what any coding assistant persists when you approve tool access, especially when a command contains a credential.
If your team uses Claude Code but the file has never been tracked, verify the exclusion behavior, inspect saved approvals for sensitive command text, and add a tracked-file guard. Then review any packaging process that might publish files outside Git.
If the file appears in current Git tracking or public history, prioritize the credential response. Do not wait for a scanner alert, and do not start with a history rewrite. Rotate what is exposed, determine its access, and then address copies and the process that allowed the file to be published.
The decision is not whether Claude Code is safe or unsafe as a whole. It is whether your development workflow lets a locally saved approval become a public credential. That is a question you can test against your own repositories.
How BizFlowAI approaches this
For Claude Code and MCP work, the useful security review is concrete: inspect saved permissions and local settings, check what Git tracks, and test whether secret scanning catches realistic mistakes. Scoped access and an auditable settings review reduce avoidable exposure, but neither replaces credential rotation or proves a repository is free of secrets.
BizFlowAI focuses on practical AI automation for small teams. If you are assessing AI development tooling, use the checks above as a starting point for the review—whether you run it internally or get engineering help.
Work with BizFlowAI
If you'd rather have this built for you, that's what we do: production AI automation for solo founders and small teams — agents, integrations, and document pipelines that actually ship.
Request a free discovery call — 30 minutes, we map the highest-ROI automation in your workflow. No pitch deck, just engineering.
More guides like this on the BizFlowAI blog.
Frequently asked questions
Can Claude Code's “don't ask again” option leak an API key?
Yes, if an approved command contains a literal API key, Claude Code may save that command in an allow rule in `.claude/settings.local.json`. The key becomes publicly exposed only if that file or a copy reaches a public repository or artifact. Avoid putting credentials in command text that may be saved as a standing permission.
Should I commit `.claude/settings.local.json` to Git?
No. It holds developer-local settings and may contain saved command approvals with sensitive values. Claude Code normally adds the file to a global Git exclude when it first writes it in a repository, but that does not protect a file Git already tracks. Check tracking explicitly and add a repository ignore rule for future local files.
How do I check whether Claude Code settings were committed without printing secrets?
From the repository root, run `git ls-files -- .claude/settings.local.json` to check whether the file is tracked. Run `git log --all --oneline -- .claude/settings.local.json` to find commits that included it, and `git check-ignore -v --no-index .claude/settings.local.json` to inspect the current ignore rule. These commands identify paths and commits without displaying file contents; also check relevant remote branches, forks, and published artifacts.
Is a leaked key safe if I deleted it from the latest commit?
No. Earlier Git commits may still contain the key, and other people may have copied it from a public repository. Treat a credential found in public history as exposed, even if the current file is clean. Revoke or rotate it before considering history cleanup.
What should I do if I find a credential in Claude Code settings on GitHub?
Identify the credential and its owner, then revoke or rotate it through the issuing service. Check available access records for unexplained use and update any legitimate workflow that depended on the old credential. Remove the local settings file from tracking, prevent future commits, and assess earlier commits, forks, clones, and artifacts. Rewriting Git history can help limit further exposure, but it cannot invalidate a copied credential.