Wasm bindings is an AI agent skill from the GitHub repository Goldziher/ai-rulez. wasm-bindgen and wasm-pack: JS interop types, Result<T, JsValue> errors, browser and Node targets, async futures, bundle size, generated .d.ts. Use when writing or reviewing WebAssembly bindings.
Claude Code: save it as .claude/skills/wasm-bindings/SKILL.md
Cursor: save it as .cursor/rules/wasm-bindings.md
Codex: save it as .agents/skills/wasm-bindings/SKILL.md
ChatGPT, Gemini and other assistants: paste it into custom or project instructions
Skill file
Use wasm-bindgen for JavaScript interop. Use wasm-pack for building and packaging.
Map Rust types to JS with #[wasm_bindgen]. Use JsValue for dynamic types, typed wrappers for known types.
Handle errors with Result<T, JsValue>. Convert Rust errors to descriptive JS error messages.
Support both browser (ES modules) and Node.js (CommonJS/ESM) targets.
Async: use wasm-bindgen-futures for Promise-returning functions. Never block the main thread.
Bundle size: use opt-level = "z", lto = true, codegen-units = 1 in release profile.
Use web-sys and js-sys for Web API access. Feature-gate platform-specific APIs.
Test with wasm-pack test --headless --firefox and a JS test runner (e.g., Vitest or Jest) for JS integration tests.
Generate TypeScript definitions automatically. Keep .d.ts files in sync with Rust exports.
Anti-patterns: no std::thread (single-threaded), no synchronous I/O, no panics (becomes JS exception).
Use this skill with your AI agent:Open on Skill Issue to copy, download, or add to your library.
Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.