# How to prevent leaks from Claude Code's 'Don't ask again' file

DevFeed: [How to prevent leaks from Claude Code's 'Don't ask again' file](<https://devfeed.tech/articles/how-to-prevent-leaks-from-claude-code-s-don-t-ask-again-file-130216.md>)

Original publisher: [Read original article](<https://about.gitlab.com/blog/prevent-leaks-from-claude-code-dont-ask-again-file/>)

Author: Daniel Abeles

Published: 2026-11-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [GitLab](<https://devfeed.tech/sources/gitlab.md>)

Topics: [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [code security](<https://devfeed.tech/topics/code-security.md>), [Secret Scanning](<https://devfeed.tech/topics/secret-scanning.md>), [AI Chat](<https://devfeed.tech/topics/ai-chat.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>)

Tags: [claude-code](<https://devfeed.tech/tags/claude-code.md>), [gitlab](<https://devfeed.tech/tags/gitlab.md>), [leaks](<https://devfeed.tech/tags/leaks.md>), [prevent](<https://devfeed.tech/tags/prevent.md>), [secret](<https://devfeed.tech/tags/secret.md>), [security](<https://devfeed.tech/tags/security.md>), [security-labs](<https://devfeed.tech/tags/security-labs.md>), [security-research](<https://devfeed.tech/tags/security-research.md>)

## AI overview

Claude Code saves approved "don't ask again" shell commands in `.claude/settings.local.json`; because Git excludes it only through each developer's personal global configuration, the file can be committed with tokens or passwords. The excerpt reports 104,185 public copies identified by Apiiro in early November 2026, 1,122 containing a secret. It recommends preventing new leaks with a repository `.gitignore` entry, group push rules, Secret Push Protection, and scheduled Secret Detection. To assess exposure, current code search can find files on default branches, while the commits API with `all=true` and `follow=false` checks history; deleted files, other branches, and forks require history checks. Rotate every secret first, then remove the file and ignore it. Where secrets were committed, purge old blobs too; forks and shared object pools need special handling, and history rewrites can require rebases and fresh clones. The excerpt notes GitLab Duo can assist with group-wide checks and cleanup merge requests, but group settings must be changed by an owner.

## Source excerpt

This guide details how to find and remove secrets that were inadvertently committed to projects and repositories hosted on GitLab. We've confirmed that GitLab's own infrastructure secrets are protected. In Claude Code, Anthropic's coding agent, a developer can approve a shell command by selecting "Yes, and don't ask again." Claude then saves that exact command to .claude/settings.local.json in the project folder and runs it without asking in the future. If the command contained a password or a token, so does the file: { "permissions": { "allow": [ "Bash(npm test:*)", "Bash(curl --header \"PRIVATE-TOKEN: glpat-EXAMPLEdummyTOKEN1234\" \"https://gitlab.com/api/v4/projects/1234567/issues?state=closed\")", ] } } Claude Code keeps the file out of Git through the developer's personal global excludes, not through the project's .gitignore. That protection lives on one laptop and does not travel with the repository, so the file gets committed and pushed wherever the repository lives. In early November 2026, Apiiro reported that this issue resulted in 104,185 copies of the file to appear in public repositories, 1,122 of them holding at least one secret. Hundreds more secrets were only in history, in files that had since been deleted. If your developers use Claude Code with repositories hosted on GitLab, this guide shows how to prevent this from happening moving forward, assess exposure now or in the past, and clean every affected project up at once. Prevent: Keep the file out of your repo There are a few actions you can perform to ensure a developer cannot commit the file by accident, and that if one slips through, you hear about it. There are four layers you can put in place, each a little more work than the last, and the order below is a reasonable one to follow. All of them are settings a group owner changes once; this is the one part of the process GitLab Duo can walk you through but cannot do for you, since its access to GitLab settings is read-only. Start with .gitignore