<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mathias Andersen</title>
    <description>The latest articles on DEV Community by Mathias Andersen (@mathias_andersen_d16e1dac).</description>
    <link>https://dev.to/mathias_andersen_d16e1dac</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272238%2F496c0d50-9138-40e2-aea8-f938bdae9289.png</url>
      <title>DEV Community: Mathias Andersen</title>
      <link>https://dev.to/mathias_andersen_d16e1dac</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mathias_andersen_d16e1dac"/>
    <language>en</language>
    <item>
      <title>Putting .env in .gitignore Doesn't Stop Cursor, Claude Code, or Copilot From Reading Your Secrets</title>
      <dc:creator>Mathias Andersen</dc:creator>
      <pubDate>Sun, 29 Nov 2026 12:12:53 +0000</pubDate>
      <link>https://dev.to/mathias_andersen_d16e1dac/putting-env-in-gitignore-doesnt-stop-cursor-claude-code-or-copilot-from-reading-your-secrets-1d04</link>
      <guid>https://dev.to/mathias_andersen_d16e1dac/putting-env-in-gitignore-doesnt-stop-cursor-claude-code-or-copilot-from-reading-your-secrets-1d04</guid>
      <description>&lt;p&gt;Every developer knows rule #1 of secret management: add &lt;code&gt;.env&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt; before your first commit.&lt;/p&gt;

&lt;p&gt;In 2026, that rule has a massive blind spot. &lt;strong&gt;&lt;code&gt;.gitignore&lt;/code&gt; only controls Git—it does not stop autonomous AI coding assistants inside your editor from reading &lt;code&gt;.env&lt;/code&gt; files on disk, indexing them into vector context, or sweeping plaintext API keys into cloud prompts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you work across &lt;strong&gt;VS Code (GitHub Copilot)&lt;/strong&gt;, &lt;strong&gt;Cursor&lt;/strong&gt;, &lt;strong&gt;Claude Code&lt;/strong&gt;, &lt;strong&gt;Windsurf&lt;/strong&gt;, or &lt;strong&gt;Gemini&lt;/strong&gt;, each assistant honors its own separate ignore or permission mechanism:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The 8 Ignore &amp;amp; Permission Layers Most Repos Miss
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Git (&lt;code&gt;.gitignore&lt;/code&gt;):&lt;/strong&gt; Blocks &lt;code&gt;git add&lt;/code&gt; on &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;.env.local&lt;/code&gt;, &lt;code&gt;.env.production&lt;/code&gt;, etc., while allowing &lt;code&gt;.env.example&lt;/code&gt; and &lt;code&gt;.env.vault&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cursor (&lt;code&gt;.cursorignore&lt;/code&gt;):&lt;/strong&gt; Without an explicit &lt;code&gt;.cursorignore&lt;/code&gt; covering &lt;code&gt;.env*&lt;/code&gt;, Cursor's local indexer and multi-file Composer workflows can touch local environment files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code Tool Boundary (&lt;code&gt;.claude/settings.json&lt;/code&gt;):&lt;/strong&gt; Simply listing &lt;code&gt;.env&lt;/code&gt; in an ignore file isn't enough when an agent has file-read tools. Adding explicit &lt;code&gt;permissions.deny&lt;/code&gt; rules (&lt;code&gt;Read(./.env)&lt;/code&gt; and &lt;code&gt;Read(./.env.*)&lt;/code&gt;) in &lt;code&gt;.claude/settings.json&lt;/code&gt; hard-blocks file reads at the tool boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Context Index (&lt;code&gt;.claudeignore&lt;/code&gt;):&lt;/strong&gt; Excludes &lt;code&gt;.env&lt;/code&gt; and &lt;code&gt;.env.*&lt;/code&gt; from workspace context indexing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Copilot Inline Disable (&lt;code&gt;.vscode/settings.json&lt;/code&gt;):&lt;/strong&gt; Mapping &lt;code&gt;".env*": "dotenv"&lt;/code&gt; and setting &lt;code&gt;"github.copilot.enable": { "dotenv": false }&lt;/code&gt; prevents accidental key autocompletion and prompt context capture while editing &lt;code&gt;.env.local&lt;/code&gt; (even if your &lt;code&gt;settings.json&lt;/code&gt; uses JSONC comments).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Copilot Agent Guardrail (&lt;code&gt;.github/copilot-instructions.md&lt;/code&gt;):&lt;/strong&gt; Instructs workspace agents never to read, grep, or echo &lt;code&gt;.env*&lt;/code&gt; secret files in terminal or chat turns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windsurf (&lt;code&gt;.windsurfignore&lt;/code&gt;):&lt;/strong&gt; Excludes &lt;code&gt;.env*&lt;/code&gt; from Cascade context indexing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini (&lt;code&gt;.aiexclude&lt;/code&gt;):&lt;/strong&gt; Blocks &lt;code&gt;.env*&lt;/code&gt; from Gemini workspace context.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2. The Second Leak Vector: Screen Shares &amp;amp; Pair Programming
&lt;/h3&gt;

