Environment Templates
Templates define the structure of your environment variables without actual values. They help with:
- Onboarding: New developers know exactly which variables they need
- Documentation: Variable requirements are self-documenting
- Validation: Ensure required variables are present before running
Template Formats
Simple Format (.env.template)
A basic format similar to .env files:
# Database
DATABASE_URL= # Required - PostgreSQL connection string
DATABASE_POOL_SIZE=10 # Optional - defaults to 10
# API Keys
STRIPE_SECRET_KEY= # Required
STRIPE_WEBHOOK_SECRET= # Required
# Feature Flags
ENABLE_ANALYTICS=true # Optional - defaults to true
YAML Format (.env.template.yaml)
A structured format with metadata:
name: my-app
description: Environment template for My App
variables:
- key: DATABASE_URL
description: PostgreSQL connection string
required: true
secret: true
- key: DATABASE_POOL_SIZE
default: "10"
description: Database connection pool size
- key: STRIPE_SECRET_KEY
required: true
secret: true
- key: LOG_LEVEL
default: "info"
description: Logging level (debug, info, warn, error)
Commands
init
Initialize a project with both configuration and template:
envmanager init --project <id>
This creates:
envmanager.json- Project configuration.env.template- Environment template
Options:
| Option | Description |
|---|---|
-p, --project <id> | Project ID |
-e, --environment <name> | Environment to base template on |
--format <type> | Template format: simple or yaml |
-f, --force | Overwrite existing files |
# Initialize with YAML template
envmanager init --project abc123 --format yaml
# Initialize from production environment
envmanager init --project abc123 --environment production
template generate
Generate a template from current EnvManager variables:
envmanager template generate [options]
Options:
| Option | Description |
|---|---|
-e, --environment <name> | Environment to generate from |
-o, --output <file> | Output file (default: .env.template) |
--format <type> | Format: simple or yaml |
-f, --force | Overwrite existing file |
# Generate template from development
envmanager template generate
# Generate YAML template from production
envmanager template generate --environment production --format yaml
template sync
Sync template with EnvManager (add missing variables):
envmanager template sync [options]
Options:
| Option | Description |
|---|---|
-i, --input <file> | Template file (default: .env.template) |
-e, --environment <name> | Target environment |
--dry-run | Show what would be synced |
# Preview sync
envmanager template sync --dry-run
# Sync to specific environment
envmanager template sync --environment staging
template validate
Validate that a .env file contains all required template variables:
envmanager template validate [options]
Options:
| Option | Description |
|---|---|
-t, --template <file> | Template file (default: .env.template) |
-i, --input <file> | Env file to validate (default: .env) |
# Validate .env against template
envmanager template validate
# Validate specific files
envmanager template validate --template .env.template.yaml --input .env.local
Output:
Validating .env against .env.template
Missing required variables:
- STRIPE_SECRET_KEY
- DATABASE_URL
Variables with default values (using defaults):
- LOG_LEVEL (default: info)
- DATABASE_POOL_SIZE (default: 10)
Validation failed: 2 required variables missing
Workflows
New Project Setup
- Project owner creates variables in EnvManager
- Generate template and commit to repo:
envmanager template generate git add .env.template git commit -m "Add environment template"
New Developer Onboarding
- Clone the repo
- Review required variables in template:
cat .env.template - Request access to EnvManager project
- Pull variables:
envmanager login envmanager pull
CI/CD Validation
Add to your pipeline:
# GitHub Actions example
- name: Validate environment
run: envmanager template validate
env:
ENVMANAGER_API_KEY: ${{ secrets.ENVMANAGER_API_KEY }}
Keeping Templates Updated
When adding new variables:
- Add to EnvManager via web UI
- Regenerate template:
envmanager template generate --force git add .env.template git commit -m "Update environment template"
Or sync from template to EnvManager:
- Edit
.env.templatemanually - Sync to EnvManager:
envmanager template sync