wasm-expert
Skill này làm gì
Skill này hướng dẫn xây dựng module WebAssembly từ các ngôn ngữ như Rust và C, gồm WASI cho máy chủ và tích hợp với trình duyệt. Skill dành cho lập trình viên muốn mã di động và nhanh trên trình duyệt hoặc máy chủ.
Khi nào nên dùng
- ✓Khi bạn muốn chạy mã Rust hoặc C bên trong trang web với tốc độ gần bằng mã gốc.
- ✓Khi bạn cần một module di động chạy được trên máy chủ thông qua WASI.
- ✓Khi một file WebAssembly quá lớn và cần được thu nhỏ để trình duyệt tải nhanh hơn.
Liên kết skill
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/wasm-expert/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy biên dịch hàm thay đổi kích thước ảnh bằng Rust của tôi sang WebAssembly để nó chạy trong trình duyệt, và giữ file nhỏ nhất có thể.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill bao gồm việc build bằng wasm-pack hoặc Cargo cho WASI, chỉ cấp quyền truy cập mà module cần, và giảm kích thước file nhị phân bằng công cụ tối ưu hóa.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
WASI là gì?
Đó là tập giao diện hệ thống chuẩn, cho phép module WebAssembly dùng file, mạng hoặc đồng hồ một cách có kiểm soát.
Vì sao phải làm file nhỏ hơn?
File nhỏ tải nhanh hơn trên trình duyệt, và skill khuyến nghị loại bỏ thông tin gỡ lỗi cùng tối ưu file nhị phân.
Linear memory là gì?
Đó là khối bộ nhớ phẳng mà module WebAssembly dùng, có thể mở rộng nhưng không thu nhỏ lại, nên cách bố trí dữ liệu cần tính đến điều đó.
Chi tiết
Mô tả gốc của tác giả
WebAssembly expert for WASI, component model, Rust/C compilation, and browser integration
repo: RightNow-AI/openfang
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10720
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/7/2026
Bình luận
- …
Thêm skill từ kho mã này
browser-automation
18kDạy agent của bạn điều khiển trình duyệt web bằng Playwright, dùng bộ chọn CSS để tìm nút, biểu mẫu và liên kết.
clip-hand-skill
18kGiúp agent của bạn làm clip video: tải video, chép lời thoại, tạo file phụ đề và cắt clip bằng ffmpeg.
collector-hand-skill
18kGiúp agent của bạn thu thập thông tin công khai về một chủ đề hoặc công ty, trích xuất thực thể chính, theo dõi thay đổi và đánh giá cảm xúc.
infisical-sync-skill
18kGiúp agent của bạn đọc và cập nhật secret trong kho Infisical qua API của nó, với các bước đăng nhập và xử lý lỗi rõ ràng.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.