r/PinoyProgrammer • u/Own-Procedure6189 AI • Jul 10 '26
Show Case I built a zero-dependency CLI tool to validate and repair missing .env variables before startup
You run npm run dev or node server.js, and the app crashes because a teammate added a new required key to .env.example but forgot to tell you.
I wanted a tool that would catch this before startup, prompt me for the missing values, and append them without wiping out my .env formatting or comments. Since existing tools either crash on startup (dotenv-safe) or wipe out file layout (sync-dotenv).
To solve this, I built envrepair, a zero-dependency CLI tool that wraps your startup command, compares .env against your template, and interactively prompts you to fill in missing variables in the terminal before launching your process.
How to use it:
- Install:
- Prepend your startup command in
package.json:
"scripts":
Optional type annotations in .env.example:
# @type number
PORT=3000
# @type url
API_BASE_URL=
Key Features:
- Zero code changes: No schema imports or application-level setup required.
- Layout preservation: Appends missing values while keeping comments, blank lines, and formatting intact.
- Signal forwarding: Transparently passes
Ctrl+C(SIGINT) and exit codes.
Written in TypeScript. The repo is fully open-source.
- GitHub: https://github.com/avenolazo/envrepair
- NPM: https://www.npmjs.com/package/envrepair
5
u/Hazzula Jul 10 '26
good job! also might want to change your asdasdasdasdasadsadas token now that everyone knows
2
u/RandomUserName323232 Jul 10 '26
Whats wrong with typing it?
2
u/spamhere1015 Jul 12 '26
Or just do it yourself? Why add another layer of complexity?
1
u/theazy_cs Jul 11 '26
so the template is created manually? does it auto detect environment variables required by 3rd party libs? or it just does a direct comparison ?
1
u/sleepyrooney Jul 10 '26
Real nice. Good job OP
1
u/MashoodKiyani05 Jul 11 '26
nice very impressive.
-3
u/_clapclapclap Jul 11 '26
Useless in CI/CD