Wasmtime Development
Wasmtime is a standalone, fast, secure WebAssembly runtime from the Bytecode Alliance. It implements the WebAssembly standard and extensions including WASI (WebAssembly System Interface) and the Component Model.
Anti-fabrication
This skill follows core:anti-fabrication. Wasmtime ships major-version bumps roughly
monthly, so pinned versions and API paths are high-risk. Verified against wasmtime
47.0.3 (crates.io, claude-skills-204): the host/guest Rust examples were pinned to a
stale "29" and used the pre-reorg wasmtime_wasi API — corrected to the p1::/p2::
submodule layout confirmed against docs.rs/wasmtime-wasi/latest, and WasiView::ctx()
was corrected to return a single WasiCtxView<'_> rather than separate ctx()/table()
methods. WASI 0.3.0 native-async coverage (stream/future in the Component Model,
requires Wasmtime 46+) was added, confirmed against wasi.dev and bytecodealliance.org.
Re-verify against docs.rs/wasmtime/latest before asserting an API this skill doesn't
cover — this crate changes fast enough that a stale example compiles against nothing.
Core Concepts
| Concept |
Purpose |
| Engine |
Shared compilation environment and configuration |
| Store |
Per-instance state container (fuel, epoch, host data) |
| Module |
Compiled .wasm binary (core module) |
| Component |
Compiled component with typed interfaces (WIT-based) |
| Instance |
Runtime instantiation of a module or component |
| Linker |
Resolves imports by name, defines host functions |
| WIT |
WebAssembly Interface Type language for component contracts |
Authoring WIT interface files continues in /wasm:wit.
Supported Languages
Guest Languages (compile TO wasm)
| Language |
Target |
Tooling |
Reference |
| Rust |
wasm32-wasip1, wasm32-wasip2, wasm32-unknown-unknown |
cargo-component, wit-bindgen |
guest-rust.md |
| Zig |
wasm32-wasi, wasm32-freestanding |
zig build, build.zig |
guest-zig.md |
Host Languages (embed wasmtime IN)
| Language |
Crate/Package |
Async Support |
Reference |
| Rust |
wasmtime crate |
Yes (tokio) |
host-rust.md |
| Elixir |
wasmex hex package |
Via GenServer |
host-elixir.md |
WASI Versions
| Version |
Status |
Key Differences |
| WASIp1 (Preview 1) |
Stable, widely supported |
POSIX-like, fd_* functions, linear memory I/O |
| WASIp2 (Preview 2) |
Stable, Component Model baseline |
Typed interfaces, synchronous streams |
| WASIp3 (0.3) |
Announced stable 2026-06-11 (bytecodealliance.org/articles/WASI-0.3, read 2026-08-04) |
Native async — stream<T>/future<T>/async as first-class canonical-ABI constructs; Wasmtime 46 ships it with Component Model Async on by default |
Use WASIp2 for broad compatibility, WASIp3 for new components that need native async and target Wasmtime 46+. WASIp1 remains supported for existing code. See overview.md for migration details.
Reference Index
| Reference |
Contents |
| overview.md |
Installation, core concepts detail, Component Model, WIT syntax, WASI deep dive, resource limits, AOT compilation, debugging |
| guest-rust.md |
Rust wasm targets, cargo-component, wit-bindgen, binary size optimization, testing strategies |
| guest-zig.md |
Zig wasm targets, build.zig configuration, allocator patterns, WASI imports, exports |
| host-rust.md |
Wasmtime Rust API, WASI context setup, Component Model bindgen!, async support, plugin system patterns |
| host-elixir.md |
Wasmex API, GenServer integration, memory access, host callbacks, supervision patterns |
WebAssembly instrumentation (whamm)
whamm! instruments compiled .wasm modules by inserting probes through bytecode rewriting, using a DTrace-inspired .mm DSL for profiling, opcode counting, cache simulation, and call graph analysis. Run instrumented modules on wasmtime by preloading the whamm core library: wasmtime run --env TO_CONSOLE=true --preload whamm_core=whamm_core.wasm out.wasm. For CLI installation (mise github backend), the .mm language, and instrumentation strategies, see the whamm and whamm-dsl skills in the whamm plugin (/plugin install whamm@vinnie357).
Common Pitfalls
- Wrong target triple: Use
wasm32-wasip2 for Component Model, wasm32-wasip1 for legacy WASI, wasm32-unknown-unknown for bare modules
- Missing WASI context: Host must add WASI to the linker before instantiating WASI-dependent modules
- Store lifetime: Each
Store owns instance state — do not share stores across threads without synchronization
- Fuel exhaustion: Enable fuel metering for untrusted code and handle
OutOfFuel traps
- Component vs Module: Components use WIT-typed interfaces; core modules use raw numeric imports/exports — do not mix APIs
- Linear memory bounds: Always validate pointer+length pairs when passing data through linear memory
1---2name: wasmtime3description: Guide for WebAssembly development with Wasmtime runtime. Use when compiling Rust or Zig to wasm, embedding Wasmtime in Rust or Elixir hosts, working with WASI, or using the Component Model.4license: MIT5---67# Wasmtime Development89Wasmtime is a standalone, fast, secure WebAssembly runtime from the Bytecode Alliance. It implements the WebAssembly standard and extensions including WASI (WebAssembly System Interface) and the Component Model.1011## Anti-fabrication1213This skill follows `core:anti-fabrication`. Wasmtime ships major-version bumps roughly14monthly, so pinned versions and API paths are high-risk. Verified against wasmtime1547.0.3 (crates.io, claude-skills-204): the host/guest Rust examples were pinned to a16stale "29" and used the pre-reorg `wasmtime_wasi` API — corrected to the `p1::`/`p2::`17submodule layout confirmed against docs.rs/wasmtime-wasi/latest, and `WasiView::ctx()`18was corrected to return a single `WasiCtxView<'_>` rather than separate `ctx()`/`table()`19methods. WASI 0.3.0 native-async coverage (stream/future in the Component Model,20requires Wasmtime 46+) was added, confirmed against wasi.dev and bytecodealliance.org.21Re-verify against `docs.rs/wasmtime/latest` before asserting an API this skill doesn't22cover — this crate changes fast enough that a stale example compiles against nothing.2324## Core Concepts2526| Concept | Purpose |27|---------|---------|28| Engine | Shared compilation environment and configuration |29| Store | Per-instance state container (fuel, epoch, host data) |30| Module | Compiled `.wasm` binary (core module) |31| Component | Compiled component with typed interfaces (WIT-based) |32| Instance | Runtime instantiation of a module or component |33| Linker | Resolves imports by name, defines host functions |34| WIT | WebAssembly Interface Type language for component contracts |3536Authoring WIT interface files continues in `/wasm:wit`.3738## Supported Languages3940### Guest Languages (compile TO wasm)4142| Language | Target | Tooling | Reference |43|----------|--------|---------|-----------|44| Rust | `wasm32-wasip1`, `wasm32-wasip2`, `wasm32-unknown-unknown` | `cargo-component`, `wit-bindgen` | [guest-rust.md](references/guest-rust.md) |45| Zig | `wasm32-wasi`, `wasm32-freestanding` | `zig build`, `build.zig` | [guest-zig.md](references/guest-zig.md) |4647### Host Languages (embed wasmtime IN)4849| Language | Crate/Package | Async Support | Reference |50|----------|---------------|---------------|-----------|51| Rust | `wasmtime` crate | Yes (tokio) | [host-rust.md](references/host-rust.md) |52| Elixir | `wasmex` hex package | Via GenServer | [host-elixir.md](references/host-elixir.md) |5354## WASI Versions5556| Version | Status | Key Differences |57|---------|--------|-----------------|58| WASIp1 (Preview 1) | Stable, widely supported | POSIX-like, `fd_*` functions, linear memory I/O |59| WASIp2 (Preview 2) | Stable, Component Model baseline | Typed interfaces, synchronous streams |60| WASIp3 (0.3) | Announced stable 2026-06-11 (bytecodealliance.org/articles/WASI-0.3, read 2026-08-04) | Native async — `stream<T>`/`future<T>`/`async` as first-class canonical-ABI constructs; Wasmtime 46 ships it with Component Model Async on by default |6162Use WASIp2 for broad compatibility, WASIp3 for new components that need native async and target Wasmtime 46+. WASIp1 remains supported for existing code. See [overview.md](references/overview.md) for migration details.6364## Reference Index6566| Reference | Contents |67|-----------|----------|68| [overview.md](references/overview.md) | Installation, core concepts detail, Component Model, WIT syntax, WASI deep dive, resource limits, AOT compilation, debugging |69| [guest-rust.md](references/guest-rust.md) | Rust wasm targets, cargo-component, wit-bindgen, binary size optimization, testing strategies |70| [guest-zig.md](references/guest-zig.md) | Zig wasm targets, build.zig configuration, allocator patterns, WASI imports, exports |71| [host-rust.md](references/host-rust.md) | Wasmtime Rust API, WASI context setup, Component Model bindgen!, async support, plugin system patterns |72| [host-elixir.md](references/host-elixir.md) | Wasmex API, GenServer integration, memory access, host callbacks, supervision patterns |7374## WebAssembly instrumentation (whamm)7576whamm! instruments compiled `.wasm` modules by inserting probes through bytecode rewriting, using a DTrace-inspired `.mm` DSL for profiling, opcode counting, cache simulation, and call graph analysis. Run instrumented modules on wasmtime by preloading the whamm core library: `wasmtime run --env TO_CONSOLE=true --preload whamm_core=whamm_core.wasm out.wasm`. For CLI installation (mise github backend), the `.mm` language, and instrumentation strategies, see the `whamm` and `whamm-dsl` skills in the whamm plugin (`/plugin install whamm@vinnie357`).7778## Common Pitfalls7980- **Wrong target triple**: Use `wasm32-wasip2` for Component Model, `wasm32-wasip1` for legacy WASI, `wasm32-unknown-unknown` for bare modules81- **Missing WASI context**: Host must add WASI to the linker before instantiating WASI-dependent modules82- **Store lifetime**: Each `Store` owns instance state — do not share stores across threads without synchronization83- **Fuel exhaustion**: Enable fuel metering for untrusted code and handle `OutOfFuel` traps84- **Component vs Module**: Components use WIT-typed interfaces; core modules use raw numeric imports/exports — do not mix APIs85- **Linear memory bounds**: Always validate pointer+length pairs when passing data through linear memory