Last week, security firm Apiiro showed how one convenient button in Claude Code put live credentials on public GitHub, in a form that GitHub secret scanning and similar tools often miss. When a developer approves a shell command with "Yes, and don't ask again," the exact command gets saved to a project file. If that command had a password in it, the password is now sitting in plain text, and sometimes it ends up in a commit.
If your team uses AI coding agents, the numbers matter. Apiiro found 1,122 copies of that file holding at least one secret, and popular scanners missed a big share of them. If one scanner is your only safety net, this is a good week to check what it actually catches.
TL;DR#
- Claude Code's "don't ask again" approvals can save full commands, including inline passwords and tokens, to
.claude/settings.local.json, and over a thousand of those files are public on GitHub. - Pattern-based scanners catch provider keys well but miss plain passwords typed into commands. Gitleaks and TruffleHog together missed 215 of the 1,122 files.
- The fix is cheap: rotate anything exposed, ignore agent config folders in every repo, scan history, and stop typing secrets into agent commands.
What happened with the Claude Code "don't ask again" file#
By default, Claude Code asks before running most shell commands. Choose "Yes, and don't ask again" and it writes an allow rule into .claude/settings.local.json inside the project. A pattern like npm test * is harmless. A rule that stores one exact command is not, because whatever you typed into that command gets saved too, as The Hacker News explains.
Apiiro's researchers found 104,185 copies of the file across 103,617 public repositories. About 1.1% of them, 1,122 files, held 1,379 distinct secrets. Counting older file versions, the shared .claude/settings.json and saved agent chat logs, the total reached 2,539 secrets across 1,994 repositories, according to GBHackers.
What leaked wasn't trivial test data. iTnews reports 379 database passwords, 122 Supabase service-role keys, 43 SSH logins (some with root passwords), and 42 tokens for GitHub, GitLab and npm. Named examples included a production Square token and the owner password for a medical-records app's database.
Why the file reached GitHub at all#
Claude Code adds the file to your global git excludes on first write. It doesn't add it to the project's own .gitignore, so the protection stays on one laptop and doesn't follow the repo to a teammate, a CI runner or a fresh clone. Boris Cherny, who leads Claude Code, said on Hacker News that the team is looking at secret scanning and auto mode changes, and noted that "historically Claude Code has not done secret scrubbing" (iTnews). No fix had shipped at the time of writing.
Why GitHub secret scanning alone won't save you#
Most secret scanners, GitHub's included, are best at provider keys with a recognisable format, like AWS keys or GitHub tokens. GitHub's supported patterns list hundreds of those. Generic password detection exists too, but what you get depends on your plan and the settings you've turned on.
The leaked passwords in this case mostly had no format at all. They looked like PGPASSWORD=hunter2 psql ... or sshpass -p 'secret' ssh root@... or mysql -p.... There's no prefix for a regex to latch onto.
So the scanner results were uneven. Of the 1,122 files, gitleaks flagged 564 and TruffleHog flagged 643, and neither caught 215. Run both and you still miss about one file in five.
There's also a timing problem. In half of the affected repositories, the secret file had been public for at least 217 days. Scanning that only runs on new pushes doesn't help with what's already in history, and forks keep their own copies: 211 forks of 74 repositories carried the same secrets.
Where coding agents put secrets: a quick comparison#
Coding agents keep state in project folders, and that state often holds whatever you typed or pasted.
| Where secrets end up | Typical example | Caught by provider-pattern scanning? |
|---|---|---|
| Agent permission files | .claude/settings.local.json allow rules with full commands | Only if the secret has a known format |
| Agent chat logs and history | .specstory/ transcripts, saved sessions | Partly; pasted passwords usually slip through |
| Other agent config folders | .cursor/, .gemini/ | Depends on contents |
| Shell commands in scripts | PGPASSWORD=... psql in a Makefile | Rarely |
| Classic config files | .env, config.yml | Usually, if keys are provider-formatted |
Apiiro compared the docs of 16 coding agents and found Claude Code was the only one confirmed to save the full approved command in a project file by default. Still, their advice to security teams covers all of these folders: treat .claude/, .cursor/, .gemini/ and .specstory/ the way you treat .env files.
What it means for businesses without a security team#
If you're a 20 to 200 person company, nobody is watching commits all day. You might have two in-house developers, a contractor, and an agency that touched the codebase last year. Any of them may have used a coding agent with production credentials in hand, and approving "don't ask again" feels like a harmless time saver. Nobody thinks about where that approval is stored.
The cost of getting this wrong isn't abstract. A leaked Supabase service-role key bypasses row-level security. A leaked Square or Stripe token touches money. An SSH root password is the whole server. Apiiro didn't test whether credentials still worked, but one affected company did confirm its key was live.
The good news: none of the fixes below need paid tools.
How to act on it: a checklist#
- Search every repo, including history. Look for
.claude/settings.local.jsonand.claude/settings.jsonacross your GitHub organisation, and check git history, not just the current branch. - Rotate first, clean up second. Any credential that ever appeared in those files is compromised. Change it before you delete anything, because deleting a file doesn't remove it from history or forks.
- Untrack and ignore. Run
git rm --cached .claude/settings.local.jsonand add agent folders to every repo's.gitignore, plus your organisation's repo templates. - Approve patterns, not commands. Allow
Bash(npm run:*)rather than one long command with a password in it. - Keep secrets out of commands. Reference variables like
$DATABASE_URLthat load from a secrets store or an untracked env file. - Scan for passwords, not just keys. Add pre-commit and CI scanning that covers history and catches inline passwords. Turn on GitHub secret scanning and push protection where your plan allows.
A minimal .gitignore block looks like this:
# AI coding agent state
.claude/settings.local.json
.cursor/
.gemini/
.specstory/
How MagicMakers Lab approaches this#
We use AI coding agents every day, and we treat their config folders like any other place secrets can hide. On custom software builds we set up ignore rules, CI scanning and a secrets store from day one, so nobody types a production password into a terminal. That discipline matters more as automation grows: a system like the one we built for Framico, shipping 200+ orders a day with zero manual steps, touches payments, carriers and storefronts, and every one of those connections is a credential. If your code has passed through several hands, a quick review of what's sitting in your repos is usually the cheapest security win available.
Key takeaways#
- Claude Code's "don't ask again" can store full commands, secrets included, in a project file that's easy to commit by accident.
- Format-based scanners miss plain passwords; in Apiiro's data, two popular tools together still missed 215 of 1,122 files.
- Treat agent folders (
.claude/,.cursor/,.gemini/,.specstory/) like.envfiles in every repo. - Rotate exposed credentials before cleaning history, and check forks.
- Approve command patterns and reference secrets through variables, never inline.
FAQ#
What does GitHub secret scanning detect?#
It scans repository content and history for credentials that match known formats, such as tokens from GitHub, AWS, Stripe and hundreds of other providers. Paid plans add push protection and some generic secret detection. It's weaker on plain passwords typed into commands, because those have no recognisable format, so pair it with history scanning and good habits around where secrets live.
Is Claude Code safe to use with production systems?#
It can be, with care. The risk in this case comes from approving exact commands that contain credentials, then committing the settings file. Keep secrets in environment variables or a secrets manager, approve command patterns instead of one-off commands, and make sure .claude/settings.local.json is in every repo's .gitignore, not only your global git excludes.
What should I do if I find leaked API keys on GitHub?#
Rotate the key or password immediately, then review access logs for misuse. After that, remove the file from tracking and rewrite history if needed. Deleting the file in a new commit isn't enough, because the secret stays in history and in any forks. Finally, add scanning so the same mistake gets caught before the next push.
Which secret scanning tools catch passwords in shell commands?#
No single tool catches everything. In Apiiro's test, gitleaks flagged about 50% of the affected files and TruffleHog about 57%. Combining a pattern scanner with custom rules for strings like PGPASSWORD=, sshpass -p and mysql -p closes much of the gap. Removing secrets from commands entirely is the more reliable fix.
Not sure what your repos are carrying? We'll look with you and tell you what to fix first. Book a free audit.
Sources#
- Claude Code's "Don't Ask Again" File Exposes Passwords and Keys in 1,122 Public Copies on GitHub (The Hacker News)
- "Don't ask again" in Anthropic's Claude Code leaks developer secrets (iTnews)
- Claude Code's "Don't Ask Again" Feature Exposes 2,539 Secrets Across 1,994 GitHub Repositories (GBHackers)
- About secret scanning patterns (GitHub Docs)