Configuration Methods
env-twin is configured entirely through command-line flags. There are no configuration files.All configuration is passed as command-line arguments. This makes env-twin transparent and easy to use in scripts and CI/CD pipelines.
Source of Truth
The most important configuration concept in env-twin is the “Source of Truth” - the file that defines which environment variables should exist across all your.env* files.
Default Behavior
When not specified:- If
.env.exampleexists, it becomes the source of truth - Otherwise, env-twin uses the union of all keys from all
.env*files - You’ll be prompted to select a source of truth interactively during sync
Setting Source of Truth
Use the--source flag (or its aliases) to explicitly specify the source of truth:
--source--src
Common Source of Truth Patterns
Using .env.example as source
Using .env.example as source
Best for: Teams where All keys in
.env.example is the documented template.env.example will be synced to other files.Using .env as source
Using .env as source
Best for: Local development where Keys from
.env is the primary file.env will be synced to .env.local, .env.development, etc.Using .env.production as source
Using .env.production as source
Best for: Ensuring production parity across all environmentsProduction keys become the baseline for all environments.
Union mode (no source specified)
Union mode (no source specified)
Best for: Initial sync or when you want all keys everywhereAll keys from all files are collected and synced across all files.
Destination Configuration
For the default command (copying.env to .env.example), you can specify custom source and destination files.
Custom Source File
--source, --src
Custom Destination File
--dest, --destination, --d, --out, --target
Combined Example
.env.development and writes to .env.dev.example with placeholder values.
File Detection Patterns
env-twin automatically detects the following.env* file patterns:
File Detection Order
Files are processed in the order listed above. This ensures consistent behavior across runs.Sync Command Options
Thesync command supports several options to customize synchronization behavior:
Skip Backup
Prevent creating a backup before syncing:Auto-Accept Prompts
Skip confirmation prompts for non-destructive actions:--yes, -y
env-twin will still prompt for destructive actions or when manual decisions are needed (e.g., resolving missing keys).
JSON Output
Output analysis in JSON format for processing by other tools:Restore Command Options
Therestore command offers advanced options for backup restoration:
Basic Restore
Skip Confirmation
--yes, -y
List Available Backups
Preserve File Attributes
Create Rollback Snapshot
Create a pre-restore backup for rollback capability:Force Restore
Skip change detection and force restoration:--force, -f
Dry Run
Preview what would be restored without making changes:--dry-run, --simulate
Verbose Logging
Enable detailed logging for debugging:--verbose, -V
Combined Restore Example
Clean Backups Options
Customize backup cleanup behavior:Keep Specific Number
10 if not specified.
Auto-Confirm Cleanup
Global Options
These options work with any command:Help
Display help information:--help, -h
Version
Display version information:--version, -v
Configuration Examples
Example 1: Team Workflow
Example 2: Local Development
Example 3: CI/CD Pipeline
Example 4: Safe Experimentation
Example 5: Disaster Recovery
Best Practices
Related Pages
- Backup Management - Understanding backup behavior
- Best Practices - Recommended usage patterns
- Troubleshooting - Common configuration issues