<?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: Rahul Retnan</title>
    <description>The latest articles on DEV Community by Rahul Retnan (@rahulretnan).</description>
    <link>https://dev.to/rahulretnan</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%2F820093%2F727cbd31-b83f-42c4-bd51-1092d81b164d.jpeg</url>
      <title>DEV Community: Rahul Retnan</title>
      <link>https://dev.to/rahulretnan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahulretnan"/>
    <language>en</language>
    <item>
      <title>Built envx-cli Because Managing Envs Shouldn't Be This Hard 😤</title>
      <dc:creator>Rahul Retnan</dc:creator>
      <pubDate>Sun, 27 Jul 2025 14:14:22 +0000</pubDate>
      <link>https://dev.to/rahulretnan/weekend-project-built-envx-cli-because-managing-envs-shouldnt-be-this-hard-ih9</link>
      <guid>https://dev.to/rahulretnan/weekend-project-built-envx-cli-because-managing-envs-shouldnt-be-this-hard-ih9</guid>
      <description>&lt;p&gt;&lt;em&gt;TL;DR: Got frustrated with existing env tools, spent a weekend with Claude Sonnet 4, and built &lt;code&gt;envx-cli&lt;/code&gt;. Now managing environment variables across monorepos or any type of project repos is actually enjoyable.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Pain Was Real
&lt;/h2&gt;

&lt;p&gt;Managing environment variables has always been challenging. Like, seriously challenging. &lt;/p&gt;

&lt;p&gt;I started with the classic approach - GPG encryption with shell scripts and Makefiles. Works, but feels like I'm living in 2010. Then I heard about &lt;strong&gt;dotenvx&lt;/strong&gt; and thought "finally, someone gets it!"&lt;/p&gt;

&lt;p&gt;Dotenvx is "a better dotenv–from the creator of &lt;code&gt;dotenv&lt;/code&gt;" and honestly, it's amazing. Solves problems for most devs perfectly. But here's where my specific setup became a nightmare:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;: I work with Nx monorepos. Multiple services, different stages (dev/staging/prod), and dotenvx was overriding keys and creating a single &lt;code&gt;.env.keys&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;This meant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating per-service folders 📁&lt;/li&gt;
&lt;li&gt;Writing tons of custom scripts 📝
&lt;/li&gt;
&lt;li&gt;Fighting the tool instead of using it 😤&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't get me wrong - dotenvx is brilliant! It just wasn't designed for my specific monorepo + multi-service Docker setup.&lt;/p&gt;

&lt;p&gt;Then I looked at &lt;strong&gt;Infisical&lt;/strong&gt;. Another great solution, but felt like overkill for smaller projects. The self-hosting overhead wasn't worth it for most of my use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "Why Not?" Moment
&lt;/h2&gt;

&lt;p&gt;After another afternoon wrestling with environment configurations, I had that classic developer epiphany: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How hard could it be to build this myself?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The package name came instantly: "envx". Clean, purposeful, memorable. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;checks npm&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Already taken. Of course. 🤦‍♂️&lt;/p&gt;

&lt;p&gt;"envx-cli" it is!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Weekend Build Setup
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;IDE Choice&lt;/strong&gt;: Cursor felt like overkill, so I went with &lt;strong&gt;Zed + GitHub Copilot API&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Holy moly, what an awesome combination! Fast, responsive, just enough AI assistance without the heavyweight overhead. Sometimes you don't need the rocket launcher.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Prompt Strategy&lt;/strong&gt;: Instead of traditional planning, I invested time in crafting one detailed prompt with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All feature requirements&lt;/li&gt;
&lt;li&gt;How I wanted it to behave
&lt;/li&gt;
&lt;li&gt;Multi-service and monorepo support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.envrc&lt;/code&gt; compatibility (crucial!, Since Most of my project relies on it)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tech Stack&lt;/strong&gt; (mentioned these to the AI since I had experience):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;commander&lt;/code&gt; - CLI framework excellence&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;inquirer&lt;/code&gt; - Interactive prompts that don't suck&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;shelljs&lt;/code&gt; - Cross-platform shell operations&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zod&lt;/code&gt; - TypeScript validation that actually works&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Magic Happened
&lt;/h2&gt;

