<?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: Guih</title>
    <description>The latest articles on DEV Community by Guih (@guih).</description>
    <link>https://dev.to/guih</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%2F4284527%2F2674e051-2cef-4a11-913f-bca20b878a10.png</url>
      <title>DEV Community: Guih</title>
      <link>https://dev.to/guih</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guih"/>
    <language>en</language>
    <item>
      <title>I built a CLI that compares .env files without ever printing a secret</title>
      <dc:creator>Guih</dc:creator>
      <pubDate>Sat, 05 Dec 2026 10:58:34 +0000</pubDate>
      <link>https://dev.to/guih/i-built-a-cli-that-compares-env-files-without-ever-printing-a-secret-3bdp</link>
      <guid>https://dev.to/guih/i-built-a-cli-that-compares-env-files-without-ever-printing-a-secret-3bdp</guid>
      <description>&lt;p&gt;You know the bug: production fails, staging works, and an hour later you find &lt;code&gt;REDIS_URL&lt;/code&gt; missing from &lt;code&gt;.env.production&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The quick way to find it is &lt;code&gt;diff .env.staging .env.production&lt;/code&gt;. The problem is that it prints your database password and API keys straight to the terminal, and from there into CI logs, screenshots and the pull request where you pasted it.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;envdiff&lt;/strong&gt;: it compares env files and shows &lt;strong&gt;key names only&lt;/strong&gt;. Values are compared in memory and never printed.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Guihakka2/envdiff" rel="noopener noreferrer"&gt;https://github.com/Guihakka2/envdiff&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;No install needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @guihakka2/envdiff                          &lt;span class="c"&gt;# compares every .env* file in this folder&lt;/span&gt;
npx @guihakka2/envdiff .env.staging .env.production
npx @guihakka2/envdiff --scan .                 &lt;span class="c"&gt;# does .env.example cover every key the code reads?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;envdiff  .env.staging  vs  .env.production

Missing in .env.production:
  - REDIS_URL

Different values (hidden):
  ~ DATABASE_URL

Possible real secrets in template files:
  ! .env.example: AWS_ACCESS_KEY_ID (line 3)

✗ Not in sync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You learn that &lt;code&gt;DATABASE_URL&lt;/code&gt; differs. You never see what it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it checks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Missing, extra and changed keys across &lt;strong&gt;2 or more&lt;/strong&gt; files&lt;/li&gt;
&lt;li&gt;Real-looking secrets (AWS, GitHub, Stripe, OpenAI, JWT, private keys…) committed to &lt;code&gt;.env.example&lt;/code&gt; and other templates&lt;/li&gt;
&lt;li&gt;A real &lt;code&gt;.env&lt;/code&gt; committed to git (fails) or missing from &lt;code&gt;.gitignore&lt;/code&gt; (warns)&lt;/li&gt;
&lt;li&gt;Typos, with "did you mean &lt;code&gt;DATABASE_URL&lt;/code&gt;?"&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--scan .&lt;/code&gt;: keys your code reads that no env file defines, and keys nobody uses. Works for Node, Python, Go, Ruby, PHP, Java, Rust, C# and docker-compose&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;# @expire 2027-03-31&lt;/code&gt; above a key warns 30 days before a token expires&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zero dependencies, runs offline, sends nothing anywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  In CI
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Guihakka2/envdiff@v1&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.env.example .env.ci&lt;/span&gt;
    &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;--keys-only --strict&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit code &lt;code&gt;0&lt;/code&gt; in sync, &lt;code&gt;1&lt;/code&gt; differences, &lt;code&gt;2&lt;/code&gt; usage error. On a big existing project, &lt;code&gt;--baseline&lt;/code&gt; records today's problems so only &lt;strong&gt;new&lt;/strong&gt; ones fail. Leaked secrets are never baselined.&lt;/p&gt;

&lt;h2&gt;
  
  
  For AI coding agents
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;envdiff --mcp&lt;/code&gt; runs it as an MCP server, so Claude Code, Codex, Cursor and friends can check your env files themselves before a deploy. They get key names and line numbers, never values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add envdiff -- npx -y @guihakka2/envdiff --mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why not an existing tool?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/dotenv-linter/dotenv-linter" rel="noopener noreferrer"&gt;dotenv-linter&lt;/a&gt; and &lt;a href="https://github.com/Chrilleweb/dotenv-diff" rel="noopener noreferrer"&gt;dotenv-diff&lt;/a&gt; are good. envdiff focuses on two things: comparing several env files where &lt;strong&gt;no value can ever reach the output&lt;/strong&gt;, and catching real secrets committed to template files.&lt;/p&gt;

&lt;p&gt;Standalone binaries for Windows, macOS and Linux are on the releases page if you don't have Node.js.&lt;/p&gt;

&lt;p&gt;Issues and feedback are very welcome. What's the worst &lt;code&gt;.env&lt;/code&gt; mistake you've shipped?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written with AI assistance and reviewed by the author.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dotenv</category>
      <category>security</category>
      <category>node</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
