I made a new folder on my laptop, typed git init, and dropped a file into .claude/ with a made-up key in it. Then I ran the three commands every one of us runs without thinking: git status, git add ., git commit. Nothing stopped me at any step. The file went in like any other file, and the commit took it without a word.

That is the whole story of the Claude Code secrets leak, and it is less interesting than the headlines make it sound. It is also worse.

GitGuardian's scan found tens of thousands of distinct keys sitting in .claude/settings.local.json files in public repos and in Docker images. That count is theirs, not mine, and I am quoting it as their finding. What I wanted to know was simpler: is there anything standing between that file and a commit on a normal machine? So I tested it, with a fake key that never belonged to anything.

A fresh repo has no .gitignore at all. Git does not ship one, the folder does not come with one, and nothing I did created one. git status showed the folder as untracked. git check-ignore said the file was not ignored. git add . staged it. The commit took it in, one file, three lines added. There was no warning, no prompt, no second chance. The file looks exactly like the kind of local config you would expect git to leave alone, and git treats it exactly like the kind of file it should track. Both of those things are true at the same time, and that is the trap.

Here is the part that surprised me. I ran the same test again in my normal setup, the one I actually work in, and the file was invisible. git status showed nothing. git add . staged nothing. For a second I thought I had proved the leak was overblown. Then I looked at why.

Months ago I had added two lines to git's global ignore file on that machine, the one that applies to every repo on the laptop. It lists .claude/settings.local.json, and it has a comment above it explaining why. That rule did its job. The file never stood a chance on that machine.

But that rule lives in one file, on one laptop, that I set up by hand. It does not travel. It is not in the repo. A teammate cloning the project does not get it. A new laptop does not get it. A Docker build does not get it. The next person to run git add . in that project, on a machine without that rule, gets the exact result my fresh test got: the file goes in, quietly, on the first commit.

That is the shape of this leak. It is not one bug in one tool. It is a file that holds keys, sitting in a folder that looks like config, in a tool people install and then forget about, protected by nothing except rules that individual people happened to add on individual machines. GitGuardian's count is what you get when you multiply that gap across every developer who never added the rule. The file gets written when you approve commands and set local options. The keys land in it because that is where the tool keeps them. And the commit that publishes them is the most ordinary command in a developer's day.

So the argument is not about whether the tool should write the file. It is about where the protection lives. A rule on my laptop protects my laptop. A rule in the repo protects everyone who touches the repo. Those are different things, and only one of them scales.

There is a second habit worth naming, because it is the one that decides whether the leak happens on day one or day ninety. Most of us run git add . the way we press save: without looking. It is fast, it feels safe, and in a repo you have worked in for months it usually is, because everything in there has already been committed once. The danger is the new folder, the fresh clone, the project you just started. That is where the files you have never seen live, and git add . takes all of them in one move. The fix is small and annoying: run git status first, read the list, and only then add. It takes ten seconds. It is the only step in the whole chain where a human actually looks.

Three things failed here, and they fail in order.

  1. Nothing ignores the file by default. A fresh repo has no ignore file, and nothing in my test added one. The first commit of a new project is the most dangerous one, because that is when git add . sweeps up everything in the folder, including the files you have not looked at yet.

  2. The protection people do have is local. A global ignore, a careful habit, a memory of having been burned once: all of these work on one machine and vanish the moment the work moves somewhere else. The Docker images in GitGuardian's findings are the proof of that. A key that never reached a repo can still reach an image, because the image build copies the folder the same way git add . does.

  3. The file is easy to commit by accident because committing it feels like nothing. There is no step where a person looks at the file and decides. git add . does not show you what it took unless you ask. The leak does not need anyone to do anything careless. It needs them to do the normal thing, once, in a new folder.

I tried to count how many of these files are still sitting in public repos myself, and I could not do it cleanly from here. The search needs a login I do not have on this machine, and I am not going to work around that and pretend the number is mine. So I am not giving you a count. The mechanism is the part I can stand behind, because I watched it happen in both directions: ignored on the machine with the rule, committed on the machine without it.

What actually fixes it is boring, which is probably why it does not happen. Put .claude/ in the repo's own .gitignore and commit that file, so the rule travels with the project instead of living on one laptop. Look at git status before the first commit of anything new, not after. Keep the global ignore too, it is still worth having, but stop treating it as the fix. And if a key ever did go in, rotate it. Removing the file from history is a separate job, and a key that was public for an hour is a key that needs replacing, not just deleting.

The uncomfortable part is how little of this is about the tool at all. The file is where the tool puts it. Git does what git does. The gap is the step nobody owns: making sure the ignore rule lives in the repo, not in one person's setup. Until that step happens, the next fresh folder will leak the same way, and the next scan will find another pile of keys that nobody meant to publish.

What has your .gitignore caught, and what slipped through it? I am curious whether anyone here found a key in a repo they thought was clean, and what made them look.

P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam

Buy me a coffee

AheadKit on Gumroad — Beginner-Friendly Books & Packs