| name | env-file-generator |
| description | Scan codebase for environment variable references and generate a complete .env.example file with safe placeholders. Use when the user asks to create or update .env.example or audit env var usage. |
Skill: Env File Generator
Scan source code for process.env.* references and produce a comprehensive .env.example with documentation and safe placeholder values.
Trigger
When the user asks to create .env.example, audit environment variables, or ensure all required env vars are documented.
Prerequisites
Steps
Step 1: Scan for Environment Variable References
Step 2: Catalog Variables
For each variable found:
Step 3: Classify Sensitivity
| Level | Examples | Placeholder Format |
|---|
| Secret | DB_PASSWORD, JWT_SECRET, API_KEY | your-secret-here |
| Infrastructure | DB_HOST, REDIS_URL, S3_BUCKET | localhost / descriptive example |
| Config | PORT, LOG_LEVEL, NODE_ENV | Actual default value |
| Feature | ENABLE_FEATURE_X, MAX_RETRIES | true / false / number |
Step 4: Generate .env.example
NODE_ENV=development
PORT=3000
LOG_LEVEL=info
DB_HOST=localhost
DB_PORT=5432
DB_NAME={{CONFIG.project.name}}
DB_USERNAME=your-db-username
DB_PASSWORD=your-db-password
JWT_SECRET=your-jwt-secret-min-32-chars
JWT_EXPIRY=15m
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
Step 5: Cross-Reference
Step 6: Generate Validation Code (Optional)
const required = ['DB_PASSWORD', 'JWT_SECRET'] as const;
for (const key of required) {
if (!process.env[key]) {
throw new Error(`Missing required environment variable: ${key}`);
}
}
Step 7: Output
Rules
- NEVER put real secret values in
.env.example
- ALWAYS use safe placeholder values (
your-xxx-here, localhost, defaults)
- ALWAYS include comments explaining each section
- ALWAYS verify
.env is in .gitignore
- Group variables by category with section headers
- Mark optional variables with comments (prefix with
#)
- Include type hints in comments where ambiguous
Completion
Complete .env.example with all environment variables, grouped by category, with safe placeholders and documentation.
If a Step Fails
- Too many vars (>50): Group by service/module, add a table of contents comment
- Dynamic env var names: Flag for manual review (e.g.,
process.env[varName])
- Can't determine required vs optional: Default to required, flag for user review
- Existing .env.example out of date: Show diff of changes (added/removed vars)