&lt;p&gt;After a few minutes (seriously!), it was there. The whole thing. Working.&lt;/p&gt;

&lt;p&gt;My first thought: "I should have done this sooner."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Development Process&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 1&lt;/strong&gt;: Core project with all features&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 2&lt;/strong&gt;: Bug fixes and comprehensive test suite&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt 3&lt;/strong&gt;: Additional features and polish&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it. Three prompts with Claude Sonnet 4 (both thinking + non-thinking models).&lt;/p&gt;

&lt;p&gt;Next steps: CI setup, GitHub push, NPM publish. Done.&lt;/p&gt;

&lt;h2&gt;
  
  
  What envx-cli Actually Does
&lt;/h2&gt;

&lt;p&gt;Let me show you why this tool is different:&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Innovation: GPG + .envrc Integration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Initialize in your Nx monorepo&lt;/span&gt;
envx init

&lt;span class="c"&gt;# Create environment files&lt;/span&gt;
envx create &lt;span class="nt"&gt;-e&lt;/span&gt; development
envx create &lt;span class="nt"&gt;-e&lt;/span&gt; production

&lt;span class="c"&gt;# Set up encryption secrets (integrates with .envrc)&lt;/span&gt;
envx interactive

&lt;span class="c"&gt;# Encrypt sensitive environments&lt;/span&gt;
envx encrypt &lt;span class="nt"&gt;-e&lt;/span&gt; production &lt;span class="nt"&gt;--overwrite&lt;/span&gt;

&lt;span class="c"&gt;# The magic: copy to .env for any service with the project&lt;/span&gt;
envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; production &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why This Matters for Nx Monorepos
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before envx-cli&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;&lt;span class="c"&gt;# Managing multiple services was painful&lt;/span&gt;
apps/
├── api/.env.dev, .env.prod.gpg, custom-scripts
├── web/.env.dev, .env.prod.gpg, more-scripts
└── worker/.env.dev, .env.prod.gpg, even-more-scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;With envx-cli&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;&lt;span class="c"&gt;# From project root, manage everything&lt;/span&gt;

&lt;span class="c"&gt;# Decrypts and copy the `.env.production` to `.env` with in each Service Folders&lt;/span&gt;
envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; production &lt;span class="nt"&gt;--all&lt;/span&gt;

&lt;span class="c"&gt;# Encrypts ALL environments&lt;/span&gt;
envx encrypt &lt;span class="nt"&gt;--all&lt;/span&gt;

&lt;span class="c"&gt;# Decrypts ALL when needed&lt;/span&gt;
envx decrypt &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One &lt;code&gt;.envrc&lt;/code&gt; file in the root manages all encryption secrets. No per-service complexity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Workflow
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Development&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;envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; development &lt;span class="nt"&gt;--all&lt;/span&gt;
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Staging Deployment&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;envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; staging &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--overwrite&lt;/span&gt;
docker-compose &lt;span class="nt"&gt;-f&lt;/span&gt; docker-compose.staging.yml up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Production&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;envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; production &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--overwrite&lt;/span&gt;
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The .envrc Prerequisite
&lt;/h3&gt;

&lt;p&gt;One key requirement: you need &lt;code&gt;.envrc&lt;/code&gt; integration. If you're using direnv (and you should be), envx-cli plays perfectly with your existing workflow.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.envrc&lt;/code&gt; file stores your encryption secrets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DEVELOPMENT_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-dev-secret"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;STAGING_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-staging-secret"&lt;/span&gt;  
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PRODUCTION_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-prod-secret"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security That Actually Works
&lt;/h2&gt;

