| 1 | --- |
| 2 | title: CLI |
| 3 | description: Every alchemy command at a glance — the command map, common options, and how the interactive TUI decides when to render. |
| 4 | --- |
| 5 | |
| 6 | ```sh |
| 7 | bun alchemy <command> [options] |
| 8 | ``` |
| 9 | |
| 10 | Every command operates on an `alchemy.run.ts` stack file (or a custom entrypoint passed with `--config <file>`, which must exist) and targets a [stage](/environments/stages). |
| 11 | |
| 12 | ## Command map |
| 13 | |
| 14 | ```sh |
| 15 | alchemy |
| 16 | ├─ deploy # plan → approve → apply |
| 17 | ├─ plan # preview changes, apply nothing |
| 18 | ├─ destroy # delete every resource in a stage |
| 19 | ├─ drift # detect (and optionally repair) infrastructure drift |
| 20 | ├─ unsafe nuke # delete everything a provider can list, tracked or not |
| 21 | │ |
| 22 | ├─ dev # hot-reloading development loop |
| 23 | ├─ logs # fetch past log entries, or tail live with --tail |
| 24 | │ |
| 25 | ├─ profile create|rename|edit|refresh|current|list|show|delete |
| 26 | │ # manage credentials and accounts (bare `profile` opens the dashboard) |
| 27 | │ |
| 28 | ├─ state list|read|delete # inspect and manage the state store (bare `state` opens the explorer) |
| 29 | │ |
| 30 | └─ provider |
| 31 | ├─ check-env # CI preflight: verify required provider env vars are set |
| 32 | ├─ aws bootstrap|teardown |
| 33 | └─ cloudflare bootstrap|teardown|token|state logs |
| 34 | ``` |
| 35 | |
| 36 | Each command has its own page: [deploy](/cli/deploy), [plan](/cli/plan), [destroy](/cli/destroy), [drift](/cli/drift), [unsafe nuke](/cli/nuke), [dev](/cli/dev), [logs](/cli/logs), [profile](/cli/profile), [state](/cli/state), [AWS provider commands](/cli/aws), and [Cloudflare provider commands](/cli/cloudflare). The workflow guides cover [adopting resources](/cli/adopting-resources) and [inspecting state](/cli/inspecting-state). |
| 37 | |
| 38 | ## Common options |
| 39 | |
| 40 | | Option | Description | |
| 41 | | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | |
| 42 | | `--stage <name>` | Stage to target. Falls back to `$ALCHEMY_STAGE`, then `live_$USER` (`dev_$USER` for `alchemy dev`). Must match `[a-z0-9]+([-_a-z0-9]+)*`. | |
| 43 | | `--profile <name>` | Auth profile from `~/.alchemy/profiles.json`. Overrides `$ALCHEMY_PROFILE`; defaults to `default`. | |
| 44 | | `--env-file <path>` | File to load environment variables from. Defaults to `.env`. | |
| 45 | | `--yes` | Yes to all prompts. | |
| 46 | | `--no-input` | Disable prompts and the interactive TUI. Commands that would need input fail instead of hanging. | |
| 47 | | `--config, -c <file>` | Stack entrypoint. Defaults to `alchemy.run.ts`; must exist. | |
| 48 | |
| 49 | Use `--profile` with `deploy`, `plan`, `destroy`, `dev`, `logs`, `drift`, or `state`. |
| 50 | |
| 51 | ## The interactive TUI |
| 52 | |
| 53 | In an interactive terminal, `deploy`, `destroy`, and `plan` render a live TUI: the rendered plan, an arrow-key approval prompt, and per-resource apply progress that unmounts into the final output. Everywhere else the same commands emit plain line-oriented logs. |
| 54 | |
| 55 | The `--no-input` flag and environment variables override the detection, in this order: |
| 56 | |
| 57 | | Signal | Effect | |
| 58 | | ------------------------------------------------------------------------------------------------- | ----------------- | |
| 59 | | `--no-input` flag | Force plain output | |
| 60 | | `ALCHEMY_PLAIN=1` or `ALCHEMY_NO_TUI=1` | Force plain output | |
| 61 | | `ALCHEMY_TUI=1` | Force the TUI | |
| 62 | | No TTY, `CI=1`, or a known agent env var (`CLAUDECODE`, `CLAUDE_CODE_ENTRYPOINT`, `CURSOR_AGENT`, `AIDER_MODEL`, `CODEX_CLI`) | Force plain output | |
| 63 | |
| 64 | Interactive terminals use the animated TUI; redirected and non-interactive runs use append-only output. |
| 65 | |
| 66 | Plain mode never prompts — it prints the plan, makes no changes, and fails with `error: Cannot approve this operation without terminal input. Pass --yes to continue.` In CI, always pass `--yes`. |
| 67 | |
| 68 | ## Exit codes |
| 69 | |
| 70 | Exit codes are script-safe: `0` only means the command actually completed. |
| 71 | |
| 72 | | Code | Meaning | |
| 73 | | ----- | --------------------------------------------------------------------------------------------------- | |
| 74 | | `0` | Command completed | |
| 75 | | `1` | Failure, including a declined plan or bare `profile`/`state` without a terminal | |
| 76 | | `130` | Cancelled by the user (Ctrl-C, or Escape inside a prompt) | |
| 77 | |
| 78 | Running these commands in a pipeline? See [CI](/environments/ci). |
| 79 | |
| 80 | ## Where next |
| 81 | |
| 82 | - [deploy](/cli/deploy) — plan, approve, and apply changes |
| 83 | - [dev](/cli/dev) — hot-reloading development loop |
| 84 | - [profile](/cli/profile) manages credentials and connected accounts |
| 85 | - [state](/cli/state) — inspect and manage the state store |
| 86 | - [Stages](/environments/stages) — how environments are isolated |
| 87 | - [CI](/environments/ci) — run the CLI in pipelines |