Interactive .env generator from example template files with comment guidance, type inference, shell inheritance, and merge safety.
- Scans workspace breadth-first for
.env.example,.env.sample, or similar templates. - Respects
.gitignoreand ignores standard build directories. - Prompts variable-by-variable with section grouping based on comment headers.
- Auto-detects booleans, dropdown options, and password fields.
- Auto-inherits matching environment variables from active shell session.
- Pre-fills values from existing
.envfiles while preserving local custom variables. - Generates layout-preserved
.envwith exact comments, spacing, and quotes. - Non-interactive mode for CI/CD pipelines.
go install github.com/kryft-dev/exenv@latestDownload pre-compiled binaries for Linux, macOS, and Windows from GitHub Releases.
Install the official exenv skill for AI coding agents:
npx skills@latest add kryft-dev/exenvRun in any directory containing a .env.example:
exenvIf multiple template candidates exist in subdirectories, an interactive selector will prompt you to pick one.
# Positional arguments
exenv .env.example .env.local
# Explicit flags
exenv --source config/.env.template --out config/.env# Accept all defaults, fail if required variables lack defaults
exenv --defaults
# Dry run to stdout
exenv --defaults --dry-run| Flag | Short | Description | Default |
|---|---|---|---|
--source |
-s |
Path to source template file | Auto-discovered |
--out |
-o |
Path to target output file | .env |
--defaults |
-d |
Non-interactive mode using default values | false |
--force |
-f |
Overwrite existing .env without pre-filling |
false |
--yes |
-y |
Skip review summary confirmation prompt | false |
--dry-run |
Output generated file to stdout | false |
|
--no-env |
Do not inherit shell environment variables | false |
|
--no-ignore |
Do not respect .gitignore when searching |
false |
|
--no-backup |
Do not create .env.bak on overwrite |
false |
|
--show-secrets |
Display secret values in plain text | false |
|
--max-depth |
Maximum directory search depth | 5 |
|
--version |
-v |
Display version information |
exenv parses annotations in comments directly above variables:
# Application environment
# @options dev,staging,prod
# @required
APP_ENV=dev
# Stripe secret key
# @secret
STRIPE_API_KEY=
# Enable experimental features
# @bool
ENABLE_BETA=false@secret: Masks input with password field.@public: Disables secret auto-masking on sensitive key names.@required: Enforces non-empty values before allowing progression.@options val1,val2,val3: Renders an interactive select dropdown.@boolor@type bool: Renders a boolean toggle (true/false).
MIT License. See LICENSE for details.