r/coolgithubprojects • • 3h 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
0 Upvotes

1 comment sorted by

0

u/fajarhide 3h ago edited 49m ago

author here. i told my coding agent not to read .env and it kept doing it anyway through normal steps, cat .env to check one setting, docker inspect on a crashing container, ps aux to find a process, git show on 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 gets denied if it would print a credential source, and the denial tells the agent how to 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 and never by value

measured with headless claude code on projects seeded with fake keys, 18 of 30 sessions leaked a key without the hooks and 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 one is fixed now

install with 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's actively trying, and the readme lists the limits. where would it get in your way?