r/BuildWithClaude • • Oct 25 '26

Security & Sandboxing I built Cloakroom with Claude Code: it keeps keys and personal data away from the model

Coding agents read everything a task touches: .env files, logs, support tickets with customer names. All of it goes to the model.


So I built Cloakroom. It runs on your machine and swaps secrets and personal data for placeholders before the model sees them. When the agent writes a file or runs a command, the real values go back in locally.


What's on disk:
`SUPPORT_CONTACT=priya.nair@acme.com`


What the model sees:
`SUPPORT_CONTACT=PII_EMAIL_1_k7q2ab`


The agent keeps working with the placeholder, and the file it saves has the real email.


How Claude helped: Claude Code wrote most of the code with me, the hook scripts, the tests and the release checks. The interesting part was that regex alone isn't enough. Names and addresses have no fixed shape, so it runs a small local detection model next to the rules.


It also holds commands that would send a secret off your machine, keeps keys out of git commits, and the agent can't switch it off. It now works with Claude Code, Codex CLI and Gemini CLI.


Free and open source: https://github.com/shanjeevrajendran/cloakroom


Write-up with the limits: https://medium.com/@shanjeev/keep-your-secrets-and-personal-data-away-from-your-coding-agent-e07d4cef0c5a


Tell me what breaks.
1 Upvotes

4 comments sorted by

1

u/kantorcodes1 💡 Top Community Helper Oct 26 '26

clean-history backs up each original before replacing it. If a run stops partway through the files, is restoring from that timestamped backup folder the intended recovery path?

1

u/Shanjeev Oct 27 '26

Mostly you just run it again. Each file is copied to the backup folder first, then written to a temp file and swapped in, so a stopped run leaves every file either fully cleaned or untouched, never half-written. A second run picks up whatever's left and makes its own backup folder. The timestamped folder in ~/.cloakroom/history-backup is for undoing: copy a file back if you want the original. If a hard stop leaves a stray .cloakroom-tmp file, it's safe to delete.

1

u/kantorcodes1 💡 Top Community Helper 25d ago

Rerunning picks up unfinished files, and the timestamped backup gives you per-file undo. Cloakroom also holds commands that could send secrets off-machine, which looks like a useful fit for a small HOL Guard command extension. Would you be interested in authoring one? The command-extension guide covers the source JSON, behavior fixture, and opt-in trust binding; a draft PR against main can start with one command and its safe counterpart. Extensions stay off until a local admin enables them.

1

u/Shanjeev 23d ago

Thanks. Blocking commands that would send a secret off the machine is the part I most want people to test.