Skip to content
Development
Skill

/wasm-wasmtime

WebAssembly runtime skill using wasmtime. Use when running WASM modules with wasmtime CLI, working with WASI preview2, using the component model, embedding wasmtime in Rust applications, limiting execution with fuel metering, or debugging WASM with DWARF in wasmtime. Activates

From plugin
low-level-dev-skills
295142 skills

Claude Code

$ npx -y skills add mohitmishra786/low-level-dev-skills --skill wasm-wasmtime --agent claude-code

SKILL.md

wasm-wasmtime.SKILL.md
name: wasm-wasmtime
description: WebAssembly runtime skill using wasmtime. Use when running WASM modules or components with the wasmtime CLI, choosing between WASI 0.1/0.2/0.3, using the component model, embedding wasmtime in Rust applications, limiting execution with fuel or timeouts, or debugging WASM with DWARF in wasmtime. Activates on queries about wasmtime, WASI, WASIp2, WASIp3, WASM component model, wasmtime embedding, WIT interfaces, fuel metering, or server-side WebAssembly.

wasmtime — Server-Side WASM Runtime

Purpose

Guide agents through wasmtime (examples checked against wasmtime 50): running modules and components from the CLI, WASI versions, the component model with WIT interfaces, embedding wasmtime in Rust, fuel and timeout limits, and debugging WASM with DWARF.

Triggers

  • "How do I run a WASM file with wasmtime?"
  • "What is the difference between WASI p1, p2 and p3?"
  • "How do I embed wasmtime in my Rust application?"
  • "What is the WebAssembly component model?"
  • "How do I limit WASM execution with fuel?"
  • "How do I debug a WASM module in wasmtime?"

Workflow

1. wasmtime CLI

# Install
curl https://wasmtime.dev/install.sh -sSf | bash

# Run a WASM module or component (run is the default subcommand)
wasmtime hello.wasm

# Arguments after the file go to the guest
wasmtime run prog.wasm arg1 arg2

# Pre-open directories (WASI filesystem sandbox)
wasmtime run --dir /tmp::/ prog.wasm    # map host /tmp to guest /

# Pass environment variables
wasmtime run --env HOME=/home/user prog.wasm

# Invoke an exported function
wasmtime run --invoke add math.wasm 3 4             # core module
wasmtime run --invoke 'add(3, 4)' math-component.wasm  # component: call syntax

# Inspect a binary (wasm-tools, not wasmtime)
wasm-tools print prog.wasm --skeleton    # imports/exports as WAT
wasm-tools component wit component.wasm  # a component's WIT interface
wasmtime explore prog.wasm               # writes prog.explore.html (wasm ↔ machine code)

# Compile ahead of time
wasmtime compile prog.wasm -o prog.cwasm
wasmtime run --allow-precompiled prog.cwasm  # required for .cwasm input

Resource limits on the CLI:

wasmtime run -W fuel=10000000 prog.wasm        # trap after N units of fuel
wasmtime run -W timeout=2s prog.wasm           # trap after wall-clock time
wasmtime run -W max-memory-size=67108864 prog.wasm  # cap linear memory (bytes)

`-W` sets wasm features and limits, `-S` WASI options, `-D` debug options, `-O` codegen options. Run `wasmtime -W help` (or `-S help`, `-D help`, `-O help`) for the full list.

2. WASI versions

| Version | Binary kind | Rust target | Notes | |---------|-------------|-------------|-------| | 0.1 (preview 1) | core module importing `wasi_snapshot_preview1` | `wasm32-wasip1` | Was `wasm32-wasi`; that target was removed from rustc | | 0.2 | component, `wasi:*@0.2.x` interfaces | `wasm32-wasip2` | Streams via `wasi:io` | | 0.3 | component, `wasi:*@0.3.x` interfaces | `wasm32-wasip3` | Native `async`, `stream<T>`, `future<T>`; on by default in wasmtime 46+ |

# wasmtime detects module vs component and links the matching WASI version
wasmtime run hello-p1.wasm
wasmtime run hello-p3.wasm

# WASI options (components)
wasmtime run -S http component.wasm             # wasi:http outgoing requests
wasmtime run -S inherit-network component.wasm  # full host network for wasi:sockets
wasmtime run -S p3=n component.wasm             # disable WASIp3 interfaces

# Serve a wasi:http proxy component
wasmtime serve proxy.wasm

# Key WASI interfaces (WIT)
# wasi:filesystem, wasi:sockets, wasi:http, wasi:cli, wasi:random, wasi:clocks

WASI 0.3 was ratified in June 2026. It removes the `wasi:io` package; streams and futures are component-model types, and the canonical ABI lifts/lowers `async func` directly. Bindings generators (`wit-bindgen`, `wasmtime::component::bindgen!`) emit async functions for these.

3. Embedding wasmtime in Rust

# Cargo.toml — wasmtime and wasmtime-wasi versions must match
[dependencies]
wasmtime = "50"
wasmtime-wasi = "50"
anyhow = "1"
use wasmtime::*;
use wasmtime_wasi::p1::{self, WasiP1Ctx};
use wasmtime_wasi::{FsPerms, WasiCtxBuilder};

fn main() -> Result<()> {
    let engine = Engine::default();

    // Load and compile a module built for wasm32-wasip1
    let module = Module::from_file(&engine, "prog.wasm")?;

    // WASI imports are supplied through a Linker
    let mut linker: Linker<WasiP1Ctx> = Linker::new(&engine);
    p1::add_to_linker_sync(&mut linker, |ctx| ctx)?;

    // WASI context: stdio, env, args, preopened directory
    let wasi = WasiCtxBuilder::new()
        .inherit_stdio()
        .inherit_env()
        .args(&["prog.wasm", "arg1"])
        .preopened_dir("/tmp", "/", FsPerms::ReadWrite)?
        .build_p1();

    // The store holds all instance state
    let mut store = Store::new(&engine, wasi);
    let instance = linker.instantiate(&mut store, &module)?;

    // Run the WASI command entry point
    let start = instance.get_typed_func::<(), ()>(&mut store, "_start")?;
    start.call(&mut store, ())?;
    Ok(())
}

A module without imports can use `Instance::new(&mut store, &module, &[])` directly. A module that imports WASI fails to instantiate that way.

4. Fuel metering — CPU limiting

Fuel metering limits the work a guest can do, stopping runaway or malicious code:

use wasmtime::*;

let mut config = Config::new();
config.consume_fuel(true);    // enable fuel consumption

let engine = Engine::new(&config)?;
let module = Module::from_file(&engine, "untrusted.wasm")?;

let mut store = Store::new(&engine, ());
store.set_fuel(1_000_000)?;

let instance = Instance::new(&mut store, &module, &[])?;
let run = instance.get_typed_func::<(), ()>(&mut store, "run")?;

match run.call(&mut store, ()) {
    Ok(()) => println!("Completed, fuel remaining: {}", store.get_fuel()?),
    Err(e) if e.downcast_ref::<Trap>() == Some(&Trap:
Read more
@mohitmishra786
Ships withlow-level-dev-skills

A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.

Stars on GitHub

Momentum

stars in total
295
Star history of mohitmishra786/low-level-dev-skills on GitHub, a chart by star-history.com

Other skills on low-level-dev-skills.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills3w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc3w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2w252k
@facebook@facebookInstall Skill

Questions about wasm-wasmtime.

Which coding agents can use wasm-wasmtime?
wasm-wasmtime installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.