/env
Set up, validate, and manage environment variables.
Usage
code
/env [action] [--check] [--generate] [--sync]
Arguments
- •
action:check,generate,sync,add,remove(default:check) - •
--check: Validate all required vars are set - •
--generate: Create.envfrom.env.example - •
--sync: Sync.env.examplewith actual usage in code
Instructions
When this skill is invoked:
Agent Behavior
Autonomy:
- •Complete environment setup end-to-end
- •Detect missing variables before runtime failures
- •Never expose secret values in output
Safety:
- •Never commit
.envfiles - •Never log or display secret values
- •Always use placeholder values in
.env.example
Actions
Check (/env check)
Validate environment is properly configured:
- •Read
.env.exampleto get required variables - •Check
.envexists — if not, offer to generate - •Verify each variable is set:
bash
# Check for missing vars diff <(grep -oP '^[A-Z_]+' .env.example | sort) <(grep -oP '^[A-Z_]+' .env | sort)
- •Validate formats where possible:
- •URLs: valid format, reachable
- •Ports: numeric, valid range
- •API keys: correct prefix/length patterns
- •Report results
Generate (/env generate)
Create .env from template:
- •Copy
.env.exampleto.env:bashcp .env.example .env
- •Prompt for values that need customization
- •Verify
.envis in.gitignore:bashgrep -q "^\.env$" .gitignore || echo ".env" >> .gitignore
Sync (/env sync)
Ensure .env.example matches actual usage:
- •Scan codebase for environment variable references:
bash
# Find all env var usage patterns grep -rn "process\.env\.\|os\.environ\|os\.getenv\|env\(" src/ --include="*.{ts,tsx,py,go}" - •Compare against
.env.example - •Report discrepancies:
- •Variables used in code but missing from
.env.example - •Variables in
.env.examplebut unused in code
- •Variables used in code but missing from
- •Update
.env.examplewith missing entries (placeholder values only)
Add (/env add <VAR_NAME>)
Add a new environment variable:
- •Add to
.env.examplewith placeholder and comment - •Add to
.env(prompt for actual value) - •Add validation in config module if one exists
- •Update
prd/00_technology.mdenvironment variables table
Remove (/env remove <VAR_NAME>)
Remove an environment variable:
- •Check for usage in codebase
- •Warn if still referenced
- •Remove from
.env.example - •Remove from config validation if applicable
Environment Report Format
markdown
## Environment Check Report **Status:** PASS / FAIL **File:** .env (exists / missing) **Gitignored:** Yes / No ### Variables | Variable | Status | Format | |----------|--------|--------| | DATABASE_URL | Set | Valid URL | | API_KEY | Set | Valid prefix | | LOG_LEVEL | Missing | — | | PORT | Set | Valid (3000) | ### Issues - LOG_LEVEL: Not set (default: INFO) - SECRET_KEY: In .env.example but not used in code ### Recommendations 1. Set LOG_LEVEL in .env 2. Remove unused SECRET_KEY from .env.example
Example Output
code
$ /env check Checking environment configuration... .env file: Found .gitignore: .env is excluded Variable Check: DATABASE_URL ......... Set (valid PostgreSQL URL) LOG_LEVEL ............ Set (INFO) ENVIRONMENT .......... Set (development) API_KEY .............. MISSING JWT_SECRET ........... Set (32 chars) Issues Found: API_KEY is required but not set in .env Copy from your provider dashboard and add to .env Status: 1 issue found — fix before running the app.