Skip to main content

CLI Usage

The CLI exposes convenient commands for working with your schema and environment files.

CLI Commands

CommandDescription
checkValidate .env against schema
syncGenerate/update .env.example
typesGenerate env.d.ts TypeScript types
initCreate starter schema
fixFixes environment issues
docsGenerates .env documentation

Examples

Validate a repo with CI-friendly output (use exit codes):

npx dotenv-gad check --strict

Add a CI step in GitHub Actions to prevent merging invalid env changes:

- name: Validate .env
run: npx dotenv-gad check --strict

Scaffold .env.example grouped sections (uses envPrefix when present):

npx dotenv-gad sync --output .env.example