Aller au contenu
Skillpedia
Programmation générale18k · #10720

wasm-expert

Ce qu’il fait

Cette skill guide la création de modules WebAssembly à partir de langages comme Rust et C, notamment WASI pour un usage serveur et l'intégration dans le navigateur. Elle s'adresse aux développeurs qui veulent un code portable et rapide dans les navigateurs ou sur des serveurs.

Quand l’utiliser

  • ✓Quand vous voulez exécuter du code Rust ou C dans une page web à une vitesse proche du natif.
  • ✓Quand vous avez besoin d'un module portable qui fonctionne sur un serveur grâce à WASI.
  • ✓Quand un fichier WebAssembly est trop volumineux et doit être réduit pour se charger dans le navigateur.

Lien du skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/wasm-expert/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/wasm-expert/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Compile ma fonction Rust de redimensionnement d'images en WebAssembly pour qu'elle fonctionne dans le navigateur, et garde le fichier aussi petit que possible.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

La skill couvre la compilation avec wasm-pack ou Cargo pour WASI, n'accorde que l'accès nécessaire à chaque module et réduit la taille du binaire grâce à des outils d'optimisation.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

WebAssembly Expert

A systems programmer and runtime specialist with deep expertise in WebAssembly compilation, WASI system interfaces, the component model, and browser integration. This skill provides guidance for compiling Rust, C, and other languages to WebAssembly, building portable server-side modules with WASI, designing composable components with WIT interfaces, and integrating Wasm modules into web applications with optimal performance.

Key Principles

  • WebAssembly provides a portable, sandboxed execution environment; leverage its security model by granting only the capabilities a module needs through explicit imports
  • Target wasm32-wasi for server-side and CLI applications that need file system, network, or clock access through the standardized WASI interface
  • Use the Component Model and WIT (WebAssembly Interface Types) for language-agnostic module composition; components communicate through typed interfaces, not raw memory
  • Optimize Wasm binary size aggressively for browser delivery; every kilobyte matters for initial load time, so strip debug info, use wasm-opt, and enable LTO
  • Understand linear memory: Wasm modules operate on a flat byte array that grows but never shrinks; design data structures and allocation patterns accordingly

Techniques

  • Compile Rust to Wasm with wasm-pack for browser targets (wasm-pack build --target web) or cargo build --target wasm32-wasi for server-side WASI modules
  • Use wasm-bindgen to expose Rust functions to JavaScript and import JS APIs into Rust; annotate public functions with #[wasm_bindgen] and use JsValue for dynamic interop
  • Define component interfaces in WIT files specifying exports (functions the component provides) and imports (functions the component requires from the host)
  • Compose multiple Wasm components using wasm-tools compose, linking one component's imports to another's exports without source-level dependencies
  • Optimize binaries with wasm-opt -Oz for size or -O3 for speed; use wasm-tools strip to remove custom sections and debug information for production builds
  • Instantiate modules in the browser with WebAssembly.instantiateStreaming(fetch("module.wasm"), importObject) for the fastest possible startup
  • Enable SIMD (Single Instruction, Multiple Data) for compute-intensive workloads by compiling with target features enabled and using explicit SIMD intrinsics or auto-vectorization

Common Patterns

  • Plugin Architecture: Host application loads untrusted Wasm plugins with restricted WASI capabilities; plugins export a known interface (defined in WIT) and cannot access resources beyond what the host provides
  • Polyglot Composition: Compile components from different languages (Rust, Go, Python) to Wasm components with WIT interfaces, then compose them into a single application using wasm-tools
  • Streaming Compilation: Use WebAssembly.compileStreaming to compile the module while it downloads; pair with instantiate for near-zero wait time after the network transfer completes
  • Memory-Mapped I/O: For large data processing in Wasm, share a linear memory region between the host and the module, passing pointers and lengths instead of copying data across the boundary

Pitfalls to Avoid

  • Do not assume all WASI APIs are available in every runtime; WASI Preview 2 is still being adopted, and different runtimes (Wasmtime, Wasmer, WasmEdge) support different subsets
  • Do not allocate memory freely without a strategy; Wasm linear memory grows in 64KB page increments and never releases pages back to the OS, so fragmentation accumulates over time
  • Do not pass complex data structures across the Wasm boundary by serializing to JSON; use shared linear memory with well-defined layouts or the component model's typed interface for efficiency
  • Do not skip testing on the target runtime; behavior differences exist between browser engines (V8, SpiderMonkey, JavaScriptCore) and server-side runtimes, especially for threading and SIMD
Questions fréquentes

Qu'est-ce que WASI ?

C'est un ensemble standard d'interfaces système qui permet aux modules WebAssembly d'utiliser les fichiers, le réseau ou les horloges de façon contrôlée.

Pourquoi réduire la taille du fichier ?

Les fichiers plus petits se chargent plus vite dans le navigateur, et la skill recommande de retirer les informations de débogage et d'optimiser le binaire.

Qu'est-ce que la mémoire linéaire ?

C'est le bloc de mémoire continu qu'un module WebAssembly utilise. Il peut grandir mais pas rétrécir, il faut donc prévoir cela dans les structures de données.

Détails

Description originale de l’auteur

WebAssembly expert for WASI, component model, Rust/C compilation, and browser integration

repo: RightNow-AI/openfang

Popularité

Étoiles GitHub
18k
Position au classement
#10720
Licence
Apache-2.0
Mis à jour
02/07/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires