You ask your coding agent to "figure out why the Stripe webhook fails locally." Thirty seconds later the transcript shows it ran cat .env to check the config, and your live secret key is now sitting in a chat log.
That's a perfectly reasonable debugging step. It's also a reminder that the agent can read everything your user account can read unless you say otherwise. Here's what I'd set up on a Mac before the next session. Everything below was checked against the official docs or repos in December 2026.
1. Claude Code deny rules for .env files
Claude Code settings (built in). Add "deny": ["Read(./.env)", "Read(./.env.*)"] under permissions in ~/.claude/settings.json and Claude Code's Read tool can't open them. Deny rules apply right away, even before a teammate trusts a shared project folder.
2. Claude Code's Bash sandbox
/sandbox (built in, off by default). The deny rule above covers the Read tool, not shell commands, so this is the other half. On macOS it uses the built-in Seatbelt framework: writes stay in the working directory, network goes through a proxy with an allowlist that starts empty, and a sandbox.credentials block can hide ~/.ssh, ~/.aws/credentials and variables like GITHUB_TOKEN from sandboxed commands.
3. Codex CLI's default sandbox
Codex CLI (included with ChatGPT plans). Codex already starts locked down: the default workspace-write mode limits writes to the workspace and keeps network access off unless you turn it on. When I only want it to read and plan, codex --sandbox read-only --ask-for-approval on-request keeps it from touching anything.
4. 1Password CLI so .env holds no real secrets
1Password CLI (needs a 1Password account). Replace each value in .env with a secret reference like op://dev/stripe/secret_key, then start the app with op run --env-file=.env -- npm run dev. The real values only exist in that process's environment while it runs, so an agent that reads the file sees references, not keys.
5. Secretive for SSH keys
Secretive (free, MIT, brew install secretive). It keeps SSH keys in the Mac's Secure Enclave, where they can't be exported by design, and can require Touch ID before each use. It also sends a notification whenever a key is used, which is a nice tell if an agent runs git push you didn't expect.
6. gitleaks as a pre-commit hook
gitleaks (free, open source, brew install gitleaks). Agents love git add -A. Wire gitleaks in through pre-commit and a commit that contains a key fails before it exists, and gitleaks git -v scans the history you already have.
7. GitHub push protection
Push protection (on by default for your account on public repos). It blocks pushes containing secrets it recognizes to public repositories, and with GitHub Secret Protection, repo admins can turn on the repository-level version for bypass alerts and custom patterns. It's the last net if the hook was skipped.
8. TokenBar to notice usage you didn't cause
Not a security tool, but a usage jump during a stretch when I wasn't prompting anything is usually the first sign that a headless script or forgotten session is still running somewhere.
TokenBar is a menu bar app that shows usage and reset times for Claude, Codex, Cursor, Gemini and Copilot in one place. It's built on Peter Steinberger's MIT-licensed CodexBar and credits Pixel Agents. It doesn't add any quota. macOS 14+, $5/month (Basic) or $15 lifetime (Pro).
9. LuLu for outbound connections
LuLu (free, open source, from Objective-See). macOS's built-in firewall only blocks incoming connections. LuLu alerts on new outgoing ones and shows the process and destination, so a dev server or script you've never seen phoning out to a new host gets a prompt instead of silence.
The short version
| Risk | What I'd use |
|---|---|
Agent reads .env with its file tool | Claude Code deny rules |
Agent runs cat .env or reaches ~/.ssh | /sandbox with credentials |
| Codex edits or connects too freely | Default workspace-write, or read-only |
| Real secrets sitting in plain text | 1Password op run |
| SSH key copied off disk | Secretive |
| Key ends up in a commit | gitleaks pre-commit |
| Key ends up in a push | GitHub push protection |
| Session you forgot is still burning usage | TokenBar |
| Unknown process calling out | LuLu |
What's in your agent's deny list right now, and did you write it before or after something went wrong?