&lt;p&gt;Unlike tools that reinvent encryption, envx-cli uses &lt;strong&gt;GPG&lt;/strong&gt; - the gold standard. Your secrets are as secure as your GPG setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best practices built-in&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Commit encrypted &lt;code&gt;.gpg&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;✅ Never commit &lt;code&gt;.envrc&lt;/code&gt; (contains secrets)&lt;/li&gt;
&lt;li&gt;✅ Strong encryption by default&lt;/li&gt;
&lt;li&gt;✅ Security status checking with &lt;code&gt;envx status&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Smart &lt;code&gt;.gitignore&lt;/code&gt; handling&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Environment files
.env.*
!.env.example
!*.gpg        # Encrypted files are safe to commit

# EnvX secrets  
.envrc        # Never commit secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The AI Development Experience
&lt;/h2&gt;

&lt;p&gt;The most surprising part? How well Claude understood my requirements. By providing clear, detailed specifications upfront, the generated code was production-ready.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My validation process&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual code review (always!)&lt;/li&gt;
&lt;li&gt;Added comprehensive test suite&lt;/li&gt;
&lt;li&gt;Real-world testing across multiple projects&lt;/li&gt;
&lt;li&gt;Security audit of GPG integration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key lesson&lt;/strong&gt;: AI is incredibly powerful, but you still need to validate everything. Don't just trust - verify.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters in 2025
&lt;/h2&gt;

&lt;p&gt;The barrier to creating custom developer tools has never been lower. When existing solutions don't fit your specific workflow, building your own is now a viable weekend project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The approach&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clear requirements upfront&lt;/strong&gt; (better prompts = better code)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose proven technologies&lt;/strong&gt; (boring tech works better with AI)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate everything&lt;/strong&gt; (AI is smart, not infallible)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solve your own problem first&lt;/strong&gt; (then share with community)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Get Started
&lt;/h2&gt;

&lt;p&gt;Ready to simplify your environment management?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install globally&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; envx-cli

&lt;span class="c"&gt;# Initialize in your project  &lt;/span&gt;
envx init

&lt;span class="c"&gt;# Create and encrypt environments&lt;/span&gt;
envx create &lt;span class="nt"&gt;-e&lt;/span&gt; production
envx interactive  &lt;span class="c"&gt;# Set up secrets&lt;/span&gt;
envx encrypt &lt;span class="nt"&gt;-e&lt;/span&gt; production

&lt;span class="c"&gt;# Use in development&lt;/span&gt;
envx copy &lt;span class="nt"&gt;-e&lt;/span&gt; development
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📦 &lt;a href="https://www.npmjs.com/package/envx-cli" rel="noopener noreferrer"&gt;NPM Package&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;a href="https://github.com/rahulretnan/envx-cli" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📚 Full documentation in the &lt;a href="https://github.com/rahulretnan/envx-cli/blob/main/README.md" rel="noopener noreferrer"&gt;README.md&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Real Message
&lt;/h2&gt;

&lt;p&gt;There are tons of AI tools out there. If you don't find the right tool or it's not meeting your specific requirements, &lt;strong&gt;go build it yourself&lt;/strong&gt;. Vibe code the whole thing!&lt;/p&gt;

&lt;p&gt;Just make sure the AI isn't doing any funny business. In my case, I reviewed every line and added separate test scripts to catch issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which model?&lt;/strong&gt; No secrets - Claude Sonnet 4 (both thinking + non-thinking). Three prompts total.&lt;/p&gt;

&lt;p&gt;The whole point: when existing tools don't fit your workflow, the solution might be a weekend away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Vibe Coding!&lt;/strong&gt; 🚀&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Working with Monorepos and environment management headaches? Give envx-cli a try and let me know how it works for your setup. Contributions welcome!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dotenv</category>
      <category>devtool</category>
      <category>node</category>
      <category>envx</category>
    </item>
  </channel>
</rss>
