How to stop your coding agent from reading your .env secrets
Dev.to AI
•
Generative AI
Open Cursor, Claude Code, or any MCP-enabled agent in your project and ask it to "fix the failing test." To do that, it reads files. Lots of them. And nothing stops it from reading this one:. en It doesn't matter that.en is in your.gitignore. gitignore keeps it out of git - it does nothing about a read_file('.en') tool call dropping STRIPE_SECRET_KEY=sk_live_. straight into a model's context window. The same file that boots your de server is sitting in plaintext, on disk, readable by every agent you've invited into your editor.