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 on queries about wasmtime, WASI, WASM component model, wasmtime embedding, WIT interfaces, fuel metering, or server-side WebAssembly.
What this skill does
# wasmtime — Server-Side WASM Runtime
## Purpose
Guide agents through wasmtime: running WASM modules from the CLI, WASI APIs, the component model with WIT interfaces, embedding wasmtime in Rust applications, fuel metering for sandboxed execution, and debugging WASM with DWARF debug info.
## Triggers
- "How do I run a WASM file with wasmtime?"
- "How does WASI work with wasmtime?"
- "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
```bash
# Install
curl https://wasmtime.dev/install.sh -sSf | bash
# Run a WASM module
wasmtime hello.wasm
# Run with WASI arguments
wasmtime prog.wasm -- arg1 arg2
# Pre-open directories (WASI filesystem sandbox)
wasmtime --dir /tmp::/ prog.wasm # map host /tmp to WASI root
# Pass environment variables
wasmtime --env HOME=/home/user prog.wasm
# Invoke specific exported function
wasmtime run --invoke add math.wasm 3 4
# Inspect exports
wasmtime explore math.wasm # interactive explorer
wasmtime inspect math.wasm # show all exports/imports
# Compile to native ahead-of-time
wasmtime compile prog.wasm -o prog.cwasm
wasmtime run prog.cwasm
```
### 2. WASI preview2 APIs
WASI preview2 provides a capability-based POSIX-like API set:
```bash
# wasmtime supports WASI p2 natively
wasmtime --wasi-modules experimental-wasi-http prog.wasm
# Key WASI interfaces (WIT)
# wasi:filesystem — file and directory access
# wasi:sockets — TCP/UDP networking (preview2)
# wasi:http — HTTP client/server (experimental)
# wasi:cli — stdin/stdout/stderr, environment
# wasi:random — secure random numbers
# wasi:clocks — system and monotonic clocks
```
### 3. Embedding wasmtime in Rust
```toml
# Cargo.toml
[dependencies]
wasmtime = "24"
wasmtime-wasi = "24"
anyhow = "1"
```
```rust
use wasmtime::*;
use wasmtime_wasi::WasiCtxBuilder;
fn main() -> anyhow::Result<()> {
// Create engine with default config
let engine = Engine::default();
// Load and compile WASM module
let module = Module::from_file(&engine, "prog.wasm")?;
// Set up WASI context
let wasi = WasiCtxBuilder::new()
.inherit_stdio()
.inherit_env()
.preopened_dir("/tmp", "/")?
.build();
// Create a store (holds WASM state)
let mut store = Store::new(&engine, wasi);
// Instantiate the module
let instance = Instance::new(&mut store, &module, &[])?;
// Call an exported function
let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?;
let result = add.call(&mut store, (3, 4))?;
println!("Result: {result}");
Ok(())
}
```
### 4. Fuel metering — CPU limiting
Fuel metering limits the number of WASM instructions executed, preventing runaway or malicious code:
```rust
use wasmtime::*;
let mut config = Config::default();
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)?; // allow 1M instructions
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.to_string().contains("all fuel consumed") => {
println!("Timed out (fuel exhausted)");
}
Err(e) => eprintln!("Error: {e}"),
}
```
### 5. Component model and WIT
The component model adds typed interface definitions (WIT) on top of core WASM:
```wit
// math.wit — interface definition
package example:[email protected];
interface calculator {
add: func(a: s32, b: s32) -> s32;
sqrt: func(x: f64) -> f64;
}
world math-world {
export calculator;
}
```
```bash
# Install component toolchain
cargo install wasm-tools cargo-component
# Create a Rust component
cargo component new --lib math-component
# Implement the WIT interface in src/lib.rs
# Build component
cargo component build --release
# Run with wasmtime component
wasmtime run math-component.wasm
```
```rust
// Embed a component in Rust
use wasmtime::component::*;
wasmtime::component::bindgen!({
world: "math-world",
path: "math.wit",
});
let component = Component::from_file(&engine, "math.wasm")?;
let (calculator, _) = MathWorld::instantiate(&mut store, &component, &linker)?;
let result = calculator.call_add(&mut store, 3, 4)?;
```
### 6. WASM debugging with DWARF
```bash
# Build WASM with debug info (Rust)
cargo build --target wasm32-wasi # debug profile includes DWARF by default
# Run with source-level debugging
WASMTIME_BACKTRACE_DETAILS=1 wasmtime prog.wasm
# Full DWARF stack traces
wasmtime --debug-info prog.wasm 2>&1
# GDB with WASM (wasmtime dev build)
wasmtime debug prog.wasm # experimental
# wasm-tools for inspection
wasm-tools print prog.wasm | head -50 # disassemble to WAT
wasm-tools validate prog.wasm # validate WASM binary
```
### 7. Performance configuration
```rust
// High-performance embedding config
let mut config = Config::default();
config.cranelift_opt_level(OptLevel::SpeedAndSize);
config.parallel_compilation(true);
config.cache_config_load_default()?; // disk cache for compiled modules
// Ahead-of-time compilation for production
// 1. Pre-compile in build pipeline
let serialized = module.serialize()?;
std::fs::write("prog.cwasm", &serialized)?;
// 2. Load pre-compiled at runtime (zero compilation cost)
let module = unsafe { Module::deserialize_file(&engine, "prog.cwasm")? };
```
## Related skills
- Use `skills/runtimes/wasm-emscripten` for compiling C/C++ to WASM for browser/WASI
- Use `skills/rust/rust-async-internals` for async patterns in wasmtime Rust embedding
- Use `skills/runtimes/binary-hardening` for sandboxing considerations with WASM
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.