zorath-env 0.1.0

A tiny CLI to validate .env using a schema, generate docs, and keep config sane.
zorath-env-0.1.0 is not a library.
Visit the last successful build: zorath-env-0.3.9

zorath-env

Built by Zorath -- infrastructure for builders.

A tiny, fast CLI that makes .env sane.

zenv validates environment variables from a schema, generates docs, and helps keep config consistent across dev/staging/prod.

Why

.env files drift. Teams copy/paste secrets. CI fails late. Docs go stale.

zenv makes your schema the source of truth.

Schema is the source of truth. Docs and examples should be generated from it.

Install

Via cargo (recommended)

cargo install zorath-env

From source

cargo install --path .

Run locally

cargo run -- check

Quick start

  1. Create a schema:
zenv init
  1. Validate your .env:
zenv check
  1. Generate docs:
zenv docs > ENVIRONMENT.md

Commands

zenv check

Validates .env against env.schema.json.

  • exits 0 if valid
  • exits 1 if invalid (CI-friendly)

zenv docs

Prints Markdown documentation for all env vars in the schema.

zenv init

Creates env.schema.json from .env.example (best-effort inference, you refine types after).

Files

By default, zenv looks for:

  • .env (optional)
  • .env.example (optional)
  • env.schema.json (preferred)

You can override paths:

zenv check --env .env --schema env.schema.json
zenv docs  --schema env.schema.json
zenv init  --example .env.example --schema env.schema.json

Schema format (v0.1)

env.schema.json is a JSON object where each key is an env var name.

Example:

{
  "DATABASE_URL": {
    "type": "url",
    "required": true,
    "description": "Primary database connection string"
  },
  "NODE_ENV": {
    "type": "enum",
    "values": ["development", "staging", "production"],
    "default": "development",
    "required": true,
    "description": "Runtime environment"
  },
  "PORT": {
    "type": "int",
    "default": 3000,
    "required": false,
    "description": "HTTP port"
  }
}

Supported types:

  • string
  • int
  • float
  • bool
  • url
  • enum

Example output

Success

$ zenv check
zenv: OK

Validation errors

$ zenv check
zenv check failed:

- DATABASE_URL: expected url, got 'not-a-url'
- NODE_ENV: expected one of ["development", "staging", "production"], got 'dev'
- API_KEY: missing (required)

Pre-commit hook

# .git/hooks/pre-commit (make executable)
#!/usr/bin/env bash
set -e

if [ -f "env.schema.json" ]; then
  if command -v zenv >/dev/null 2>&1; then
    zenv check || exit 1
  else
    cargo run --quiet -- check || exit 1
  fi
fi

License

MIT