Claude Code's 'Don't ask again' file is leaking secrets
GitLab published a cleanup guide after Apiiro reported 104,185 copies of .claude/settings.local.json in public repositories, 1,122 of them holding at least one secret.
GitLab's Security Labs published guidance on November 11, 2026 on the Claude Code settings.local.json leak, explaining how a saved command approval can carry a token or a password into a repository and what a group owner can do about it. In Claude Code, Anthropic's coding agent, a developer who approves a shell command with "Yes, and don't ask again" hands that exact command to .claude/settings.local.json in the project folder, which then runs without asking. If the command held a credential, the file holds it too. The GitLab write-up covers projects and repositories hosted on GitLab.
Why the exclusion does not travel
Claude Code keeps the file out of Git through the developer's personal global excludes rather than the project's .gitignore. That protection lives on one laptop and does not move with the repository, so the file can be committed and pushed wherever the repository is hosted. GitLab's example stores a curl command whose header carries a PRIVATE-TOKEN value, token included.
What Apiiro counted
In early November 2026, Apiiro reported 104,185 copies of the file in public repositories, 1,122 of them holding at least one secret. Hundreds more secrets sat only in history, in files that had since been deleted. GitLab says it has confirmed that its own infrastructure secrets are protected.
Four layers, each one more work
GitLab lays out four settings a group owner applies once, in rising order of effort. GitLab Duo can walk someone through them but cannot apply them, because its access to GitLab settings is read-only.
- .gitignore. Add .claude/settings.local.json to each repository. On Premium or Ultimate, put the same line in the group's file templates project under Settings > General > Templates so new projects inherit it.
- Push rule (Premium and Ultimate). Under Settings > Repository > Pre-defined push rules, add the prohibited filename pattern (^|/).claude/settings.local.json$, which rejects any push adding the file at the root or in a subdirectory, on any branch. It checks files being added, not edits to a tracked file, and a group rule reaches only projects created later; existing projects need it set individually or through an API loop, using PUT where rules already exist.
- Secret Push Protection (Ultimate). It inspects the content of each push rather than the file name and rejects known token formats. Self-Managed and Dedicated instances must allow it under Admin > Settings > Security and compliance first; on GitLab.com that step is already done. It is then enabled per project, or for a group through the group security settings API.
- Scan execution policy (Ultimate). A policy on the top-level group runs Secret Detection in every project, including ones with no .gitlab-ci.yml, and projects cannot switch it off. GitLab recommends one rule on every pipeline plus a weekly scheduled rule, adding SECRET_DETECTION_HISTORIC_SCAN: 'true' when a weekly run should cover full history.
Finding copies that are already committed
GitLab offers two routes for assessment. GitLab Duo Agentic Chat, with Duo Core on Premium and Ultimate or GitLab Credits on a Free group on GitLab.com, answers a prompt asking whether any project in the group ever held the file, including deleted copies and copies on other branches. It returns one table of projects, current status and the commits that added and removed the file, covers forks, and states what it did not check; a group of about a hundred projects takes several minutes. Code search, on Premium and Ultimate, finds current copies only, with a different query depending on whether the group runs exact or advanced search, and shows the default branch as it stands today. The history check the guide lists for all tiers is where the available text ends.
Limits and open questions
Three limits are stated. The push rule, Secret Push Protection and scan execution policy all sit on paid tiers. A group push rule does not reach projects that already exist. And push rules ignore changes to an already tracked file, so cleanup has to come before enforcement. That likely makes the order of work matter more than the choice of layer. Whether Anthropic plans to change how Claude Code excludes the file is not addressed in the text that is available.
What this means for apps built with AI
Files an agent writes into a project folder are part of the code you review, because anything in that folder can be committed. Where a builder pushes source to a repository, Draftship's paid plans include source code access and GitHub push, described on the GitHub and Vercel page, so it helps to know which files your tooling generates before the first push.
Primary sources
- How to prevent leaks from Claude Code's 'Don't ask again' file · GitLab Blog, Nov 11, 2026
This article was drafted with AI assistance from the primary sources listed below, then reviewed and approved by a Draftship editor.