1---
2title: state
3description: Browse, read, and delete entries in the state store.
4---
5
6```sh
7alchemy state [subcommand] [options]
8```
9
10Inspect and manage the state store — the record of which resources
11alchemy thinks exist for each stack/stage. Reads from whatever state
12layer the stack file configures (e.g. `Cloudflare.state(...)`), or
13from the on-disk `.alchemy/state` directory with `--backend local`.
14See [State Store](/state-store).
15
16Run `alchemy state` with no subcommand in an interactive terminal to
17open the **state explorer**. It shows stacks, stages, resources, and a YAML
18preview of the selected resource's persisted state. Mark
19entries with Space and delete them with `d`; a confirm dialog lists the
20exact records before anything is removed. The subcommands below are the
21scriptable equivalents.
22
23The stack file is imported only to resolve its configured state layer
24Pass it with `--config`, which defaults to `alchemy.run.ts`. There is no
25deploy-style `--stage` flag here: state commands address what they
26inspect explicitly through positional arguments.
27
28All subcommands share these options:
29
30| Option | Description |
31| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
32| `--backend <configured\|local>` | `configured` uses the stack's state layer; `local` reads `.alchemy/state`, including orphaned state after a failed bootstrap |
33| `--profile <name>` | Auth profile to use (defaults to `$ALCHEMY_PROFILE` or `default`) |
34| `--env-file <path>` | Load environment variables from a file |
35| `--config, -c <file>` | Stack entrypoint to resolve the state layer from (defaults to `alchemy.run.ts`) |
36
37## `state list`
38
39```sh
40alchemy state list [path] [options] # alias: ls
41```
42
43State is addressed like a filesystem: `<stack>/<stage>/<namespace…>/
44<resource>`, plus one `output` entry per stage holding the stack's
45evaluated outputs. `list` prints one directory level; `--recursive`/`-r`
46walks the whole subtree.
47
48```sh
49alchemy state list # every stack
50alchemy state list my-app # stages under my-app
51alchemy state list my-app/prod # resource entries under my-app/prod
52alchemy state list my-app -r # every path under my-app
53```
54
55## `state read`
56
57```sh
58alchemy state read [path] [options] # alias: cat
59```
60
61Print persisted state as JSON. A resource path prints that record; a
62directory path with `--recursive` prints every record beneath it, keyed
63by path. Output uses the same encoding the store persists: redacted
64secrets are unwrapped into `{ __redacted__: ... }` and Resources are
65flattened.
66
67```sh
68# one resource record
69alchemy state read my-app/prod/Bucket
70
71# a whole stage as one JSON document for jq
72alchemy state read my-app/prod -r | jq 'to_entries[] | select(.value.resourceType == "AWS.EC2.Instance")'
73
74# diff two stages
75diff <(alchemy state read my-app/dev -r) \
76 <(alchemy state read my-app/prod -r)
77```
78
79## `state delete`
80
81```sh
82alchemy state delete <path> [options] # alias: rm
83```
84
85Delete state records. Deleting a stack or stage path removes everything
86beneath it; a directory path below stage level needs `--recursive`.
87`output` cannot be deleted independently. Alchemy removes it with its
88stage.
89
90| Option | Description |
91| ------------------- | ---------------------------------- |
92| `--recursive`, `-r` | Operate recursively on directories |
93
94:::caution
95**Destructive but local-only** — the actual cloud resources are not
96touched, only alchemy's record of them. A subsequent `deploy`
97re-imports owned resources automatically; see
98[Inspecting State](/cli/inspecting-state) for the recovery workflow
99and [Adopting Resources](/cli/adopting-resources) for when `--adopt`
100is needed.
101:::
102
103## Where next
104
105- [Inspecting State](/cli/inspecting-state) — debugging and recovery workflows
106- [Adopting Resources](/cli/adopting-resources) — how deploy reclaims existing infrastructure
107- [State Store](/state-store) — where resource state lives