wasm-wasmtime
БесплатноБез исполняемых скриптовНе проверен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…
от mohitmishra786★ 307 звёзд на GitHubОб этом скилле
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.c
Установить wasm-wasmtime в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл wasm-wasmtime?
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.
Как установить скилл wasm-wasmtime?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл wasm-wasmtime запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic