sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ cli/ destroy.mdx

import Terminal from "../../../components/Terminal.astro";
alchemy destroy [options]

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.

Under the hood, destroy is deploy with the desired state zeroed out — every resource in state plans as a deletion.

<Terminal content={`[u]Plan[/u]: [r]2 to delete[/r]

[r]-[/r] [b]Worker[/b] d[/d] [r]-[/r] [b]Bucket[/b] d[/d]

Proceed? ◉ Yes ○ No [r]✗[/r] [b]Worker[/b] d[/d] [r]deleted[/r] [r]✗[/r] [b]Bucket[/b] d[/d] [r]deleted[/r]`} />

Flags

OptionDescription
--config, -c <file>Stack file to destroy (defaults to alchemy.run.ts)
--stage <name>Stage to destroy (defaults to $ALCHEMY_STAGE or live_$USER)
--yesSkip the approval prompt
--dry-runShow what would be deleted without actually deleting
--profile <name>Auth profile to use (defaults to $ALCHEMY_PROFILE or default)
--env-file <path>Load environment variables from a file

Examples

# Destroy a PR preview environment
alchemy destroy --stage pr-42 --yes

# Destroy your personal cloud sandbox
alchemy destroy --stage live_sam

# Destroy the local-dev stage created by alchemy dev
alchemy destroy --stage dev_sam

Retained resources

Resources declared with RemovalPolicy.retain() are skipped by destroy: the provider's delete is never called and only the state row is dropped, so the cloud object outlives the stack. The same is true of a resource whose declaration you simply delete — the orphan sweep reads the policy from the state row, not from your code.

import * as RemovalPolicy from "alchemy/RemovalPolicy";

const data = yield* R2.Bucket("Data").pipe(RemovalPolicy.retain());

See Resource lifecycle › Removal policy.

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.

Where next