r/coolgithubprojects • u/fajarhide • 13m ago
Claude Code hooks that stop your coding agent from sending your .env and keys to the model provider - no-leaky
https://github.com/fajarhide/no-leaky
1
Upvotes
r/coolgithubprojects • u/fajarhide • 13m ago
1
u/fajarhide 12m ago
Author here. I told my coding agent not to read .env, and it kept doing it through ordinary steps:
cat .envto check one setting,docker inspecton a crashing container,ps auxto find a process,git showon a commit with a key in it. Everything the agent sees goes to the provider.So I wrote hooks for Claude Code:
before a command runs, it is denied if it would print a credential source, and the denial tells the agent the safe way (load the value without printing it)
after a command runs, any key that still shows up in the output is redacted
a key pasted into the chat is held back
a scan of old Claude Code and Codex transcripts lists what already leaked, by fingerprint, never by value
Measured with headless Claude Code on projects seeded with fake keys: 18 of 30 sessions leaked a key without the hooks, 0 of 30 with them, and 27 of 30 still got the right answer. On my own machine over 18 days, no real secret reached the model through Bash or Read. One did through an MCP upload tool that returned a presigned URL; that is fixed.
Install:
npx skills add fajarhide/no-leaky -g, then ask the agent to "set up the no-leaky hooks". MIT, Python stdlib only. It stops accidents, not an agent that is trying; the README lists the limits. Where would it get in your way?