env-ai-gen
v1.0.0
Published
CLI tool that scans project source code and generates .env.example with detected environment variables
Maintainers
Readme
env-ai-gen
CLI tool that scans your project's source code and generates a .env.example file with all detected environment variables, descriptions, and sensible defaults.
Supported Languages
- Node.js —
process.env.VAR_NAME - Python —
os.environ["VAR"],os.environ.get("VAR"),os.getenv("VAR") - Rust —
env::var("VAR") - Go —
os.Getenv("VAR") - Ruby —
ENV["VAR"],ENV.fetch("VAR")
Install
npm install -g env-ai-genUsage
# Scan current directory
env-ai-gen
# Scan a specific directory
env-ai-gen ./my-project
# Output as JSON
env-ai-gen --format json --output env.json
# Sort alphabetically and merge with existing file
env-ai-gen --sort --merge
# Custom output path
env-ai-gen -o .env.templateOptions
| Flag | Description | Default |
|------|-------------|---------|
| [dir] | Directory to scan | . |
| -o, --output <path> | Output file path | .env.example |
| -f, --format <fmt> | Format: dotenv, json, yaml | dotenv |
| --merge | Merge with existing file | false |
| --sort | Sort variables alphabetically | false |
Features
- Auto-categorizes variables (Database, Auth, Server, External APIs, Email, Storage, Cache)
- Adds descriptions based on common naming patterns
- Sets sensible defaults (e.g.,
PORT=3000,NODE_ENV=development) - Marks sensitive variables (secrets, passwords, API keys) with empty values
- Tracks source files for each variable
- Skips
node_modules,.git,dist,build,__pycache__,target,vendor
License
MIT