&lt;p&gt;Even when your AI context rules are locked down, opening &lt;code&gt;.env.local&lt;/code&gt; on a quick Zoom, Teams, or Discord call exposes production &lt;code&gt;sk_live_&lt;/code&gt; or database URLs in clear text to everyone on the recording.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automating All 8 Layers Locally (Free VS Code Extension)
&lt;/h3&gt;

&lt;p&gt;After manually maintaining these 8 config files across every new client repository—and still worrying about &lt;code&gt;.env.staging&lt;/code&gt; drifting out of sync with &lt;code&gt;.env.local&lt;/code&gt;—I built &lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=msolutions-hq.envshield-ai-vault" rel="noopener noreferrer"&gt;EnvShield&lt;/a&gt;&lt;/strong&gt;, a zero-cloud VS Code extension that handles this 100% locally:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyytm153n8b3kd0g8folo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyytm153n8b3kd0g8folo.png" alt="EnvShield Preview" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Free Forever:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1-Click 8-Layer AI &amp;amp; Git Firewall:&lt;/strong&gt; Audits and writes &lt;code&gt;.gitignore&lt;/code&gt;, &lt;code&gt;.cursorignore&lt;/code&gt;, &lt;code&gt;.claude/settings.json&lt;/code&gt; (&lt;code&gt;permissions.deny&lt;/code&gt;), &lt;code&gt;.claudeignore&lt;/code&gt;, &lt;code&gt;.vscode/settings.json&lt;/code&gt; (&lt;code&gt;dotenv: false&lt;/code&gt;), &lt;code&gt;.github/copilot-instructions.md&lt;/code&gt;, &lt;code&gt;.windsurfignore&lt;/code&gt;, and &lt;code&gt;.aiexclude&lt;/code&gt; in one click.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Screen-Share Camouflage:&lt;/strong&gt; Automatically masks secret values (&lt;code&gt;••••••••••••&lt;/code&gt;) on inactive lines inside &lt;code&gt;.env*&lt;/code&gt; editor tabs while keeping variable names readable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;.env&lt;/code&gt; Drift Check &amp;amp; Safe &lt;code&gt;.env.example&lt;/code&gt; Generator.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optional One-Time Pro Unlock (No Subscriptions):&lt;/strong&gt; Side-by-side multi-environment matrix editor (&lt;code&gt;.env.local&lt;/code&gt; vs &lt;code&gt;.env.staging&lt;/code&gt; vs &lt;code&gt;.env.production&lt;/code&gt;), pre-commit hardcoded key scanner, and local &lt;code&gt;AES-256-GCM&lt;/code&gt; &lt;code&gt;.env.vault&lt;/code&gt; encryption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zero cloud accounts, zero npm runtime dependencies, and nothing leaves your machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VS Code Marketplace: &lt;a href="https://marketplace.visualstudio.com/items?itemName=msolutions-hq.envshield-ai-vault" rel="noopener noreferrer"&gt;EnvShield — .env Vault, Secret &amp;amp; AI Firewall&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Guide &amp;amp; Docs: &lt;a href="https://envshield.mandersen097.workers.dev" rel="noopener noreferrer"&gt;envshield.mandersen097.workers.dev&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I missed an ignore file for another AI coding agent you use daily, let me know in the comments and I'll add it to the free firewall!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>security</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
