CLI Usage
The CLI exposes convenient commands for working with your schema and environment files.
CLI Commands
| Command | Description |
|---|---|
check | Validate .env against schema |
sync | Generate/update .env.example |
types | Generate env.d.ts TypeScript types |
init | Create starter schema |
fix | Fixes environment issues |
docs | Generates .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