Skip to content

Repository files navigation

exenv

Interactive .env generator from example template files with comment guidance, type inference, shell inheritance, and merge safety.

Features

  • Scans workspace breadth-first for .env.example, .env.sample, or similar templates.
  • Respects .gitignore and 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 .env files while preserving local custom variables.
  • Generates layout-preserved .env with exact comments, spacing, and quotes.
  • Non-interactive mode for CI/CD pipelines.

Installation

Via Go

go install github.com/kryft-dev/exenv@latest

Pre-built Binaries

Download pre-compiled binaries for Linux, macOS, and Windows from GitHub Releases.

Agent Skill

Install the official exenv skill for AI coding agents:

npx skills@latest add kryft-dev/exenv

Usage

Interactive Mode

Run in any directory containing a .env.example:

exenv

If multiple template candidates exist in subdirectories, an interactive selector will prompt you to pick one.

Specify Source and Output Files

# Positional arguments
exenv .env.example .env.local

# Explicit flags
exenv --source config/.env.template --out config/.env

Non-Interactive (CI/CD)

# Accept all defaults, fail if required variables lack defaults
exenv --defaults

# Dry run to stdout
exenv --defaults --dry-run

CLI Flags

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

Template Annotations

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.
  • @bool or @type bool: Renders a boolean toggle (true/false).

License

MIT License. See LICENSE for details.

About

Interactive .env generator from example templates with comment guidance, merge safety, and type inference

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages