<?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>Forem: Akshay Kumar Das</title>
    <description>The latest articles on Forem by Akshay Kumar Das (@akshaykrdas001).</description>
    <link>https://forem.com/akshaykrdas001</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3657404%2F59ec128e-1d0d-45db-9ad1-5902870528ce.png</url>
      <title>Forem: Akshay Kumar Das</title>
      <link>https://forem.com/akshaykrdas001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/akshaykrdas001"/>
    <language>en</language>
    <item>
      <title>I built a CLI to prevent .env bugs — here’s why</title>
      <dc:creator>Akshay Kumar Das</dc:creator>
      <pubDate>Thu, 11 Dec 2025 13:04:49 +0000</pubDate>
      <link>https://forem.com/akshaykrdas001/i-built-a-cli-to-prevent-env-bugs-heres-why-2h14</link>
      <guid>https://forem.com/akshaykrdas001/i-built-a-cli-to-prevent-env-bugs-heres-why-2h14</guid>
      <description>&lt;p&gt;If you’ve ever shipped a feature, deployed confidently… and then watched the app crash instantly because of a missing or wrong environment variable — this is for you.&lt;/p&gt;

&lt;p&gt;Almost every developer has fought .env issues. They’re silent, annoying, and often only show up after you deploy.&lt;/p&gt;

&lt;p&gt;That’s exactly why I built envspec — a schema-driven CLI that validates, generates, and protects environment variables before they break your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The problem: .env bugs are invisible until too late&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Environment variables seem simple, but they cause real-world failures every day:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A missing DATABASE_URL takes down production&lt;/li&gt;
&lt;li&gt;Someone mistypes PORT=abc → app boots but behaves weird&lt;/li&gt;
&lt;li&gt;A teammate forgets to add a new variable to their .env&lt;/li&gt;
&lt;li&gt;Staging works, production crashes&lt;/li&gt;
&lt;li&gt;.env accidentally gets committed&lt;/li&gt;
&lt;li&gt;New developers ask: “Which variables do I need?”
There is no structure, no validation, and no safety net.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A real failure scenario (we’ve all seen something like this)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A teammate adds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ENABLE_CACHE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="nx"&gt;CACHE_TTL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;900&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But your local .env looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ENABLE_CACHE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;CACHE_TTL&lt;/code&gt;.&lt;br&gt;
Your app deploys fine… until the code tries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cacheFn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CACHE_TTL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Number(undefined)&lt;/code&gt; → &lt;code&gt;NaN&lt;/code&gt;&lt;br&gt;
Now your caching layer behaves unpredictably.&lt;/p&gt;

&lt;p&gt;Production bug. Hard to trace. Caused by missing .env values. This shouldn’t happen in 2025.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;The insight: .env needs a schema, just like your API does&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We validate API bodies, DB schemas, and types —&lt;br&gt;
but &lt;code&gt;.env&lt;/code&gt; is still the wild west.&lt;/p&gt;

&lt;p&gt;So I built:&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;envspec&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A CLI that turns your .env into a typed, validated, documented source of truth.&lt;/p&gt;

&lt;p&gt;👉 npm: &lt;a href="https://www.npmjs.com/package/@devakio/envspec" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@devakio/envspec&lt;/a&gt;&lt;br&gt;
👉 GitHub: &lt;a href="https://github.com/akshayxemo/envspec" rel="noopener noreferrer"&gt;https://github.com/akshayxemo/envspec&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How envspec solves the problem&lt;/strong&gt;&lt;br&gt;
✔ 1. Validate your &lt;code&gt;.env&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envspec validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Catches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing variables&lt;/li&gt;
&lt;li&gt;Wrong types&lt;/li&gt;
&lt;li&gt;Wrong enum values&lt;/li&gt;
&lt;li&gt;Unknown vars&lt;/li&gt;
&lt;li&gt;Broken JSON (for arrays/objects)
Before your app even runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✔ 2. Generate .env files safely&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envspec create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Placeholders&lt;/li&gt;
&lt;li&gt;Example values&lt;/li&gt;
&lt;li&gt;Backup creation&lt;/li&gt;
&lt;li&gt;Merging existing values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes onboarding new developers instant.&lt;/p&gt;

&lt;p&gt;✔ 3. Infer schema from existing .env&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envspec init &lt;span class="nt"&gt;--from-env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It scans your .env and creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$schemaVersion&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;desc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your_port&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔ 4. Protect env files from accidental commits&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envspec git-protect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Automatically adds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;.env
.env.local
.env.&lt;span class="k"&gt;*&lt;/span&gt;.backup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this matters for teams&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Onboarding becomes 30 seconds, not 30 minutes&lt;/li&gt;
&lt;li&gt;CI pipelines can fail fast&lt;/li&gt;
&lt;li&gt;Production incidents drop dramatically&lt;/li&gt;
&lt;li&gt;Schemas document your env configuration clearly&lt;/li&gt;
&lt;li&gt;Secrets remain local — no cloud dependencies
envspec is deliberately &lt;strong&gt;simple&lt;/strong&gt;.
It doesn’t replace dotenv, vaults, or secrets managers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It just prevents &lt;code&gt;.env&lt;/code&gt; mistakes — everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Start&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @devakio/envspec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;envspec init
envspec create
envspec validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Done.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I built it&lt;/strong&gt;&lt;br&gt;
I got tired of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;silent failures&lt;/li&gt;
&lt;li&gt;inconsistent .env files&lt;/li&gt;
&lt;li&gt;guessing environment variables&lt;/li&gt;
&lt;li&gt;onboarding pains&lt;/li&gt;
&lt;li&gt;production crashes caused by trivial env typos
envspec is my attempt to bring clarity, types, and safety to one of the most overlooked parts of modern development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Want to try it?&lt;/strong&gt;&lt;br&gt;
👉 Install&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @devakio/envspec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 GitHub Repo&lt;br&gt;
&lt;a href="https://github.com/akshayxemo/envspec" rel="noopener noreferrer"&gt;https://github.com/akshayxemo/envspec&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 npm Package&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@devakio/envspec" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@devakio/envspec&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you like this project, leaving a ⭐ on GitHub means a lot.&lt;br&gt;
And yes — TypeScript support, VSCode plugin, and CI integrations are coming soon.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>devops</category>
      <category>tooling</category>
      <category>envspec</category>
    </item>
  </channel>
</rss>
