WebAssembly Engineering
Use this skill for the boundary between a WebAssembly artifact and the host that
loads, instantiates, calls, grants authority to, packages, or deploys it. Treat
the exact core module/component, host, runtime release, backend, target, and
capability implementation as one compatibility and security decision.
Do not infer support, portability, isolation, performance, or authority from a
.wasm suffix, successful local build, core validation, a WASI name, or a
runtime's general marketing claim.
Scope and routing
This skill owns:
- Wasm binary and WAT text artifacts, core imports/exports, and embedding
boundaries;
- WASI profile and import selection; WIT packages/worlds; Component Model and
Canonical ABI compatibility;
- host/guest contract shape, values, linear memory, ownership, serialization,
resource handles, lifecycle, traps, exit/error mapping, and resource limits;
- runtime/backend/OS/CPU/AOT-or-JIT/browser target evidence, packaging, and
deployment validation; and
- capability grants and the host implementation of filesystem, network,
environment, clock, random, process, browser, and download surfaces.
Source-language, compiler, package-manager, binding-generator implementation,
and framework mechanics remain with the matching language/framework skill. For
example, Rust ownership, Cargo, wasm-bindgen, generated Rust bindings, and
Rust-target implementation belong to rust-engineering,
rust-async-web, and
rust-testing-quality as applicable. This
skill defines the host/guest and target evidence those implementations must meet;
it does not replace their source-level guidance.
Use api-design for a published service, SDK, CLI, or
event contract beyond the host/guest boundary. Use
documentation-engineering for
reader-facing documentation after the contract is settled. Use
ci-release-engineering for checked-in
release automation and container-engineering
for OCI/Compose implementation.
Mandatory executable-input gate
Treat modules, components, runtimes, toolchains, compilers, bindgen/component
composers, generated bindings, packages, registries, downloaded artifacts, host
integration code, and browser-delivered Wasm as untrusted executable
supply-chain inputs. Before downloading, installing, generating, loading,
instantiating, compiling, testing, or otherwise executing any such input:
- Load
dependency-supply-chain-review,
security-review, and
security-review-evidence.
- Inspect repository policy and use static evidence first: origin, immutable
version or revision, digest/signature/provenance where available, manifest and
lockfile state, generated/vendored diff, transitive native/build inputs, and
intended host integration.
- Identify every proposed effect: filesystem writes and reads, network egress,
inherited environment/credentials, subprocesses, executable memory, browser
origin/storage/downloads, caches, and artifact locations. Authorization to
run a command does not contain its transitive effects.
- Obtain the required execution authority and use isolation appropriate to the
repository trust decision. If provenance, security review, evidence handling,
authority, or isolation is unresolved, stop before execution and report the
blocked evidence.
This gate also applies to an apparently passive browser flow: fetching,
streaming, compiling, instantiating, or downloading Wasm crosses delivery and
execution boundaries. Do not treat a lockfile, checksum, typed binding, browser
sandbox, or runtime validation as a complete trust or isolation claim.
Repository-first workflow
- Inspect the repository's manifests, lockfiles, artifact build/package paths,
host embedding code, WIT/WAT/Wasm assets, target configuration, tests,
deployment descriptors, CI, runtime pin, and existing capability policy.
Preserve unrelated changes.
- Classify the artifact precisely: core module or component; WAT source or
binary; selected core features; exported/imported functions; for components,
Component Model/Canonical ABI generation plus WIT package versions and world.
- Define the host/guest contract before changing code. Name each import/export,
value and serialization representation, linear-memory allocation and
ownership rule, string/list encoding, resource-handle lifetime, reentrancy
constraint, trap versus recoverable error behavior, start/initialize/stop
sequence, cancellation, and resource quota.
- Start from no authority. Derive required capabilities from actual imports or
the selected WIT world, then grant only explicit, bounded host capabilities.
Record the implementation and limits, not merely an interface name.
- Select an artifact form, runtime, backend, and target using the repository's
requirements plus current official, versioned evidence. Read
the target and runtime selection evidence workflow
when selecting or asserting support for a runtime, target, component/WASI
line, browser delivery, AOT/JIT mode, or deployment host. It is not a product
matrix and cannot prove an unrecorded combination.
- Design tests at the lowest useful boundary: import/export and WIT contract
tests, invalid/oversized memory and serialization cases, trap/error mapping,
denied-capability behavior, lifecycle cleanup, resource-limit exhaustion, and
exact target-host smoke tests. Do not use a different runtime, backend, or
browser as compatibility proof.
- Package only the reviewed artifact and its declared metadata. Record artifact
identity, producer/toolchain/runtime versions, WIT world/ABI/WASI profile,
target, capability policy, delivery integrity requirements, and rollback or
compatibility fallback. Validate deployment in the intended target environment
after the executable-input gate is satisfied.
Capability boundaries
Every host capability is a security boundary owned by the embedding and
deployment policy, not by core Wasm validation.
- Filesystem: use explicitly scoped/preopened paths, an explicit symlink and
path-race policy, access modes, quotas, and cleanup ownership. A guest path is
never proof of host containment.
- Network and HTTP: define allowed schemes, destinations, ports, DNS/redirect
behavior, proxy rules, credentials, request/response limits, timeouts, and
egress enforcement. An imported socket or HTTP interface is not ambient
network authority.
- Environment, process, clocks, and randomness: allowlist environment values;
explicitly map stdin/stdout/stderr and exit semantics; define process-spawn
policy; provide intentional clock/random sources; never pass ambient host
credentials by default.
- Browser and download delivery: origin, CORS, Content-Type, CSP, integrity,
caching, storage, worker/thread availability, user-visible downloads, and
browser APIs are separate host constraints. Bare browser Wasm does not imply
WASI or Component Model support.
- Custom imports: version, authenticate, authorize, bound, and test each host
function as an application API. Keep guest-controlled lengths, pointers,
handles, callbacks, and serialized values validated at the host boundary.
Load security-review and security-review-evidence for these boundaries even
when a task does not execute artifacts; load threat-modeling when designing a
new authority model, untrusted-code boundary, plugin model, or sensitive data
flow.
Contract and lifecycle rules
- Prefer WIT worlds/components when an independently versioned interface and
Canonical ABI are the intended portable boundary; use a core-module import ABI
only when the selected host documents and tests that boundary.
- Pin WIT package versions, selected world, Component Model/Canonical ABI line,
WASI profile, and producer/consumer releases together. A matching
.wasm
extension does not make components and core modules interchangeable.
- Make ownership explicit across linear memory and lifting/lowering boundaries:
who allocates, who frees, when borrowed data expires, maximum sizes, alignment,
invalid pointer/length behavior, and how handles become invalid.
- Choose a serialization contract deliberately. Specify encoding, schema/version
negotiation, bounds, canonicalization where needed, and failure behavior; do
not pass opaque guest-controlled bytes into trusted host APIs unvalidated.
- Separate expected guest errors from traps, cancellation, timeout, host failure,
fuel/epoch/resource exhaustion, and process exit. Map each to an observable,
safe host result and ensure cleanup is idempotent.
- Specify instantiation, initialization, call concurrency/reentrancy, shutdown,
restart, and resource-release ownership. Do not assume dropping a host handle
rolls back external effects or terminates guest-spawned work.
Completion evidence
Before handoff, report:
- artifact form, core features, WIT world/package versions, ABI and WASI profile;
- exact host/runtime/backend/toolchain and OS/CPU/target evidence, plus every
unresolved support claim;
- capability grants, implementation limits, and the corresponding security
review/evidence status, using sanitized details only;
- supply-chain/provenance review status for every executable/download/generator
surface and whether any execution was intentionally blocked or skipped;
- contract, denial, error/trap, lifecycle, resource-limit, and intended-target
test results; and
- packaging/deployment identity, delivery controls, rollback/fallback plan, and
residual runtime, host, browser, or proposal risk.
Never turn missing versioned host evidence into a portability, sandboxing, or
security guarantee.
1---2name: webassembly-engineering3description: WebAssembly engineering guidance for Wasm/WAT modules, WASI, WIT and the Component Model, host/guest contracts, runtime and target selection, capability grants, memory/ABI/serialization, lifecycle/errors, testing, packaging, and deployment. Use when a WebAssembly artifact, host embedding, runtime, component, or WASI boundary is being designed, changed, tested, reviewed, packaged, or deployed. Do not use for source-language/compiler mechanics, generic dependency work without a Wasm boundary, or a product comparison without repository and current-doc evidence.4---56# WebAssembly Engineering78Use this skill for the boundary between a WebAssembly artifact and the host that9loads, instantiates, calls, grants authority to, packages, or deploys it. Treat10the exact core module/component, host, runtime release, backend, target, and11capability implementation as one compatibility and security decision.1213Do not infer support, portability, isolation, performance, or authority from a14`.wasm` suffix, successful local build, core validation, a WASI name, or a15runtime's general marketing claim.1617## Scope and routing1819This skill owns:2021- Wasm binary and WAT text artifacts, core imports/exports, and embedding22 boundaries;23- WASI profile and import selection; WIT packages/worlds; Component Model and24 Canonical ABI compatibility;25- host/guest contract shape, values, linear memory, ownership, serialization,26 resource handles, lifecycle, traps, exit/error mapping, and resource limits;27- runtime/backend/OS/CPU/AOT-or-JIT/browser target evidence, packaging, and28 deployment validation; and29- capability grants and the host implementation of filesystem, network,30 environment, clock, random, process, browser, and download surfaces.3132Source-language, compiler, package-manager, binding-generator implementation,33and framework mechanics remain with the matching language/framework skill. For34example, Rust ownership, Cargo, `wasm-bindgen`, generated Rust bindings, and35Rust-target implementation belong to [`rust-engineering`](../rust-engineering/SKILL.md),36[`rust-async-web`](../rust-async-web/SKILL.md), and37[`rust-testing-quality`](../rust-testing-quality/SKILL.md) as applicable. This38skill defines the host/guest and target evidence those implementations must meet;39it does not replace their source-level guidance.4041Use [`api-design`](../api-design/SKILL.md) for a published service, SDK, CLI, or42event contract beyond the host/guest boundary. Use43[`documentation-engineering`](../documentation-engineering/SKILL.md) for44reader-facing documentation after the contract is settled. Use45[`ci-release-engineering`](../ci-release-engineering/SKILL.md) for checked-in46release automation and [`container-engineering`](../container-engineering/SKILL.md)47for OCI/Compose implementation.4849## Mandatory executable-input gate5051Treat modules, components, runtimes, toolchains, compilers, bindgen/component52composers, generated bindings, packages, registries, downloaded artifacts, host53integration code, and browser-delivered Wasm as untrusted executable54supply-chain inputs. Before downloading, installing, generating, loading,55instantiating, compiling, testing, or otherwise executing any such input:56571. Load [`dependency-supply-chain-review`](../dependency-supply-chain-review/SKILL.md),58 [`security-review`](../security-review/SKILL.md), and59 [`security-review-evidence`](../security-review-evidence/SKILL.md).602. Inspect repository policy and use static evidence first: origin, immutable61 version or revision, digest/signature/provenance where available, manifest and62 lockfile state, generated/vendored diff, transitive native/build inputs, and63 intended host integration.643. Identify every proposed effect: filesystem writes and reads, network egress,65 inherited environment/credentials, subprocesses, executable memory, browser66 origin/storage/downloads, caches, and artifact locations. Authorization to67 run a command does not contain its transitive effects.684. Obtain the required execution authority and use isolation appropriate to the69 repository trust decision. If provenance, security review, evidence handling,70 authority, or isolation is unresolved, stop before execution and report the71 blocked evidence.7273This gate also applies to an apparently passive browser flow: fetching,74streaming, compiling, instantiating, or downloading Wasm crosses delivery and75execution boundaries. Do not treat a lockfile, checksum, typed binding, browser76sandbox, or runtime validation as a complete trust or isolation claim.7778## Repository-first workflow79801. Inspect the repository's manifests, lockfiles, artifact build/package paths,81 host embedding code, WIT/WAT/Wasm assets, target configuration, tests,82 deployment descriptors, CI, runtime pin, and existing capability policy.83 Preserve unrelated changes.842. Classify the artifact precisely: core module or component; WAT source or85 binary; selected core features; exported/imported functions; for components,86 Component Model/Canonical ABI generation plus WIT package versions and world.873. Define the host/guest contract before changing code. Name each import/export,88 value and serialization representation, linear-memory allocation and89 ownership rule, string/list encoding, resource-handle lifetime, reentrancy90 constraint, trap versus recoverable error behavior, start/initialize/stop91 sequence, cancellation, and resource quota.924. Start from no authority. Derive required capabilities from actual imports or93 the selected WIT world, then grant only explicit, bounded host capabilities.94 Record the implementation and limits, not merely an interface name.955. Select an artifact form, runtime, backend, and target using the repository's96 requirements plus current official, versioned evidence. Read97 [the target and runtime selection evidence workflow](references/target-runtime-selection.md)98 when selecting or asserting support for a runtime, target, component/WASI99 line, browser delivery, AOT/JIT mode, or deployment host. It is not a product100 matrix and cannot prove an unrecorded combination.1016. Design tests at the lowest useful boundary: import/export and WIT contract102 tests, invalid/oversized memory and serialization cases, trap/error mapping,103 denied-capability behavior, lifecycle cleanup, resource-limit exhaustion, and104 exact target-host smoke tests. Do not use a different runtime, backend, or105 browser as compatibility proof.1067. Package only the reviewed artifact and its declared metadata. Record artifact107 identity, producer/toolchain/runtime versions, WIT world/ABI/WASI profile,108 target, capability policy, delivery integrity requirements, and rollback or109 compatibility fallback. Validate deployment in the intended target environment110 after the executable-input gate is satisfied.111112## Capability boundaries113114Every host capability is a security boundary owned by the embedding and115deployment policy, not by core Wasm validation.116117- **Filesystem:** use explicitly scoped/preopened paths, an explicit symlink and118 path-race policy, access modes, quotas, and cleanup ownership. A guest path is119 never proof of host containment.120- **Network and HTTP:** define allowed schemes, destinations, ports, DNS/redirect121 behavior, proxy rules, credentials, request/response limits, timeouts, and122 egress enforcement. An imported socket or HTTP interface is not ambient123 network authority.124- **Environment, process, clocks, and randomness:** allowlist environment values;125 explicitly map stdin/stdout/stderr and exit semantics; define process-spawn126 policy; provide intentional clock/random sources; never pass ambient host127 credentials by default.128- **Browser and download delivery:** origin, CORS, Content-Type, CSP, integrity,129 caching, storage, worker/thread availability, user-visible downloads, and130 browser APIs are separate host constraints. Bare browser Wasm does not imply131 WASI or Component Model support.132- **Custom imports:** version, authenticate, authorize, bound, and test each host133 function as an application API. Keep guest-controlled lengths, pointers,134 handles, callbacks, and serialized values validated at the host boundary.135136Load `security-review` and `security-review-evidence` for these boundaries even137when a task does not execute artifacts; load `threat-modeling` when designing a138new authority model, untrusted-code boundary, plugin model, or sensitive data139flow.140141## Contract and lifecycle rules142143- Prefer WIT worlds/components when an independently versioned interface and144 Canonical ABI are the intended portable boundary; use a core-module import ABI145 only when the selected host documents and tests that boundary.146- Pin WIT package versions, selected world, Component Model/Canonical ABI line,147 WASI profile, and producer/consumer releases together. A matching `.wasm`148 extension does not make components and core modules interchangeable.149- Make ownership explicit across linear memory and lifting/lowering boundaries:150 who allocates, who frees, when borrowed data expires, maximum sizes, alignment,151 invalid pointer/length behavior, and how handles become invalid.152- Choose a serialization contract deliberately. Specify encoding, schema/version153 negotiation, bounds, canonicalization where needed, and failure behavior; do154 not pass opaque guest-controlled bytes into trusted host APIs unvalidated.155- Separate expected guest errors from traps, cancellation, timeout, host failure,156 fuel/epoch/resource exhaustion, and process exit. Map each to an observable,157 safe host result and ensure cleanup is idempotent.158- Specify instantiation, initialization, call concurrency/reentrancy, shutdown,159 restart, and resource-release ownership. Do not assume dropping a host handle160 rolls back external effects or terminates guest-spawned work.161162## Completion evidence163164Before handoff, report:1651661. artifact form, core features, WIT world/package versions, ABI and WASI profile;1672. exact host/runtime/backend/toolchain and OS/CPU/target evidence, plus every168 unresolved support claim;1693. capability grants, implementation limits, and the corresponding security170 review/evidence status, using sanitized details only;1714. supply-chain/provenance review status for every executable/download/generator172 surface and whether any execution was intentionally blocked or skipped;1735. contract, denial, error/trap, lifecycle, resource-limit, and intended-target174 test results; and1756. packaging/deployment identity, delivery controls, rollback/fallback plan, and176 residual runtime, host, browser, or proposal risk.177178Never turn missing versioned host evidence into a portability, sandboxing, or179security guarantee.