CLI Reference
The mik CLI provides commands for creating, building, and running WASI HTTP projects. It includes an embedded runtime, so you only need one binary.
Installation
Section titled “Installation”cargo install mikCommands
Section titled “Commands”mik new
Section titled “mik new”Create a new mik project with all required files.
mik new <NAME> [OPTIONS]Options:
| Flag | Description |
|---|---|
--lib | Initialize as a library (default: handler) |
Example:
mik new my-apicd my-apimik build -rcmik runGenerated structure:
my-api/├── Cargo.toml # Component package├── mik.toml # Project config├── wit/│ ├── world.wit # WIT world definition│ └── deps/core/ # Core handler interface├── src/│ └── lib.rs # Handler implementation├── modules/ # Dependencies directory└── .gitignoremik build
Section titled “mik build”Build the WASM handler and optionally compose with bridge.
mik build [OPTIONS]Options:
| Flag | Description |
|---|---|
-r, --release | Build with optimizations |
-c, --compose | Compose with HTTP bridge |
Examples:
# Debug buildmik build
# Release buildmik build -r
# Release build + compose with bridgemik build -rcOutput:
target/wasm32-wasip2/release/<name>.wasm- Compiled handlerdist/<name>-composed.wasm- Composed component (with-c)
mik dev
Section titled “mik dev”Start development server with watch mode and embedded services.
mik dev [OPTIONS]Options:
| Flag | Description |
|---|---|
--port <PORT> | Server port (default: 3000) |
--no-services | Skip starting embedded services |
Features:
- Auto-rebuilds on source changes (watch mode)
- Auto-starts daemon for embedded services (KV, SQL, Storage, Cron)
- Runs in foreground with nice output
- Graceful shutdown on Ctrl+C
Example:
mik dev # Watch mode on port 3000mik dev --port 8080 # Custom portmik dev --no-services # Skip embedded servicesOutput:
Starting development server...
Services available at http://127.0.0.1:9919 KV: /kv/:key SQL: /sql/query, /sql/execute Storage: /storage/*path Cron: /cron
Watching for changes...Server: http://127.0.0.1:3000Press Ctrl+C to stopmik run
Section titled “mik run”Start the HTTP server with the embedded runtime.
mik run [COMPONENT] [OPTIONS]Arguments:
| Argument | Description |
|---|---|
COMPONENT | Optional path to a .wasm file |
Options:
| Flag | Description |
|---|---|
--port <PORT> | Server port (default: 3000) |
--workers <N> | Number of worker processes (0 = auto) |
--lb | Enable integrated L7 load balancer |
--local | Bind to localhost only |
--detach | Run as background instance with services |
--name <NAME> | Instance name when detached (default: “default”) |
Modes:
All modes use consistent /run/<module>/* routing.
Foreground mode (default):
mik run # Multi-module from mik.tomlmik run dist/api.wasm # Single componentDetached mode (background with services):
mik run --detach # Background instancemik run --detach --name prod --port 8080Auto-starts daemon if not running. Use mik ps to list instances.
Multi-worker mode (for performance):
mik run --workers 4 --lb # LB on 3000, workers on 3001-3004mik run --workers 0 --lb # Auto-detect workersExample output:
Starting server on http://127.0.0.1:3000Routes: /run/my-api/* -> componentHealth: /healthMetrics: /metricsBuilt-in endpoints:
| Endpoint | Description |
|---|---|
/health | Health check |
/metrics | Prometheus metrics |
/static/* | Static files (if configured) |
mik add
Section titled “mik add”Add a dependency to the project.
mik add <PACKAGE> [OPTIONS]Package formats:
user/repo # OCI: ghcr.io/user/repo:latestuser/repo:tag # OCI: ghcr.io/user/repo:tagOptions:
| Flag | Description |
|---|---|
--git <URL> | Git repository URL |
--path <PATH> | Local path |
--tag <TAG> | OCI/Git tag |
--branch <BRANCH> | Git branch |
Examples:
# Add from OCI registrymik add dufeutech/router
# Add with specific versionmik add dufeutech/router:v1.0.0
# Add from gitmik add my-component --git "https://github.com/user/repo.git"
# Add local dependencymik add my-handler --path "../my-handler"mik remove
Section titled “mik remove”Remove a dependency from the project.
mik remove <PACKAGE>mik sync
Section titled “mik sync”Synchronize dependencies from registries.
mik syncDownloads missing dependencies and removes stale modules from modules/.
When to use:
- After
git cloneto download all dependencies - After switching branches
- To clean up unused modules
mik cache
Section titled “mik cache”Manage the AOT compilation cache.
mik cache <SUBCOMMAND>Subcommands:
| Command | Description |
|---|---|
info | Show cache statistics |
clean | Remove stale entries |
clear | Clear all cached data |
mik completions
Section titled “mik completions”Generate shell completion scripts for tab completion support.
mik completions <SHELL>Supported shells: bash, zsh, fish, powershell, elvish
Installation:
# Bashmik completions bash > ~/.local/share/bash-completion/completions/mik
# Zsh (add fpath+=~/.zfunc to .zshrc first)mik completions zsh > ~/.zfunc/_mik
# Fishmik completions fish > ~/.config/fish/completions/mik.fish
# PowerShellmik completions powershell >> $PROFILEInstance Management
Section titled “Instance Management”Commands for managing background WASM instances. The daemon is auto-managed - it starts automatically when needed and stops when the last instance is stopped.
mik stop
Section titled “mik stop”Stop a running instance.
mik stop [NAME]Arguments:
| Argument | Description |
|---|---|
NAME | Instance name (default: “default”) |
Example:
mik stop # Stop "default" instancemik stop prod # Stop named instanceWhen the last instance is stopped, the daemon automatically exits.
mik ps
Section titled “mik ps”List all instances.
mik psExample output:
NAME PORT PID STATUS UPTIME────────────────────────────────────────────────────────default 3000 12345 running 2h 15mdev 3001 12346 running 45mmik logs
Section titled “mik logs”View instance logs.
mik logs [NAME] [OPTIONS]Options:
| Flag | Description |
|---|---|
-f, --follow | Follow log output |
-n, --lines <N> | Number of lines (default: 50) |
Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
PORT | Override server port |
HOST | Bind address (default: 127.0.0.1) |
RUST_LOG | Log level (error, warn, info, debug, trace) |
MIK_HOT_RELOAD | Enable hot reload mode |
MIK_API_KEY | API key for daemon authentication (optional) |
Workflow Examples
Section titled “Workflow Examples”Development Workflow
Section titled “Development Workflow”# 1. Create projectmik new my-apicd my-api
# 2. Build with compositionmik build -rc
# 3. Start development server (watch mode + services)mik dev
# 4. Testcurl http://localhost:3000/healthcurl http://localhost:3000/run/my-api/Production-like Testing
Section titled “Production-like Testing”# Multi-worker with load balancermik run --workers 4 --lb
# Or run as background instancemik run --detach --name prodmik ps # Check statusmik logs prod -f # Follow logsmik stop prod # Stop when doneAfter Cloning
Section titled “After Cloning”git clone https://github.com/user/my-api.gitcd my-apimik sync # Download all dependenciesmik build -rcmik dev # Start development