Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Wasm Wasi Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-wasm-wasi-knowledge-patch)
---
name: wasm-wasi-knowledge-patch
description: WebAssembly / WASI
version: "Wasm 3.0 / WASI 0.3.0"
license: MIT
metadata:
author: Nevaberry
---
# WebAssembly / WASI Knowledge Patch
Load this skill when migrating WASI interfaces, working with async component
bindings, writing WIT, or checking core WebAssembly semantics and compatibility.
## Reference index
| Reference | Topics |
| --- | --- |
| [WASI interface migration](references/wasi-interface-migration.md) | Released WIT snapshot, mixed-version hosting, I/O replacements, sockets, HTTP, clocks, CLI, proposals, conformance tests |
| [Async Component Model](references/async-component-model.md) | Suspension, handle ownership, stream forwarding, read/write completion, bindings, Go HTTP bodies, toolchains |
| [WIT language and composition](references/wit-language.md) | Identifiers, comments, NaNs, packages, world inclusion, named instances, maps, feature adoption and compatibility |
| [Core WebAssembly](references/core-webassembly.md) | Evergreen specification, 64-bit memories and tables, exception dispatch, deterministic profile, text annotations |
## Interface migration: replacements first
### Replace the removed I/O package
WASI 0.3 has no `wasi:io` package. Apply these replacements:
| Previous API | Replacement |
| --- | --- |
| `pollable` and `subscribe()` | A future returned by the operation; await it for completion |
| `input-stream` | A returned `stream<u8>` |
| `output-stream` | A `stream<u8>` parameter |
### Update sockets and capabilities
Replace the 0.2 `start-foo` / `finish-foo` pair with one call.
TCP `connect` is an `async func`; `bind` and `listen` are plain functions.
Network access is granted at the world level. Remove the `network` resource
argument from bind, connect, and DNS lookup calls. Update socket imports to the
consolidated `types` and `ip-name-lookup` interfaces.
TCP `listen` returns a `stream<tcp-socket>` to consume for incoming connections.
### Update HTTP resources and worlds
`wasi:http` uses `request` and `response` resources, `stream<u8>` bodies, and a
future for trailers. The handler returns the response directly.
Move from `proxy` to `service` when exporting a handler. Use `middleware` when
the component also imports a handler.
Both worlds import `wasi:http/client` for outbound requests. A runtime can wire
the `middleware` world's imported `handler` directly to a downstream component
in the same process.
### Update clocks and shared CLI types
Change `wasi:clocks` imports from `wall-clock` to `system-clock` and use
`instant` in place of `datetime`.
Use `wasi:cli/types` for types shared among the CLI interfaces.
## Async calls, data, and completion
### Choose the call's suspension behavior
A plain `func` returning `future<T>` must return without blocking. The caller
can await that future later. Use `async func` when the call itself may need to
suspend before returning.
Streams and futures can cross component boundaries as values. An intermediary
can forward a stream without relaying wake-ups.
### Transfer ownership of async handles
WIT exposes `stream<T>` and `future<T>` only as owned handles. Passing either
across a component boundary transfers ownership.
### Read data and await status separately
Filesystem reads return a data stream and a terminal result future. You can
read part of the stream, drop it, and still await terminal status.
```wit
read-via-stream: func(offset: filesize) -> tuple<stream<u8>, future<result<_, error-code>>>;
```
Stdin, TCP receive, and directory listing operations also return separate
streams and futures.
### Pass a stream to a write operation
Pass the data stream into the operation and await the returned future for the
outcome after the host consumes the stream.
```wit
write-via-stream: func(data: stream<u8>) -> future<result<_, error-code>>;
```
Stdout, stderr, filesystem writes, and TCP sends use this pattern.
## Hosting and binding compatibility
### Keep existing component imports
Existing 0.2 components can keep their 0.2 imports. A 0.3 runtime can implement
them with 0.3 primitives at the host boundary. `wasmtime serve` supports both
versions from the same executable by dispatching per component.
### Select supported tools
Use Wasmtime 46 or later; it enables WASI 0.3 and `component-model-async` by
default. Use `wkg` 0.15 or later to fetch the 0.3 packages.
Generate bindings with `wit-bindgen` 0.46 or later and its `async` feature.
Rust builds with `wit-bindgen` 0.58 require nightly because stable Rust bundles
an older `wasm-component-ld` that cannot link that 0.3 output.
Rust provides WASI 0.3 bindings in `wasip3`. Use jco's `preview3-shim` for
JavaScript hosts; jco's WASI 0.3 shim for Node.js is experimental. Most other
toolchains still target WASI 0.2.
For `componentize-go`, export
`func Handle(request *Request) Result[*Response, ErrorCode]` and write the
response body from a goroutine. The runtime parks the goroutine when a stream
write needs to wait and resumes it when the stream can accept data. The async
reference includes the response-construction example.
## WIT composition and compatibility
### Name interfaces and represent dictionaries
A component can use `implements` to import or export multiple instances of one
interface under distinct names. Use `map<K, V>` for an associative collection; it replaces the
`list<tuple<K, V>>` pattern for expressing a dictionary in WIT.
WASI WIT interfaces can use both features starting with 0.3.1. Runtimes and
toolchains must support both to be compatible with WASI 0.3.1 or later.
### Account for cumulative feature requirements
Runtimes and toolchains that implement a WASI version must support the ungated
Component Model features and every feature adopted through that version,
including features still unused by WASI APIs. WASI 0.3.1 adds required support
for `external-id` on plain-named interface imports and exports.
A stable WASI API marked `@since` can depend on a gated Component Model feature
only after WASI Subgroup adoption. Use unadopted features in prerelease versions
or proposals that have yet to ship in a stable WASI release.
### Compose packages and worlds
A package can span `.wit` files in one directory. One file can declare the
package ID for the directory; multiple declarations must agree on namespace,
name, and version. Interfaces can refer to types declared in peer files.
A qualified world path in `include` inherits both imports and exports from
another package.
### Preserve numeric representation when needed
WIT exposes one logical NaN for `f32` and `f64`. Use an integer representation
when exact IEEE 754 NaN bits must survive a component boundary.
## Core WebAssembly quick reference
Memories and tables can declare `i64` as their address type. On the web, each
64-bit memory is capped at 16 GiB.
Exception handlers are blocks with dispatch lists mapping tags to branch
labels; they can specify a catch-all label. Tags declare payload types passed
to their matching handlers.
Engines implementing the deterministic profile use prescribed behavior for
otherwise nondeterministic instruction results, including generated
floating-point NaNs and relaxed SIMD edge cases.
Text annotations are analogous to binary custom sections. Downstream standards
can define their meaning, and a Wasm implementation can ignore them.
The W3C Candidate Recommendation Draft is updated in place for subsequent
language versions; the upstream specification includes the latest corrections.
## Proposal and conformance checks
Phase 2 proposals must publish WIT in an OCI registry and document portability
criteria. Timezone conversion and outbound HTTP 1xx response handling are
separate Phase 2 proposals for Clocks and HTTP.
Use `wasi-testsuite` to test WASI 0.1 and 0.3 interfaces across runtimes. Its
runner provides adapters for Wasmtime, jco, and WAMR, among others.