1---
2title: destroy
3description: Delete every resource in a stack — plan all existing resources for deletion, ask for approval, and remove them in dependency order.
4---
5
6import Terminal from "../../../components/Terminal.astro";
7
8```sh
9alchemy destroy [options]
10```
11
12`destroy` deletes every resource in a stack. It computes a plan where all existing resources are marked for deletion, asks for approval, and removes them in dependency order.
13
14Under the hood, `destroy` is `deploy` with the desired state zeroed out — every resource in state plans as a deletion.
15
16<Terminal content={`[u]Plan[/u]: [r]2 to delete[/r]
17
18[r]-[/r] [b]Worker[/b] [d](Cloudflare.Worker)[/d]
19[r]-[/r] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d]
20
21Proceed?
22◉ Yes ○ No
23[r]✗[/r] [b]Worker[/b] [d](Cloudflare.Worker)[/d] [r]deleted[/r]
24[r]✗[/r] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d] [r]deleted[/r]`} />
25
26## Flags
27
28| Option | Description |
29| ------------------- | ----------------------------------------------------------------- |
30| `--config, -c <file>` | Stack file to destroy (defaults to `alchemy.run.ts`) |
31| `--stage <name>` | Stage to destroy (defaults to `$ALCHEMY_STAGE` or `live_$USER`) |
32| `--yes` | Skip the approval prompt |
33| `--dry-run` | Show what would be deleted without actually deleting |
34| `--profile <name>` | Auth profile to use (defaults to `$ALCHEMY_PROFILE` or `default`) |
35| `--env-file <path>` | Load environment variables from a file |
36
37## Examples
38
39```sh
40# Destroy a PR preview environment
41alchemy destroy --stage pr-42 --yes
42
43# Destroy your personal cloud sandbox
44alchemy destroy --stage live_sam
45
46# Destroy the local-dev stage created by alchemy dev
47alchemy destroy --stage dev_sam
48```
49
50## Retained resources
51
52Resources declared with `RemovalPolicy.retain()` are skipped by
53`destroy`: the provider's `delete` is never called and only the state
54row is dropped, so the cloud object outlives the stack. The same is
55true of a resource whose declaration you simply delete — the orphan
56sweep reads the policy from the state row, not from your code.
57
58```typescript
59import * as RemovalPolicy from "alchemy/RemovalPolicy";
60
61const data = yield* R2.Bucket("Data").pipe(RemovalPolicy.retain());
62```
63
64See [Resource lifecycle › Removal policy](/infrastructure-as-code/resource-lifecycle#removal-policy).
65
66`destroy` is scoped to one stack + stage and driven by the state store; to enumerate and delete everything a set of providers can see in the live account, see [nuke](/cli/nuke).
67
68## Where next
69
70- [deploy](/cli/deploy) — bring the stack back
71- [nuke](/cli/nuke) — account-wide teardown, not scoped to a stack
72- [state](/cli/state) — inspect and clear the state the plan is driven by
73- [Stages](/environments/stages) — how environments are isolated
74- [Resource lifecycle › Removal policy](/infrastructure-as-code/resource-lifecycle#removal-policy) — keep a resource when its stack goes away