Safe8bit: keep .env files and API keys out of Cursor's agent (beforeReadFile / beforeShellExecution hooks, macOS)

Cursor’s agent reads .env files whenever it needs to understand a config, and the key ends up in the chat context.

I built Safe8bit, a secrets vault for macOS, and its Shield plugs into Cursor’s hooks (beforeReadFile and beforeShellExecution):

  • denies reading .env files, private keys and credential files (.netrc, ~/.aws/credentials…), directly or through cat/grep/python/curl @file
  • denies reading any file that contains a value stored in the vault
  • asks you before printenv, env or safe8bit read, including inside sh -c and safe8bit run --
  • tells the agent to use safe8bit run -- npm run dev instead, which puts the variables into the process. Touch ID asks you, not the agent.

Install: brew install --cask safe8bit-app/tap/safe8bit, then safe8bit shield install (it finds ~/.cursor and ~/.claude).

The vault is encrypted on the Mac (AES-256-GCM, Argon2id, key in the Secure Enclave), with no account and no server. It’s a guardrail against accidental leaks, not a sandbox: code the agent runs can still read its own environment.

Lite is free forever (the Shield only logs there); Pro is $39/year and blocks. I’m the developer, happy to answer questions.

Demo and download: Safe8bit — the secrets vault for developers

Curious how others keep secrets away from the agent today.