rust-wasm-conventions

Installation
SKILL.md

Rust WebAssembly Conventions

Apply these conventions only when the project uses wasm-bindgen, wasm-pack, or targets wasm32-unknown-unknown. These rules are written for any coding agent, including Claude Code, Codex, Cursor, and Copilot.

Project Setup

  • Use wasm-pack for building, testing, and packaging.
  • Build with wasm-pack build.
  • Set the crate type to cdylib in Cargo.toml: crate-type = ["cdylib"].
  • Use wasm-bindgen as the primary bridge between Rust and JavaScript.

#[wasm_bindgen]

  • Annotate exported pub struct, pub enum, and impl blocks with #[wasm_bindgen].
  • Use #[repr(u8)] on enums exposed to JavaScript when compact single-byte representation is useful.
  • Expose constructors as pub fn new() -> Self inside a #[wasm_bindgen] impl block.
  • Keep functions intended only for Rust-side tests in impl blocks without #[wasm_bindgen].

JavaScript Interop and Memory

Installs
33
Repository
avbel/ai-skills
GitHub Stars
2
First Seen
May 16, 2026