Commands Reference¶
All Run 2.0 commands are accessed via run v2 <command>.
Get help for any command:
init¶
Create a new Run 2.0 project with a working starter component.
What it creates:
<name>/
├── run.toml # Project config with component + test
├── components/
│ └── hello.wat # Starter component (increment function)
└── wit/
└── hello.wit # WIT interface definition
Example:
run v2 init calculator
cd calculator
wasm-tools parse components/hello.wat -o components/hello.wasm
run v2 test # Verify everything works
The starter exports a greet(s32) -> s32 function that increments its argument. It's intentionally simple — the point is to verify your entire toolchain works before writing real components.
build¶
Compile source components to WASI 0.2 .wasm binaries.
| Flag | Description |
|---|---|
--release | Optimize for production |
--reproducible | Deterministic builds (sets SOURCE_DATE_EPOCH, strips paths) |
--component <name> | Build only one component |
Examples:
# Build all components
run v2 build
# Production build
run v2 build --release
# Build one component
run v2 build --component api
# CI/CD: reproducible build
run v2 build --reproducible --release
Supported languages: Rust, Go, Python, JavaScript, TypeScript, Zig
The build command detects the language from run.toml, invokes the appropriate toolchain (cargo-component, tinygo, componentize-py, jco, zig), and validates the output is a valid WASI 0.2 component.
Pre-built components
If your component uses path instead of source in run.toml, it's already compiled and build skips it.
exec¶
Execute a component in production mode with strict determinism guarantees.
| Flag | Description |
|---|---|
--function <name> | Function to call (required for non-CLI components) |
--args <value> | Argument (repeatable, or comma-separated). Format: type:value |
--allow-clock | Allow clock access (breaks determinism) |
--allow-random | Allow random access (breaks determinism) |
--json | Force JSON output |
Argument format:
Arguments use typed format: s32:42, u64:100, string:hello, bool:true, f64:3.14
Examples:
# Run a CLI component (has _start or wasi:cli/run)
run v2 exec my-app.wasm
# Call a specific function
run v2 exec calculator.wasm --function add --args "s32:3" --args "s32:4"
# → {"exit_code":0,"return_value":7}
# Comma-separated args
run v2 exec calculator.wasm --function add --args "s32:3,s32:4"
# JSON output for scripting
run v2 exec api.wasm --function handler --json
# Allow clock (e.g., for timestamp-dependent logic)
run v2 exec app.wasm --allow-clock
Output:
By default, exec returns structured JSON:
For CLI components (those exporting _start or wasi:cli/run), stdout/stderr are passed through directly.
test¶
Run component tests defined in run.toml or auto-discovered from exports.
| Flag | Description |
|---|---|
--component <name> | Test specific component |
--build | Build before testing |
Defining tests in run.toml:
[[test]]
component = "calculator"
function = "add"
args = ["s32:2", "s32:3"]
expected = "s32:5"
[[test]]
component = "calculator"
function = "multiply"
args = ["s32:6", "s32:7"]
expected = "s32:42"
Auto-discovery:
If no tests are defined in run.toml, Run automatically discovers and runs any exported functions whose names start with test_ or test-.
Example output:
Running 3 tests...
PASS add_basic (add(s32:2, s32:3) → s32:5)
PASS multiply_basic (multiply(s32:6, s32:7) → s32:42)
PASS test_edge_case (auto-discovered)
Results: 3 passed, 0 failed
dev¶
Start a development server with hot reload and component composition.
| Flag | Description |
|---|---|
--port <port> | Dev server port (default: 3000) |
--no-hot-reload | Disable file watching |
--verbose | Verbose logging |
What it does:
- Loads all components defined in
run.toml - Loads installed dependencies from
.run/components/ - Links components together (cross-component imports resolve automatically)
- Watches for file changes and rebuilds
- Serves a status UI on the configured port
Example:
[dev] Starting dev session...
[dev] Loaded 3 components
[dev] Resolved 2 dependencies
[dev] Watching for changes...
[dev] Dev server: http://localhost:3000
Dev vs Exec differences:
| Feature | dev | exec |
|---|---|---|
| Clock access | Allowed | Blocked (deterministic) |
| Hot reload | Yes | No |
| Resource limits | Relaxed | Enforced |
| Component linking | Automatic | Manual |
install¶
Install components from the registry.
| Flag | Description |
|---|---|
--version <ver> | Specific version |
--dev | Install as dev dependency |
Examples:
# Install all dependencies from run.toml
run v2 install
# Install a specific package
run v2 install wasi:http@0.2.0
# Install as dev dependency
run v2 install test:mock --dev
Installed components are cached in .run/components/ and are automatically available during run v2 dev and run v2 exec.
publish¶
Publish a component to the registry.
| Flag | Description |
|---|---|
--build | Build before publishing |
--component <name> | Publish specific component |
--registry-url <url> | Custom registry URL |
--token <token> | Auth token (prefer RUN_AUTH_TOKEN env var) |
Authentication priority:
--tokenCLI flagRUN_AUTH_TOKENenvironment variable[registry] auth_tokeninrun.toml
Example:
deploy¶
Deploy components to edge platforms or package for distribution.
| Flag | Description |
|---|---|
--target <target> | local, registry, or edge |
--provider <name> | Edge provider: cloudflare, fastly, aws-lambda, vercel |
--profile <name> | Use named profile from run.toml |
--build | Build before deploying |
--output <dir> | Output directory (for local target) |
Examples:
# Package locally
run v2 deploy --target local
# Deploy to Cloudflare Workers
run v2 deploy --target edge --provider cloudflare --build
# Use a named profile
run v2 deploy --profile production
See Deployment for full configuration.
info¶
Show project or component information.
Inspect a local .wasm file:
Project info (from run.toml):
Registry package info:
update¶
Update dependencies to their latest versions.
verify¶
Verify installed component integrity against the lockfile.
| Flag | Description |
|---|---|
--offline | Don't fetch missing components |
Checks SHA256 hashes of all cached components. Use in CI/CD to detect tampering.
clean¶
Remove build artifacts and optionally the component cache.
| Flag | Description |
|---|---|
--cache | Also clean .run/ cache |
compose¶
Analyze and migrate Docker Compose files to WASI components.
| Action | Description |
|---|---|
analyze | Analyze a compose file for WASI migration candidates |
migrate | Generate a run.toml from a compose file |
# See what can be migrated
run v2 compose analyze docker-compose.yml
# Generate run.toml
run v2 compose migrate docker-compose.yml run.toml
toolchain¶
Manage and lock toolchain versions for reproducible builds.
| Action | Description |
|---|---|
sync | Write current toolchain versions to run.lock.toml |
Creates run.lock.toml with exact versions of cargo-component, wasm-tools, etc. Commit this file to ensure all team members and CI use identical toolchains.