A powerful CLI tool that validates .env files against .env.example files, ensuring your environment configuration is complete and properly maintained.
β
Comprehensive Validation: Compare .env files against .env.example templates
π Multi-Environment Management: Manage multiple environments using .envguard/ directory
π Auto-Sync: Automatically saves .env changes to the active environment
π― Environment Switching: Quickly switch between development, staging, production, etc.
π Fast & Reliable: Built with Go for speed and reliability
π Detailed Reports: Clear summaries showing missing, extra, and valid variables
π§ Flexible Configuration: Custom file paths via command-line flags
npm install -g @crabest/envguardnpm install @crabest/envguardgit clone https://github.com/crabest/envguard
cd envguard
go mod tidy
go build -o envguardgo install# Validate default files (.env against .env.example)
./envguard
# Or if installed globally
envguard# Create a new environment
envguard create -e development
envguard create -e production --from-current
# List all environments
envguard list
# Use an environment (switch + tracking)
envguard use production
envguard use development
# Check current environment status
envguard status
# Delete an environment
envguard delete -e old-config
envguard delete -e test --no-confirm# Use custom file paths for validation
envguard --env .env.production --example .env.example
# Short flags
envguard -e .env.staging -x .env.templateenvguard --helpπ EnvGuard - Environment File Validator
π Validation Results:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Comparing: .env β .env.example
β
Variables found in both files (8):
β DATABASE_URL
β API_KEY
β PORT
β JWT_SECRET
β REDIS_URL
β LOG_LEVEL
β APP_NAME
β DEBUG
β οΈ Missing variables in .env (2):
β’ EMAIL_SERVICE_KEY
β’ WEBHOOK_SECRET
β Extra variables in .env not found in .env.example (1):
β’ DEPRECATED_CONFIG
π Summary:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your .env file has missing and extra variables.
π β
8 variables OK β’ β οΈ 2 missing β’ β 1 unused
EnvGuard supports managing multiple environment configurations using a hidden .envguard/ directory with automatic synchronization:
# 1. Create your first environment
envguard create -e development --from-current
# 2. Create additional environments
envguard create -e staging
envguard create -e production --from-current
# 3. List all environments
envguard list
# 4. Use environments - edit .env normally!
envguard use production
# Edit .env in your editor...
envguard use development # Previous changes auto-saved!
# 5. Check current environment status
envguard status
# 6. Validate current environment
envguard
# 7. Clean up unused environments
envguard delete -e old-staging.envguard/Directory: All environment files are stored in this hidden directory- Active Environment: The root
.envfile is always your active environment - Auto-Sync: Any changes to
.envare automatically saved to the active environment - Environment Usage:
envguard usecopies the selected environment to.env - Active Tracking:
envguard usetracks the current environment in.envguard/.active - Status Checking:
envguard statusshows which environment is currently active - Validation: Always validates the active
.envagainst.env.example - Isolation: Each environment is completely isolated and independent
| Command | Description | Auto-Sync | Use Case |
|---|---|---|---|
envguard use <env> |
Use environment + track | β Before switch | Normal workflow |
envguard status |
Show active environment | β | Check current state |
envguard list |
List all environments | β | See available options |
envguard |
Validate .env | β Before validation | Check environment |
go test ./...go build -o envguardgo fmt ./...- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run
go fmt ./...andgo vet ./... - Submit a pull request
MIT License - see LICENSE file for details