/sync-env - Sync Environment Variables
Synchronize environment variables across development, staging, and production.
Steps
- Read the current .env file and .env.example for the project
- Identify all environment variables used in the codebase (process.env, os.environ)
- Compare variables across environments: development, staging, production
- Identify missing variables in each environment
- Identify variables present in code but missing from all .env files
- Detect variables in .env files that are no longer used in code
- Verify variable naming conventions are consistent (UPPER_SNAKE_CASE)
- Check for sensitive variables that should use secrets management
- Generate an updated .env.example with all required variables and descriptions
- Sync missing variables to target environments (with placeholder values for secrets)
- Report: variables added, removed, mismatched across environments
- Update documentation with the current environment variable inventory
Rules
- Never copy secret values between environments; use placeholders
- Always update .env.example when adding new variables
- Do not commit .env files to version control; verify .gitignore includes them
- Flag variables with default values that look like real credentials
- Group related variables together in .env files (database, API keys, feature flags)
- Validate variable values against expected formats (URLs, numbers, booleans)
- Include comments in .env.example explaining each variable's purpose