Complete reference for all envcheck command-line options and flags.
envcheck [path] [options]Directory or file to scan for environment variable usage.
- Type:
string - Default:
"."(current directory) - Examples:
envcheck # Scan current directory envcheck ./src # Scan src directory envcheck src/config.js # Scan specific file
Path to the .env.example file to validate against.
- Type:
string - Default:
".env.example" - Examples:
envcheck --env-file .env.production.example envcheck --env-file config/.env.template
Output format for results.
- Type:
string - Values:
text,json,github - Default:
"text" - Examples:
envcheck --format text # Human-readable output envcheck --format json # JSON output for scripts envcheck --format github # GitHub Actions annotations envcheck -f json # Short form
Format Details:
text: Human-readable colored output with tables and summariesjson: Structured JSON for programmatic consumptiongithub: GitHub Actions workflow commands (::error, ::warning)
Exit with code 1 if the specified condition is met. Useful for CI/CD pipelines.
- Type:
string - Values:
missing,unused,undocumented,all,none - Default:
"none" - Examples:
envcheck --fail-on missing # Fail if vars missing from .env.example envcheck --fail-on unused # Fail if unused vars in .env.example envcheck --fail-on undocumented # Fail if vars lack comments envcheck --fail-on all # Fail on any issue envcheck --fail-on none # Never fail (default)
Condition Details:
missing: Variables used in code but not in .env.exampleunused: Variables in .env.example but not used in codeundocumented: Variables without descriptive commentsall: Any of the above conditionsnone: Never exit with error code (always 0)
Glob pattern to exclude from scanning. Can be specified multiple times.
- Type:
string(repeatable) - Default:
[] - Examples:
envcheck --ignore "node_modules/**" envcheck --ignore "**/*.test.js" --ignore "dist/**" envcheck -i "vendor/**" -i "build/**"
Common Patterns:
--ignore "node_modules/**" # Exclude dependencies
--ignore "**/*.test.js" # Exclude test files
--ignore "**/*.spec.ts" # Exclude TypeScript tests
--ignore "dist/**" # Exclude build output
--ignore "coverage/**" # Exclude coverage reports
--ignore ".next/**" # Exclude Next.js buildLoad configuration from a specific file.
- Type:
string - Default: Auto-detect (
.envcheckrc,.envcheckrc.json, etc.) - Examples:
envcheck --config .envcheckrc.json envcheck --config config/envcheck.prod.json envcheck -c .envcheckrc.dev.json
Watch mode: automatically rerun validation when files change.
- Type:
boolean - Default:
false - Examples:
envcheck --watch envcheck -w envcheck ./src --watch --format json
Watch Mode Behavior:
- Monitors all files in the scan path
- Reruns validation on any file change
- Respects
--ignorepatterns - Press Ctrl+C to exit
Automatically add missing variables to .env.example with smart defaults.
- Type:
boolean - Default:
false - Examples:
envcheck --fix envcheck . --fix --quiet
Auto-fix Behavior:
- Adds missing variables to .env.example
- Generates smart default values based on variable names
- Preserves existing comments and formatting
- Creates backup before modifying
Smart Defaults:
API_KEY→your_api_key_hereDATABASE_URL→postgres://localhost:5432/dbnamePORT→3000NODE_ENV→developmentREDIS_URL→redis://localhost:6379
Disable colored output. Useful for logs and non-TTY environments.
- Type:
boolean - Default:
false - Examples:
envcheck --no-color envcheck . --no-color > output.txt
Disable intelligent suggestions (typo detection, example values).
- Type:
boolean - Default:
false - Examples:
envcheck --no-suggestions envcheck . --no-suggestions --format json
Disable progress indicators and spinners.
- Type:
boolean - Default:
false - Examples:
envcheck --no-progress envcheck . --no-progress --quiet
Suppress output when no issues are found. Only show output if problems exist.
- Type:
boolean - Default:
false - Examples:
envcheck --quiet envcheck -q envcheck . --quiet --fail-on missing
Start interactive REPL mode for exploring and fixing issues.
- Type:
boolean - Default:
false - Examples:
envcheck --repl envcheck -r
See REPL Guide for detailed REPL documentation.
Display version number and exit.
- Type:
boolean - Examples:
envcheck --version envcheck -v
Display help message and exit.
- Type:
boolean - Examples:
envcheck --help envcheck -h
envcheck uses standard exit codes:
0: Success (no issues found, or issues don't match--fail-oncondition)1: Validation failed (issues found matching--fail-oncondition)2: Error (invalid arguments, file not found, configuration error)
# Quick check during development
envcheck
# Watch mode for continuous feedback
envcheck --watch
# Auto-fix missing variables
envcheck --fix# Fail build if variables are missing
envcheck --fail-on missing --format github
# Strict mode: fail on any issue
envcheck --fail-on all --no-color --no-progress
# JSON output for further processing
envcheck --format json --fail-on missing > results.json# Use shared configuration
envcheck --config .envcheckrc.json
# Exclude test files and build artifacts
envcheck --ignore "**/*.test.js" --ignore "dist/**"
# Quiet mode for pre-commit hooks
envcheck --quiet --fail-on missingOptions can be combined for powerful workflows:
# Watch mode with JSON output
envcheck --watch --format json
# Strict CI check with GitHub annotations
envcheck --fail-on all --format github --no-color
# Auto-fix with quiet output
envcheck --fix --quiet
# Custom config with specific env file
envcheck --config .envcheckrc.prod.json --env-file .env.production.example
# Scan specific directory, ignore tests, fail on missing
envcheck ./src --ignore "**/*.test.js" --fail-on missingenvcheck respects these environment variables:
NO_COLOR: Disable colored output (same as--no-color)CI: Automatically disables progress indicators in CI environments
CLI arguments always override configuration file settings:
// .envcheckrc.json
{
"format": "text",
"failOn": "none"
}# This uses format: json and failOn: missing (CLI overrides config)
envcheck --format json --fail-on missing# Check what env vars are needed
envcheck --format text
# Auto-generate .env from .env.example
cp .env.example .env# Fail if missing variables
envcheck --quiet --fail-on missing# GitHub Actions
envcheck --format github --fail-on all
# GitLab CI
envcheck --format text --fail-on missing --no-color
# Jenkins
envcheck --format json --fail-on missing > results.json# Find unused variables to clean up
envcheck --format json | jq '.unused[]'
# Watch for issues while refactoring
envcheck --watch# Check each package
for dir in packages/*; do
echo "Checking $dir"
envcheck "$dir" --env-file "$dir/.env.example"
done- Configuration Guide - Detailed configuration options
- REPL Guide - Interactive mode documentation
- Examples - Real-world usage examples
- Integrations - CI/CD and tool integrations