This is a follow-up to my previous article: I built a CLI tool that auto-detects missing environment variables — no schema needed
Quick update on dotenv-audit — the CLI tool that scans your code and finds missing environment variables.
What's new in v1.1.0
1. sync command — keep .env.example in sync with your code
The most common problem with .env.example files? They go outdated. Someone adds a new process.env.STRIPE_KEY in code but forgets to update .env.example. New developers clone the repo, miss the variable, and waste time debugging.
Now just run:
npx dotenv-audit sync
It will:
Scan your code for every process.env usage
Compare with your existing .env.example
Add missing variables with smart placeholder values
Warn about unused variables that should be removed
# .env.example
PORT=3000
DATABASE_URL=
JWT_SECRET=
OLD_UNUSED_VAR=something
After running npx dotenv-audit sync:
dotenv-audit sync
Scanned 12 files
+ 2 variable(s) missing from .env.example:
+ API_KEY app.js:3
+ STRIPE_KEY payments.ts:22
- 1 variable(s) in .env.example but not used in code:
- OLD_UNUSED_VAR
✓ Added 2 variable(s) to .env.example
! 1 unused variable(s) found — review and remove manually
Your .env.example now has:
PORT=3000
DATABASE_URL=
JWT_SECRET=
OLD_UNUSED_VAR=something
# ── Added by dotenv-audit sync ──────────────
# Other
API_KEY=your_api_key_here
# Stripe
STRIPE_KEY=sk_test_your_stripe_secret_key_here
- Local .env file reading (bug fix in v1.0.3) Previously the tool only checked process.env at runtime — so if you had variables in your .env file, they were still showing as "missing". Fixed. Now it reads .env and .env.local before validating.
All commands
npx dotenv-audit # Scan and show missing vars
npx dotenv-audit --ask # Interactive mode (generate .env + ENV_SETUP.md)
npx dotenv-audit sync # Sync .env.example with code
npx dotenv-audit audit # List all detected variables
npx dotenv-audit gen # Generate .env.example from scratch
npx dotenv-audit --json --ci # CI mode with JSON output
Try it
npx dotenv-audit sync
npm: https://www.npmjs.com/package/dotenv-audit
400+ downloads in the first 2 days. Would love your feedback — what would you want next?
Thanks for reading! If you missed the first article, check it out here: How I built dotenv-audit
If you find it useful, drop a ❤️ and share it with your team!
Top comments (0)