zorath-env
Open Sourcev0.3.8Package: zorath-env | Binary: zenv
Schema-based .env validation with secret detection
Catch configuration errors and leaked secrets before they reach production. 13 commands, 14 validation types. Language-agnostic, privacy-focused, zero dependencies.
cargo install zorath-envFeatures
Secret Detection
Scan .env files for accidentally committed secrets: AWS, Stripe, GitHub, GitLab, Slack, Google, Heroku, SendGrid, Twilio, Mailchimp, npm tokens, private keys, JWT, and more.
Env File Comparison
Compare two .env files to find differences between environments. Catch config drift between dev, staging, and production.
Type Validation
Support for 14 types: string, int, float, bool, url, enum, uuid, email, ipv4, ipv6, semver, port, date, hostname. Catch type mismatches before runtime.
Language Agnostic
Works with any tech stack - Node.js, Python, Go, Ruby, Rust, Java, PHP, and more. Your schema is the source of truth.
CI/CD Ready
Clear exit codes (0 for success, 1 for failure). Integrate into any CI/CD pipeline or pre-commit hook.
Privacy Focused
Runs entirely locally. No external requests, no data uploads, no telemetry. Your secrets stay on your machine.
Zero Dependencies
Single binary, no runtime requirements. Install once and run anywhere without dependency conflicts.
Auto Documentation
Generate markdown or JSON documentation from your schema. Keep your env docs always in sync.
Variable Interpolation
Reference other variables with ${VAR} syntax. Build complex configurations from simple building blocks.
Schema Inheritance
Extend base schemas for environment-specific configurations. DRY principle for your env schemas.
Smart Initialization
Initialize schemas from existing .env.example files with intelligent type inference.
GitHub Action
Official GitHub Action for CI/CD. Validates .env files in your pipeline with prebuilt binaries for fast execution.
Shell Completions
Generate shell completions for bash, zsh, fish, and PowerShell. Tab-complete commands and options.
Validation Rules
Add constraints with min/max for integers, min_value/max_value for floats, min_length/max_length and regex patterns for strings.
Remote Schemas
Fetch schemas from HTTPS URLs for shared team configurations. Automatic caching with 1-hour TTL, --no-cache flag to bypass. Security features: hash verification with --verify-hash, custom CA certificates with --ca-cert, and rate limiting (60s default).
Watch Mode
Continuous validation with --watch flag. Monitors .env and schema files for changes with delta detection and timestamped output.
Type-Aware Placeholders
Generate smart placeholder values based on key names. PORT becomes 3000, DATABASE_URL becomes postgres://..., API_KEY becomes your_api_key_here.
Duplicate Key Detection
Warns about duplicate keys in .env files with line numbers. Catches copy-paste errors before they cause issues.
YAML Schema Support
Define schemas in YAML format (.yaml/.yml) for better readability. JSON and YAML schemas are interchangeable.
Severity Levels
Mark variables with severity: warning to continue validation on failure. Warnings are reported but don't fail CI.
JSON Output
Get machine-readable JSON output with --format json for CI/CD integration and automated processing.
Multi-Format Export
Export .env files to 7 formats: shell scripts, Dockerfile ENV, Kubernetes ConfigMap, JSON, systemd, dotenv, and GitHub Secrets (gh CLI).
Health Diagnostics
Run zenv doctor for comprehensive health checks: installation, schemas, env files, cache status, and shell completions.
Auto-Fix
Automatically fix common issues with zenv fix: sort variables, add missing with defaults, remove unknown keys. Creates backups.
Code Scanning
Scan source code for environment variable usage with zenv scan. Supports 9 languages and finds unused/missing variables.
Cache Management
Manage remote schema cache with zenv cache: view path, list cached schemas, clear specific URLs or all cache.
CI/CD Templates
Generate ready-to-use CI/CD configurations with zenv template. Supports GitHub Actions, GitLab CI, and CircleCI.
How It Works
Define Your Schema
Create an env.schema.json file that describes your environment variables.
{
"DATABASE_URL": {
"type": "url",
"required": true,
"description": "PostgreSQL connection string"
},
"PORT": {
"type": "int",
"required": false,
"default": 3000,
"description": "Server port"
},
"DEBUG": {
"type": "bool",
"required": false,
"default": false
}
}Create Your .env File
Add your environment variables as usual.
DATABASE_URL=postgresql://localhost:5432/mydb
PORT=8080
DEBUG=trueValidate
Run zenv to validate your .env against the schema.
$ zenv check
zenv: OKQuick Reference
Commands
zenv checkValidates your .env file against the schema. Optionally scan for leaked secrets. Returns exit code 0 on success, 1 on failure.
zenv diffCompare two .env files and show differences. Find variables only in one file, or with different values.
zenv initGenerates a schema file from an existing .env.example file with intelligent type inference and smart description generation based on key names.
zenv docsGenerates documentation from your schema. Outputs to stdout.
zenv exampleGenerate .env.example from schema (reverse of init).
zenv versionDisplays the current version of zenv with optional update check and changelog links.
zenv completionsGenerate shell completions for bash, zsh, fish, or PowerShell.
zenv exportExport .env files to various deployment formats. Supports 7 output formats for different platforms.
zenv doctorRun comprehensive health diagnostics. Checks installation, schemas, env files, cache, and shell completions.
zenv fixAutomatically fix common .env issues. Creates a backup before making changes.
zenv scanScan source code for environment variable usage. Finds unused schema variables and undeclared env references.
zenv cacheManage the remote schema cache. View cache location, list entries, clear cached schemas, or view statistics.
zenv templateGenerate CI/CD configuration templates for environment validation. Supports GitHub Actions, GitLab CI, and CircleCI.
Supported Types
stringAny string valueintInteger numbersfloatFloating point numbersbooltrue, false, 1, 0, yes, nourlValid URL formatenumOne of specified valuesuuidUUID v4 formatemailValid email addressipv4IPv4 addressipv6IPv6 addresssemverSemantic versioningportValid port (1-65535)dateISO 8601 datehostnameValid hostnameReady to get started?
Install zorath-env and start validating your environment variables today.