You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how Alchemy automatically parses CLI arguments for common operations like destroy, read, quiet mode, and staging without requiring a traditional CLI tool.
5
+
---
6
+
7
+
# CLI Arguments
8
+
9
+
Alchemy doesn't have a traditional CLI tool like `wrangler` or `terraform` because it's designed to be an embeddable TypeScript library. Instead, it provides automatic CLI argument parsing when you initialize an alchemy application, making it easy to run your infrastructure scripts with common options.
10
+
11
+
## No CLI, but CLI Arguments
12
+
13
+
Rather than building a separate CLI tool, Alchemy automatically parses CLI arguments when you call:
14
+
15
+
```ts
16
+
const app = await alchemy("my-app");
17
+
```
18
+
19
+
This design choice keeps Alchemy simple while still providing the convenience of CLI arguments for common operations.
20
+
21
+
## Supported Arguments
22
+
23
+
### Phase Control
24
+
25
+
Control what phase your infrastructure script runs in:
26
+
27
+
```sh
28
+
# Deploy/update resources (default)
29
+
bun ./alchemy.run
30
+
31
+
# Read-only mode - doesn't modify resources
32
+
bun ./alchemy.run --read
33
+
34
+
# Destroy all resources
35
+
bun ./alchemy.run --destroy
36
+
```
37
+
38
+
Learn more about phases in the [phase concepts guide](../concepts/phase.md).
By default, the stage is set to `process.env.USER` (your username). You can also use `ALCHEMY_STAGE` or `PASSWORD` environment variables to control staging behavior.
61
+
62
+
### Secret Management
63
+
64
+
Provide encryption password via environment variable:
65
+
66
+
```sh
67
+
# Set password for encrypting/decrypting secrets
68
+
ALCHEMY_PASSWORD=my-secret-key bun ./alchemy.run
69
+
```
70
+
71
+
## How It Works
72
+
73
+
When you call `alchemy("my-app")`, it automatically:
74
+
75
+
1. Parses `process.argv` for supported arguments
76
+
2. Merges CLI options with any explicit options you provide
77
+
3. Explicit options always take precedence over CLI arguments
78
+
79
+
```ts
80
+
// CLI args are parsed automatically
81
+
const app = await alchemy("my-app");
82
+
83
+
// Explicit options override CLI args
84
+
const app = await alchemy("my-app", {
85
+
phase: "up", // This overrides --destroy or --read
86
+
stage: "prod", // This overrides --stage
87
+
quiet: false, // This overrides --quiet
88
+
});
89
+
```
90
+
91
+
## Environment Variables
92
+
93
+
Alchemy also supports these environment variables:
94
+
95
+
- `ALCHEMY_PASSWORD` - Password for encrypting/decrypting secrets
96
+
- `ALCHEMY_STAGE` - Default stage name
97
+
- `USER` - Fallback for stage name (uses your username)
98
+
99
+
## Complete Example
100
+
101
+
Here's how you might use CLI arguments in practice:
0 commit comments