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

Running CLI Commands

You can run CLI commands using npx (Node.js) or bunx (Bun):

npx dotenv-gad <command>
# or
bunx dotenv-gad <command>

Examples

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

npx dotenv-gad check --strict
# or
bunx 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
# or use bunx dotenv-gad check --strict with Bun

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

npx dotenv-gad sync --output .env.example
# or
bunx dotenv-gad sync --output .env.example