My tool used to show what my AI agent read. Now it blocks first. A developer built agentwhy, an open-source CLI that now blocks AI coding agents from reading private files such as .env files, SSH keys and credential configs before they reach the model, rather than only reporting on access after the fact. The tool adds rules to Claude Code's file tools and a check on shell commands that refuses patterns like `cat .env`, `cat .env*` and `grep -r` over folders holding private files, plus a `protect` command for paths outside project folders and an `init --hide-keys` option that swaps recognised keys for placeholders before the model reads them. The developer says the approach closes more than a deny list of verbs but is not a sandbox, missing runtime-built paths, scripts, `sh -c` wrappers, attached files and encoded or partial keys. On 11 September 2026 a read-only Claude Code subagent brought part of a secret from apps/web/.env.development into my chat. The first rule in my AGENTS.md said never to read .env files. The subagent never saw that rule. It got one task, "confirm what URL and secret it's configured to use", searched the project for the variable's name, and the search printed the line with the value. I wrote that up in AGENTS.md is not a firewall https://www.agentwhy.dev/blog/the-rule-that-never-reached-the-helper.html . Then I built agentwhy https://github.com/karolkozer/agentwhy , an open source CLI that reads the conversations Claude Code already saves on your disk and shows which private files an agent reached, from which task, and which key to change. For two months agentwhy was mostly that: a report you read afterwards. I have now turned the order around. On 14 October I posted the incident on r/ClaudeCode and r/SideProject. By the evening there were four comments. All four were about the commenters' own defences: secrets kept off the mount, stub env files, hooks before and after a tool call, 1Password op:// references, not pasting keys at all. Nobody asked how to check afterwards. Four comments is a small sample. But it matched what my own write-up already said: the things that hold are the ones in front of the read. A report tells you which key to change. It does not take the key back from the model provider. So agentwhy now blocks the obvious routes first. The report stays, as the last layer, for whatever gets through. Each one with what it stops and what it misses. npx @agentwhy/cli init init adds rules to Claude Code's own file tools and a check on shell commands. The check refuses cat .env , a glob such as cat .env , and grep -r over a folder that holds a private file. That last one is the route from my incident: a search that never names .env but prints from it. The same check runs in Codex from the first message, and in GitHub Copilot once you turn it on. init shows exactly what it will write and asks first. By default it treats these as private: .env , .env , .npmrc , secrets/ , .ssh/ , id rsa . Add your own with init --protect "config/ .pem" . What gets past it: a path built while the command runs, a script, or a command handed to another shell sh -c '…' . It is not a sandbox. In September a Bash deny list of cat , grep and head let python3 -c print a whole file on my machine. A check on what a command reads closes more than a list of verbs, but not everything. Settings in agentwhy's demo, a made-up project: each private file is Block or Track. A report where the block worked: the AI tried to open .env.production and was stopped in time. Your SSH keys and cloud logins sit in no project folder, so no project's rules name them. npx @agentwhy/cli protect "~/.ssh/ " This keeps that place from your AI in every project: Claude Code's own file tools, and the shell commands agentwhy checks. Measured on a Mac in Claude Code's terminal. VS Code, the desktop apps and Windows are not measured yet. A key can sit in config/payments.yml , and no rule names that file. With init --hide-keys , or one switch in Settings, agentwhy swaps a key it recognises for a placeholder before Claude Code's AI reads it: config/payments.yml, on your disk stripe: secret key: sk live … what your AI reads stripe: secret key: redacted by agentwhy Your file stays as it is. The AI is told the real value is still there and not to write the placeholder back, so an edit around the key keeps it. In Codex the same switch hides a key in what a shell command printed. What it misses: in Claude Code a command that fails, a file you attach to a message, part of a key, a key that is encoded or split, and a password of no known format. It lowers the risk; it does not remove it. Through npx , each step of your AI takes about half a second longer. This one is not the agent's doing. You paste a config block so your AI can set something up, and a live key is in it. agentwhy stops that message before your AI reads it: agentwhy blocked this message before your AI read it: it holds a Stripe key line 6 . Put it in .env as STRIPE SECRET KEY, and send the name instead. It knows a key by its format, and a password in a URL. A sample key passes. It keeps nothing of the key. This runs in Claude Code and Codex. The limits: Claude Code and Codex still save the blocked message, key included, in their own files on your disk. Codex's desktop app and its VS Code panel name a new chat from its first message even when that message is blocked, so there the key may have reached a model, and agentwhy adds a line asking you to change it. If the check itself breaks, the message goes through. Copilot is not covered. npx @agentwhy/cli This is where agentwhy started, and it stays. It reads the conversations Claude Code, Codex and Copilot already save, from the last 7 days, on your computer, and opens a page that shows which private file was reached, which task led there, and which key to change. It works on history from before you installed it. Nothing leaves your computer, and no secret value appears in the report. The week in the demo: how many conversations read something private, and where to start. On 29 scripted sessions, each one a route I wrote, it said to change the key in 14 of 18 where a value came in, named the task a helper was given in 5 of 5, and kept every secret out of the report in 29 of 29. Those are my scenarios, misses listed, not a rate on real machines: docs/detection.md https://github.com/karolkozer/agentwhy/blob/main/docs/detection.md . Because every layer above has a gap I can name, and some routes no rule sees. In my incident nothing told me: no prompt, no warning. In my setup a read refused by a deny rule fired no hook, so my audit log stayed empty. The whole story was only in the saved conversation. Once a key reaches a conversation, it is with the model provider. Deleting the chat does not take it back. Changing the key does, and the report is how you know which key. Fix it goes one file at a time, one step per screen. To try both halves in a project: npx @agentwhy/cli init block the obvious reads in this project npx @agentwhy/cli see what your AI has already read It needs Node 22 or later. It is made and tested on a Mac; on Windows it is new and still being tested. It is also a Claude Code plugin, and it is open source under Apache 2.0: github.com/karolkozer/agentwhy https://github.com/karolkozer/agentwhy . Which of these layers do you already have, and which one did you add only after something got through?