Skip to content

CLI Guide

Abhijeet Kumar edited this page Nov 20, 2026 · 1 revision

CLI Guide

Installing env-saaf gives you the env-saaf command.

env-saaf init

Creates a starter env.schema.js (with commented examples of the main types) and a matching .env.example. It refuses to overwrite existing files unless you pass --force. Use --schema <name> for a different schema file name.

env-saaf check

Compares the variables your code actually uses against .env.example (and your real .env when one exists). It reports missing, extra and unused keys. Any finding exits with code 1, so it can fail a CI job.

Add --schema <file> to also validate the real .env values against your schema.

env-saaf scan

Scans a directory of source code for process.env usage and prints what it finds. When nothing is found, it says so on stderr instead of printing nothing.

env-saaf example

Generates a .env.example from your code scan or from a schema. With --write it writes the file — and if there is nothing to write, it warns and writes no file.

Flags

Flag Meaning
--json Machine-readable output
--no-color Disable coloured output
--help Help for the command (also works after a subcommand)
--version Print the installed version

In GitHub Actions

- run: npm ci
- run: npx env-saaf check

A non-zero exit code fails the job, so a drifting .env.example is caught in review instead of in production.

Clone this wiki locally