CLI Reference¶
envdrift provides a command-line interface for validating environment files against Pydantic schemas, comparing environments, managing encryption, and scanning for exposed secrets.
Installation¶
Commands¶
| Command | Description |
|---|---|
| validate | Validate .env files against Pydantic schemas |
| diff | Compare two .env files and show differences |
| encrypt | Check or perform encryption using dotenvx or SOPS |
| decrypt | Decrypt encrypted .env files (dotenvx or SOPS) |
| push | Encrypt and combine files (partial encryption) |
| pull-partial | Decrypt secret files for editing (partial encryption) |
| guard | Scan for unencrypted .env files and exposed secrets |
| pull | Pull keys from vault and decrypt all env files |
| sync | Sync encryption keys from cloud vaults to local files |
| vault-push | Push encryption keys from local files to cloud vaults |
| init | Generate Pydantic Settings from .env files |
| hook | Manage pre-commit hook integration |
| version | Show envdrift version |
Global Options¶
All commands support these options:
--help Show help message and exit
--install-completion Install shell completion
--show-completion Show completion script
Quick Examples¶
# Validate production env against schema
envdrift validate .env.production --schema config.settings:ProductionSettings
# Compare dev vs prod environments
envdrift diff .env.development .env.production
# Check if secrets are encrypted
envdrift encrypt .env.production --check
# Guard against plaintext secrets
envdrift guard --ci --fail-on high
# Generate schema from existing .env
envdrift init .env --output settings.py
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Validation failed, file not found, or other error |
Environment Variables¶
| Variable | Description |
|---|---|
ENVDRIFT_SCHEMA_EXTRACTION |
Set by envdrift during schema loading. Check this in your settings module to skip instantiation during validation. |
Schema Path Format¶
The --schema option uses Python's dotted import path format:
Examples:
config.settings:Settingsmyapp.config:ProductionSettingssrc.config.settings:AppConfig