Running AI agents in a repo full of .env files
Your agent needs this project's keys to run it. It doesn't need the .env files of every other project on your Mac, and the keys shouldn't leave for anywhere but their own service.
● Bash(cat apps/api/.env)
⎿OPENAI_API_KEY=sk-proj-… DATABASE_URL=postgres://…
● Bash(cat ~/Dev/client-site/.env)
⎿Muzzle blocked this: it reads your env file from another project (~/Dev/client-site/.env). To allow it, click Allow on this entry in Muzzle's Activity.
● Write(scripts/notify.ts)
⎿Muzzle blocked this: a secret (slack-token, xoxb…7Hk2) would be written into notify.ts:12 in an HTTP request, so it would go out with every request that code makes. Remove it, or read it from the environment at runtime.
What your agent can and can't do with .env
.env files in the repo you're working inThe whole git repo counts, so every package in a monorepo is in
Allowed.env.example and other templates.env files in other projects
BlockA key from .env sent to its own service
AllowedA key from .env sent anywhere else, or hardcoded into a request
BlockBefore it reaches git
The commit check stops a commit that puts a key where the code sends it out. Keep .env itself in .gitignore.
Related
Put Muzzle between your agents and the internet
Download for Mac
Free · Apple Silicon · macOS 12 or later