asd env + asd mode — environment configuration
modedeclares which environment you're in (dev,prod,staging, …).envmaterialises the corresponding.env.<mode>file fromtpl.env. Together they're asd's multi-environment story.
These two groups always come up together. tpl.env holds per-mode
values (_mode_dev_PORT=3000, _mode_prod_PORT=8000). asd mode set <name> flips the active mode. asd env apply renders the right
.env.<mode> file. Manifests read PORT through ${{ env.PORT }}
and get the right value per mode.
For the walk-through: learn/04-multi-environment.
asd mode| Command | What it does |
|---|---|
asd mode list |
List modes declared in project.env_modes.available. |
asd mode set <name> |
Set the active mode for this project. --global to set the system default. |
asd mode show |
Show the currently active mode. --resolution shows the chain (project → global → default). |
In asd.yaml:
project:
env_modes:
available: [dev, staging, prod]
default: dev
State (active_mode) lives in .asd/state/active_mode so it
survives shells and persists across asd up/asd down cycles.
asd env| Command | What it does |
|---|---|
asd env init |
Initialise project .env from module templates. Done once per project (also runs implicitly during asd init). |
asd env apply |
Render .env.<active-mode> from tpl.env's _mode_<m>_* keys. Re-run after editing tpl.env or after mode set. |
asd env sync |
Three-way merge: pull new keys from tpl.env into .env without losing your edits. Requires .asd/state/env.snapshot. |
tpl.env key shape# Shared across modes — no prefix
APP_NAME=hello
# Per-mode — _mode_<name>_KEY
_mode_dev_PORT=3000
_mode_dev_LOG_LEVEL=debug
_mode_prod_PORT=8000
_mode_prod_LOG_LEVEL=info
asd env apply reads the _mode_<active>_* keys and renders them
(prefix-stripped) into .env.<active-mode>. Shared keys (no prefix)
pass through unchanged.
| Goal | Command |
|---|---|
| See available modes | asd mode list |
| Switch to prod mode | asd mode set prod && asd env apply && asd net apply |
| Add a new key to tpl.env without breaking my edits | asd env sync |
| What mode am I in? | asd mode show |
| Set global default mode | asd mode set dev --global |
| Re-render after editing tpl.env | asd env apply |
learn/04-multi-environment — the scenario walkthrough.reference/asd-yaml § project.env_modes — the declarative slot.cli/workspace — asd read-env for inspecting values without rendering.