Manage multi-environment configuration across .env.dev, .env.staging, and .env.prod.
# Switch the active environment to staging
nself env use staging
# List all environments and the currently active one
nself env list
# Compare staging vs prod to catch drift
nself env diff staging prodnself env use <ENV>
nself env list
nself env show [ENV]
nself env diff <ENV_A> <ENV_B>
nself env copy <FROM> <TO> [FLAGS]nSelf uses a layered environment cascade: .env.dev holds team-shared defaults, .env.staging and .env.prod hold environment-specific overrides, .env.secrets holds real production secrets (gitignored), and.env.local holds per-machine overrides (gitignored). The CLI merges these layers at startup; later layers override earlier ones.
nself env use switches which environment the CLI targets for subsequent commands like nself start, nself deploy, andnself db. The active environment is stored in .nself/env and survives shell restarts.
The subcommands create, switch, and delete were removed in v1.0.x. Use env use to switch, and manage env files directly for creation and deletion.
Set the active environment for all subsequent CLI operations. Valid values:local, dev, staging, prod.
nself env use staging
# Switched to environment: staging
# Active: .env.staging + .env.secretsPrint all available environments and highlight the currently active one.
nself env list
# local (active)
# staging
# prodPrint the merged, resolved configuration for an environment. Secrets are masked by default; use --reveal with caution. Omitting ENV shows the active environment.
nself env show
nself env show staging
nself env show prod --reveal # shows secret values — handle carefullyCompare two environments side-by-side. Highlights variables that differ in value, variables present in one environment but missing in the other, and masked secrets that have different hashes (indicating different values without revealing them).
nself env diff staging prod
# VAR STAGING PROD
# POSTGRES_DB nself_staging nself_prod
# HASURA_GRAPHQL_ADMIN_SECRET [differs] [differs]
# NEW_FEATURE_FLAG true <missing>Copy non-secret variables from one environment file to another. Secrets (any variable matching *_SECRET, *_TOKEN, *_KEY,*_PASSWORD) are skipped unless --include-secrets is passed.
# Copy shared config from dev to staging (no secrets)
nself env copy dev staging
# Also copy secrets (be careful)
nself env copy staging prod --include-secrets| Flag | Type | Default | Description |
|---|---|---|---|
--reveal | bool | false | Show secret values in env show output (use carefully) |
--include-secrets | bool | false | Include secret variables in env copy |
--json | bool | false | Output list, show, and diff as JSON |
--no-mask | bool | false | Alias for --reveal |
nself env diff staging prod
# Review all differences, especially missing vars in prodnself env copy staging prod
# Then manually set prod secrets in .env.secretsnself env show staging --json | jq 'keys | sort'
nself env show prod --json | jq 'keys | sort'nself env use local
nself startnself env show --json | jq 'to_entries[] | select(.value != "[secret]")'NSELF_ENV — override the active environment for one command: NSELF_ENV=prod nself db status0 — success1 — generic error2 — invalid arguments or unknown environment name6 — diff found differences (useful in CI assertions: nself env diff staging prod; [ $? -eq 0 ])