Loading page content…
LAB 001 // Developer tools
A TypeScript and Node.js CLI that compares .env.example with .env, detects missing keys and malformed declarations, and reports results without exposing secret values.
How can a lightweight command-line tool catch missing environment configuration before an application runs, provide useful diagnostics and protect secret values?

Environment configuration is easy to overlook during development and project setup. A missing variable can cause an application to fail after it starts, leaving the developer to trace the problem manually.
I built EnvGuard to make that check explicit: compare the variables declared in .env.example with those available in .env, then explain what needs attention.
EnvGuard reads both files, parses their declarations and compares the configuration keys. It produces a readable terminal report showing present and missing keys, alongside diagnostics for malformed declarations.
The tool supports standard KEY=value declarations and supported export KEY=value declarations. Its parsing handles quoted content, Windows-style line endings, Unicode and other tested edge cases.
I built the CLI with TypeScript and Node.js and used tsup to produce the distributable package.
The implementation separates command handling, parsing, validation and terminal reporting. This keeps the comparison logic independent of its presentation and makes individual behaviours easier to test.
The CLI provides a check command, help and version options, colour-coded output and formatting that adapts to terminal width.
The report displays variable names and validation statuses rather than environment-variable values. Sensitive declaration values are also masked in diagnostics.
This allows developers to identify configuration problems without unnecessarily exposing secrets in terminal output or CI logs.
The verified release includes 35 automated tests covering parser behaviour, validation and CLI execution, including integration tests against the compiled binary.
GitHub Actions builds the CLI before running integration tests and checks compatibility across Node.js 20, 22 and 24.
The CLI returns exit code 0 for successful validation and informational commands, and 1 for validation failures or command errors, allowing it to be used in automated workflows.
I published EnvGuard as @itseghosime/envguard on npm. It can be installed through npm or run through npx and requires Node.js 20 or newer.
The release workflow includes versioned Git tags, a changelog and GitHub releases.
Version 0.1.1 validates whether required keys are present. It does not determine whether their values are non-empty, correctly typed or suitable for the application.
EnvGuard provides an early configuration check; application-specific validation remains a separate responsibility.
Separating parsing, validation and reporting made the CLI easier to test and allowed each module to focus on a specific responsibility.
Quoted content, exported declarations, line endings and malformed input required explicit handling and tests.
Reporting variable names and statuses, while masking values in diagnostics, provides actionable feedback without exposing configuration secrets.
Compiled-CLI integration tests check the command users actually run, extending coverage beyond individual functions.
Key presence does not prove that a value is valid. Documenting that boundary makes the tool’s results easier to interpret correctly.