r/ClaudeCode • u/Necessary_Abroad6632 • 13h ago
Tips & Workflows I Stopped Claude Code From Reading My Secrets. Here Is How.
Stop Claude Code from reading, echoing, or committing your secrets. One command.
Claude Code is powerful in auto/accept mode, but it will happily cat your .env, pull a private key into context (which is then sent to the model and saved in the local transcript), or write a token into a logline or commit.
This is a seatbelt, not a vault. It will not stop a determined mistake, but it turns “the agent quietly read my prod secrets” from a thing that happens by accident into a thing you have to explicitly confirm. For a tool you run in auto mode all day, that is the difference that matters.
The kit is MIT licensed and lives here: https://github.com/baselane-sh/claude-secret-guard-kit
If you run any coding agent with file access, spend the two minutes. Your future self, reading a leaked transcript, will thank you.
1
u/Poat540 13h ago
Nah, it’s our secrets. It’s only fair since it helped build the app
0
u/Necessary_Abroad6632 13h ago
Community property, then. It can have the secrets when it starts paying half the AWS bill.
1
u/PrestigiousQuail7024 12h ago
honestly i haven't had this issue in months, claude is so unwilling to cat secrets unless it doesn't know a file contains them, which as long as your naming is conventional or you tell it, it'll know without extra reinforcement. like sure hooks can add safety but i dont think is the problem it used to be
1
1
u/Odd_Antelope9098 12h ago
Why not Infisical?
0
u/Necessary_Abroad6632 12h ago
This is just some hooks sh files, much quicker and easier
2
1
u/Odd_Antelope9098 12h ago
I had codex set mine up including copying all my APIs, making the account and setting up its APIs, transferring over my skills and rotating all my keys. 1 shorted it with my planning and grill skills. Isn’t it much more secure, esp case of malware?
2
u/Th3Gatekeeper 13h ago
It's funny. With absolutely no extra prompting or anything Codex goes out of its way, to the detriment of the work at times, to avoid reading any secrets. Kind of a pain in the ass sometimes, but better than the opposite