The nself env command manages the active environment for a project. nSelf supports multiple named environments (e.g. local, staging,prod) via the .env.dev → .env.staging/.env.prod → .env.secrets → .env.computed cascade.
Source of truth: SPORT F02-COMMAND-INVENTORY.md.
use · list · show · diff · copySubcommands create, switch, delete,validate, export, import,status, and info do not exist in v1.0.x.
nself env <subcommand> [args]| Command | Description |
|---|---|
use <env> | Switch active environment |
list | List available environments |
show | Show current environment config (secrets masked) |
diff <env-a> <env-b> | Compare two environments side by side |
copy <from> <to> | Copy environment config to a new name |
Switch the active environment. After switching, run nself build to regenerate configs.
nself env use local
nself env use staging
nself env use prodList all available environments. The active environment is marked.
nself env list
# Example output:
# ENVIRONMENTS
# * local (active)
# staging
# prodShow the current environment configuration. Secret values are masked.
nself env show
# Displays all .env keys for the active environment
# Secret values appear as [REDACTED]Compare two environments side by side. Useful before deploying to catch config drift.
nself env diff local staging
nself env diff staging prod
# Example output:
# KEY local staging
# DEBUG true false
# BASE_DOMAIN local.nself.org staging.example.com
# LOG_LEVEL debug infoCopy an environment configuration to a new name. Useful for creating a new environment from an existing one.
nself env copy staging qa # Create 'qa' from 'staging'nSelf uses a layered environment cascade. Files applied in order (later overrides earlier):
.env.dev # Base team defaults (committed)
↓
.env.staging # Staging shared config (committed)
.env.prod # Production shared config (committed)
↓
.env.secrets # Real secrets — NOT committed, chmod 600
↓
.env.computed # Generated by nself build — do not hand-edit# Check what's active
nself env list
# Compare before deploying
nself env diff local staging
# Switch to staging
nself env use staging
nself build
nself start