@frxncisxo/envoy
v0.1.0
Published
Auto-generate Zod schemas, TypeScript types and .env.example from your .env files
Downloads
66
Maintainers
Readme
envoy ⚡
Auto-generate Zod schemas, TypeScript types, and .env.example from your
.envfile.
Stop writing validation boilerplate by hand. envoy reads your .env, infers the type and purpose of every variable, and generates everything you need in one command.
npx envoy generate --allThe problem
Every JS project needs:
- A
.env.examplefor onboarding teammates - Runtime validation so bad env crashes early
- TypeScript types for autocomplete
Most devs either skip these, or write them by hand — and they go stale instantly.
envoy does all three, automatically.
Install
npm install -g @envoy-cli/envoy
# or use without installing
npx envoy <command>Commands
envoy generate — Generate files from your .env
envoy generate # Generates Zod schema (default)
envoy generate --all # Generates everything
envoy generate --types # TypeScript types only
envoy generate --example # .env.example only
envoy generate -i .env.prod -o ./config # Custom input/outputOutput: env.schema.ts
import { z } from 'zod'
export const envSchema = z.object({
/** Runtime environment */
NODE_ENV: z.enum(['development', 'staging', 'production', 'test']),
/** Port number (1-65535) */
PORT: z.coerce.number().int().min(1).max(65535),
/** ⚠️ Secret — never commit the real value */
JWT_SECRET: z.string().min(1),
/** Boolean flag (true/false) */
DEBUG: z.enum(['true', 'false']).transform(v => v === 'true'),
})
export type Env = z.infer<typeof envSchema>
// Usage:
// export const env = envSchema.parse(process.env)Output: .env.example
# Runtime environment
NODE_ENV=development
# Port number (1-65535)
PORT=3000
# ⚠️ Secret — never commit the real value
JWT_SECRET=envoy inspect — See what envoy infers about your variables
envoy inspect
envoy inspect -i .env.stagingNODE_ENV enum Runtime environment
PORT port Port number (1-65535)
DATABASE_URL url A valid URL
JWT_SECRET secret [secret] ⚠️ Never commit
DEBUG boolean Boolean flagenvoy check — Validate that your .env has all required variables
envoy check
# ✅ All 12 variables are present in .env
envoy check
# ❌ Missing 2 variable(s) in .env:
# • STRIPE_SECRET_KEY
# • SENDGRID_API_KEYGreat for CI pipelines.
Inference rules
envoy detects types using key name patterns and value heuristics:
| Pattern | Inferred type | Zod |
|---|---|---|
| *_URL, *_ENDPOINT | url | z.string().url() |
| PORT | port | z.coerce.number().int().min(1).max(65535) |
| *_SECRET, *_KEY, *_TOKEN | secret | z.string().min(1) |
| DEBUG, IS_*, ENABLED | boolean | z.enum(['true','false']).transform(...) |
| NODE_ENV, APP_ENV | enum | z.enum(['development','staging','production','test']) |
| *_TIMEOUT, *_LIMIT, PORT | number | z.coerce.number() |
| Value starts with https:// | url | z.string().url() |
| Value is true/false | boolean | — |
| Value is digits only | number | — |
Roadmap
- [ ]
--watchmode to regenerate on.envchanges - [ ] AI-powered inference for ambiguous variables (via
OPENAI_API_KEYorANTHROPIC_API_KEY) - [ ] VSCode extension
- [ ] Support for multiple
.env.*files
License
MIT
