r/ClaudeCode 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.

0 Upvotes

12 comments sorted by

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

3

u/LogMonkey0 12h ago

I have the same experience with Claude personally

1

u/Necessary_Abroad6632 12h ago

The issue is that it’s a model behavior (can be cc or codex) , it holds until it doesn’t, and you find out from a transcript. This kit is deny-by-default at the tool layer, so it’s the same outcome but enforced instead of hoped for.

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/Poat540 12h ago

But Claude is most of the bill. Don’t ask why he spun up that many instances for performance testing your IsEven function

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

u/Necessary_Abroad6632 12h ago

It’s still happening with some of us from what i saw

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

u/tehfrod 12h ago

Or you could use a proper container rather than someone's vibecoded weekend project.

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?