How Claude Code's 'Don't Ask Again' Leaks Secrets
A convenience setting can write secrets to a local file, and that file can end up in git.
Reviewed by Abhijith N M · 24 October 2026 · Editorial standards
You run a shell command in Claude Code. It asks for approval. You pick "Yes, and don't ask again." According to Apiiro, Claude Code then saves that approval as a permanent permission rule. The rule goes in a local file called `.claude/settings.local.json`, inside your project folder. The saved rule records the command you approved. If that command contained a password, an API key or a token, the value can be written to disk in plain text. That file is meant to stay local. Git's ignore list tells git which files to skip. When Claude Code creates the file inside a git repository, it adds the file to your global ignore list. That covers the common case. It does not cover every case. A folder can become a repo later. A clone on another machine can miss the rule. A file someone already committed stays committed. Claude Code does not write the rule into the project's own `.gitignore`. So nothing travels with the repo to protect it. Apiiro looked for these files in public repositories. It found 1,122 secrets in `.claude/settings.local.json` files. It found another 1,160 in git history, in the shared `settings.json` that people commit on purpose, and in agent chat transcripts stored in repos. The evidence ties embedded credentials, passwords and API tokens to the local settings file. It does not say every one of the 2,282 findings was a live credential. One more problem: a pattern-based scanner looks for a key-shaped string. A key buried in the middle of a longer command is harder to match. That is analysis, not a claim from Apiiro. The convenience is real. The risk is that the approval decision is stored next to the command text. So the secret travels with the rule. Check your own settings files and your git history for tokens before you push.
How Claude Code's 'Don't Ask Again' Leaks Secrets — Visual Breakdown
# Rotate the exposed credential first. Removing the file does not remove it from history.
# 1. Find settings files git is tracking in this repo
git ls-files | grep -E 'settings(\.local)?\.json$' || echo 'no tracked settings files'
# 2. Search the working tree for common token prefixes.
# This covers .claude/ and a shared settings.json at the repo root.
# Note: 'sk-' is a broad prefix and matches non-secrets (e.g. sk-learn).
# Review every hit by hand.
grep -rnE 'sk-[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{20,}|npm_[A-Za-z0-9]{20,}' .claude/ settings.json 2>/dev/null || echo 'no matches found'
# 3. Search git history. The -n numbers are stream lines, not file lines.
# Pass A: everything (catches secrets committed outside .claude/).
git log -p --all | grep -nE 'sk-[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{20,}|npm_[A-Za-z0-9]{20,}' || echo 'no matches in history'
# Pass B: any settings file, wherever it lives.
git log -p --all -- '*settings*.json' | grep -nE 'sk-[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{20,}|npm_[A-Za-z0-9]{20,}' || echo 'no matches in settings history'
# 3b. To find the commit behind a match, use -S (pickaxe) or show context:
# git log -p --all -S 'ghp_' --oneline
# git log -p --all | grep -n -B20 'ghp_'
# 4. Stop future tracking of the local settings file (once).
# Creates .gitignore if missing; skips if the line already exists.
# This does NOT remove the secret from history. Rotate the key and rewrite history.
grep -qxF '.claude/settings.local.json' .gitignore || echo '.claude/settings.local.json' >> .gitignore
git ls-files --error-unmatch .claude/settings.local.json >/dev/null 2>&1 && git rm --cached .claude/settings.local.jsonQuick Concept Check
Test your understanding in 15 seconds
Why are secrets embedded in longer shell commands harder for pattern-based scanners to catch?
Related Concepts
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.