Token导航 LogoToken导航

Agent Skill · 前端设计

webassembly-component-development(WebAssembly 组件开发)

webassembly-component-development 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

webassembly-component-development 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 5,784。

总安装 606周安装 25GitHub Stars 16下载 198核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:webassembly-component-development(WebAssembly 组件开发)
来源仓库:https://github.com/cosmonic-labs/skills
仓库路径:skills/webassembly-component-development
安装命令:
npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-component-development
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-component-development

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

组件模型支持与语言无关的可组合 WebAssembly 应用程序 WASI 0.2 (wasip2) 是具有完整网络和 UTF-8 保证的当前标准 设计粗粒度接口以获得更好的性能 尽早并经常在目标运行时进行测试 使用清洗构建 对于 wasmCloud 项目 - 自动处理兼容性 记录运行时要求并维护兼容性矩阵 每周安装量 25 存储库 宇宙实验室/技能 GitHub 之星 16 第一次看到 4 天前 安全审计 Gen Agent Trust Hub 通行证 套接字通行证 斯尼克通行证

来源仓库内路径:skills/webassembly-component-development

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-compo…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

webassembly-component-development 怎么安装?

在终端执行 npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-component-devel…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

webassembly-component-development 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

webassembly-component-development 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-component-development 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

webassembly-component-development 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

webassembly-component-development 用的人多吗?

公开数据是累计安装 606 次,近一周安装 25 次,下载 198 次,GitHub 16 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

webassembly-component-development 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
webassembly-component-development

WebAssembly 组件开发 · 本页

60616执行命令未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

WebAssembly Component Development

This skill provides comprehensive expertise in developing WebAssembly components, including WASI fundamentals, composition patterns, runtime compatibility, and troubleshooting.


Part 1: Core Concepts

What is the Component Model?

The WebAssembly Component Model enables:

  • Combining multiple components into a single application
  • Using libraries written in one language from another language
  • Building modular, reusable WebAssembly modules
  • Creating component graphs with defined dependencies

Benefits

  1. Language Interoperability: Use the best language for each task
  2. Code Reuse: Share components across projects
  3. Modularity: Clear boundaries and interfaces
  4. Independent Development: Teams can work on different components
  5. Type Safety: WIT ensures type-safe composition

WASI (wasip2)

The current WASI standard targets wasm32-wasip2 (Rust 1.82+ tier-2 target):

  • Full Component Model support
  • Native networking via wasi:http and wasi:sockets
  • UTF-8 guaranteed string encoding
  • Async via tokio (1.50+) or wstd; WASIp3 (0.3) adds native async (experimental)

Part 2: Component Composition

Composition Patterns

1. Simple Dependency

One component depends on another component's interface.

// component-a/wit/world.wit
package example:component-a;

interface math {
    add: func(a: s32, b: s32) -> s32;
}

world component-a {
    export math;
}
// component-b/wit/world.wit
package example:component-b;

world component-b {
    import example:component-a/math;
    export calculate: func(x: s32, y: s32) -> s32;
}
2. Adapter Pattern

Adapting one interface to another for compatibility.

world adapter {
    import old-api/interface;
    export new-api/interface;
}
3. Middleware Pattern

Components that intercept and process data between other components.

world http-logger {
    import wasi:http/incoming-handler;
    export wasi:http/outgoing-handler;
    // Logs all HTTP requests/responses
}
4. Facade Pattern

Single component providing simplified access to multiple components.

world application-facade {
    import database/client;
    import cache/client;
    import auth/service;
    export api/handler;
}

Designing Component Boundaries

Good Boundaries:

  • Clear, well-defined responsibilities
  • Minimal coupling between components
  • Coarse-grained interfaces (fewer, larger operations)
  • Domain-aligned (matches business/technical domains)
// Good: Clear, focused interface
interface user-service {
    create-user: func(name: string, email: string) -> result<user-id, error>;
    get-user: func(id: user-id) -> result<user, error>;
    update-user: func(id: user-id, updates: user-updates) -> result<_, error>;
}

Poor Boundaries (Anti-patterns):

  • Too fine-grained (many small operations)
  • Tight coupling (components know too much about each other)
  • Chatty interfaces (many back-and-forth calls)
// Bad: Too fine-grained, chatty interface
interface user-service {
    set-user-name: func(id: user-id, name: string);
    get-user-name: func(id: user-id) -> string;
    set-user-email: func(id: user-id, email: string);
    get-user-email: func(id: user-id) -> string;
}

Building Components

If the project has a .wash/config.yaml, use wash to build and develop:

wash build              # Build a valid WebAssembly component
wash dev                # Development with hot-reload
wash build --skip-fetch

wash build automatically:

  • Compiles to the correct wasm32-wasip2 target
  • Handles WIT dependency fetching and binding generation
  • Respects .wash/config.yaml build configuration

For non-wash projects, you can target wasip2

cargo build --target wasm32-wasip2 --release

Composition Tools

wac (WebAssembly Composition)

A modern composition tool using a declarative .wac language:

# Install wac
cargo install wac-cli

# Quick plug: wire one component's exports into another's imports
wac plug component-a.wasm --plug component-b.wasm -o composed.wasm

# Or use a .wac composition file for complex graphs
wac compose composition.wac -o composed.wasm
wasmCloud Composition

wasmCloud handles runtime linking automatically via wRPC over NATS. Components are wired together using link definitions and deployed via wash.

Build Configuration with.wash/config.yaml

For projects using wash, the .wash/config.yaml file in the project root configures custom build commands:

# .wash/config.yaml
dev:
  command: make build

build:
  command: make bindgen build

This is useful for non-Rust projects (Go, TinyGo, etc.) or projects with custom build steps, controlling how wash build and wash dev invoke the build.


Part 3: Language Interoperability

Cross-Language Composition

Example: Python library used from Rust

// python-ml-lib/wit/world.wit
package ml:inference;

interface model {
    predict: func(features: list<float32>) -> list<float32>;
}

world ml-component {
    export model;
}
// Rust component using Python ML library
wit_bindgen::generate!({
    world: "app",
    path: "wit",
});

impl Guest for MyApp {
    fn process(data: Vec<f32>) -> Vec<f32> {
        ml::inference::model::predict(&data)
    }
}

Supported Languages

  • Rust - First-class support via wash build
  • Python - Via componentize-py
  • JavaScript/TypeScript - Via componentize-js (experimental, uses SpiderMonkey)
  • Go - Via TinyGo 0.33+ with native WASI P2 support, plus Go Component SDK
  • C/C++ - Via WASI SDK
  • C# - Experimental support

Language Compatibility Considerations

Data Types:

  • WIT provides common types that map to each language
  • Complex types (records, variants, lists) are automatically converted
  • Strings are always UTF-8

Performance:

  • Cross-language calls have overhead (serialization/deserialization)
  • Keep interfaces coarse-grained to minimize calls
  • Pass handles/resources instead of large data when possible

Error Handling:

  • Use WIT result types for cross-language error propagation
  • Each language maps result<T, E> to its native error handling

Part 4: WASI Gotchas

1. No Threading Support

Problem: Thread pool operations are unsupported on wasm32-wasip2.

Symptoms:

  • Panic with "operation not supported on this platform"
  • Libraries like rayon fail at runtime
  • Any code using std::thread::spawn fails

Solution:

  • Avoid libraries that require threading (check dependency trees)
  • Use single-threaded algorithms and data structures
  • Consider async/await patterns instead of threads

2. String/Encoding Issues

Problem: Unsafe assumptions about string encoding across platforms.

Key Facts:

  • OsStr from wasip2 is guaranteed to be valid UTF-8
  • Avoid as_encoded_bytes() - uses unspecified encoding
  • Conversion to str should almost never fail on wasip2
// Good: Safe UTF-8 handling
let path_str = path.to_str().expect("wasip2 guarantees UTF-8");

// Bad: Platform-specific encoding
let bytes = path.as_os_str().as_encoded_bytes(); // Don't do this!

3. Network Capabilities

Available WASI networking interfaces:

  • wasi:http - HTTP client and server APIs
  • wasi:sockets - Low-level socket APIs

Part 5: Async in WebAssembly Components

Tokio on wasip2

As of tokio 1.50+, tokio supports wasm32-wasip2 networking. This means you can use tokio's async runtime and networking APIs in WebAssembly components.

Requirements:

  • tokio 1.50+
  • Build with RUSTFLAGS="--cfg tokio_unstable" (required until stabilized)
# Cargo.toml
[dependencies]
tokio = { version = "1.50", features = ["rt", "net", "macros", "time", "io-util", "sync"] }
# Build with wash (tokio_unstable flag required)
RUSTFLAGS="--cfg tokio_unstable" wash build

What works on wasip2:

  • tokio::net::TcpListener, TcpStream — full async TCP networking
  • tokio::time — timers and delays
  • tokio::sync — channels, mutexes, etc.
  • tokio::io — async I/O utilities
  • Single-threaded runtime (rt feature)

What does NOT work yet:

  • tokio::net::lookup_host — DNS lookups require multithreading workaround
  • tokio::fs — async file I/O (may work with future WASIp3 threading)
  • Multi-threaded runtime (rt-multi-thread) — WASI has no threading support yet
  • tokio::process — no process spawning in WASI
#[tokio::main(flavor = "current_thread")]
async fn main() {
    let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
    loop {
        let (stream, _addr) = listener.accept().await.unwrap();
        tokio::spawn(async move {
            handle_connection(stream).await;
        });
    }
}

wstd

wstd is a lightweight, WebAssembly-native async standard library built specifically for WASI 0.2. It provides a minimal async runtime, HTTP, networking, and other APIs purpose-built for the Wasm component model.

# Cargo.toml
[dependencies]
wstd = "0.6"

When to use wstd over tokio:

  • You want a minimal, Wasm-native dependency with no tokio_unstable flag required
  • You need wstd::http client/server APIs (higher-level than raw TCP)
  • You want wstd::rand for random number generation in Wasm
  • You prefer a purpose-built Wasm library over a general-purpose runtime
ModulePurposeExample Types
wstd::httpHTTP client and serverClient, Server
wstd::ioAsync I/O abstractionsRead, Write traits
wstd::netAsync TCP networkingTcpListener
wstd::timeAsync time interfacesDuration, Instant
wstd::randRandom number generationthread_rng()
wstd::runtimeAsync event loopTask spawning
#[wstd::main]
async fn main() {
    let client = wstd::http::Client::new();
    let response = client.get("https://example.com").await.unwrap();
    println!("Status: {}", response.status());
}
#[wstd::http_server]
async fn handle(request: wstd::http::IncomingRequest) -> wstd::http::Response {
    wstd::http::Response::new(200, "Hello, World!")
}

Note: wstd defines its own I/O traits separate from tokio — do not mix wstd and tokio in the same component.


Part 6: Runtime Compatibility

Unknown Import Errors

The Most Common Error:

Error: instantiation failed: unknown import
component name: wasi:cli/environment@0.2.0

Root Causes:

  1. Runtime doesn't support WASI Preview 2
  2. Runtime doesn't implement that specific interface
  3. Version mismatch between component and runtime

Diagnosis:

# Check what your component imports
wasm-tools component wit your-component.wasm

# Try running and see what fails
wasmtime run component.wasm 2>&1 | grep "unknown import"

Solutions:

# Solution 1: Update runtime
cargo install wasmtime-cli --version 18.0.0

# Solution 2: Re-fetch WIT dependencies
wkg wit fetch

# Solution 3: Remove dependency on unsupported interface

Runtime-Specific Compatibility

wasmtime
  • Full WASI 0.2 support (stable)
  • WASI 0.3 (WASIp3) support is experimental — adds native async
wasmtime run component.wasm
wasmtime serve component.wasm                          # HTTP components
wasmtime serve -S cli component.wasm                   # Enable wasi:cli (env vars, filesystem, sockets, clocks)
wasmtime serve -S cli,inherit-network component.wasm   # Full host network access within the guest
wasmtime serve -S cli,allow-ip-name-lookup component.wasm # Enable wasi:sockets/ip-name-lookup
wasmtime serve -S p3 component.wasm                    # Enable WASIp3 (experimental)
wasmCloud
  • Full WASI 0.2 support in recent versions
  • Custom wasmCloud interfaces (wasmcloud:*)
  • wasmcloud:wash interface not published (use wash build --skip-fetch for plugins)
wash dev      # Development testing with hot-reload

Version Alignment Strategies

Strategy 1: Match Runtime Version

[dependencies]
wasi = "=0.14.0"  # Exact version matching runtime

Strategy 2: Use Conservative Interfaces

  • ✅ wasi:cli/environment
  • ✅ wasi:cli/stdin/stdout/stderr
  • ✅ wasi:filesystem (basic operations)
  • ⚠️ wasi:http (check runtime support)
  • ⚠️ wasi:sockets (not universally available)

Strategy 3: Feature Detection

#[cfg(feature = "wasi-http")]
mod http_impl { /* HTTP-specific code */ }

#[cfg(not(feature = "wasi-http"))]
mod http_impl { /* Fallback implementation */ }

Part 7: Testing Strategies

1. Lightweight Host Harness

use wasmtime::{Engine, Store, component::Component};

#[cfg(test)]
mod tests {
    #[test]
    fn test_component() -> Result<()> {
        let engine = Engine::default();
        let mut store = Store::new(&engine, ());
        let component = Component::from_file(&engine, "component.wasm")?;
        // Instantiate and test...
        Ok(())
    }
}

2. Mock Components

wit_bindgen::generate!({
    world: "mock-database",
    exports: {
        "database:client/query": MockDatabase,
    }
});

struct MockDatabase;

impl database::client::Query for MockDatabase {
    fn execute(query: String) -> Result<Vec<Row>, Error> {
        Ok(vec![/* test rows */])
    }
}

3. Integration Tests with wash

wash dev  # Start development environment
curl http://localhost:8080/api/test  # Test the component's HTTP interface

4. Feature Flags for Host-Specific Code

#[cfg(target_family = "wasm")]
mod wasm_impl {
    pub fn get_data() -> Vec<u8> {
        wasi::filesystem::read("/data/file.bin")
    }
}

#[cfg(not(target_family = "wasm"))]
mod native_impl {
    pub fn get_data() -> Vec<u8> {
        vec![1, 2, 3, 4] // Test data
    }
}

5. Environment Setup

use wasmtime_wasi::{WasiCtxBuilder, Dir};

#[test]
fn test_with_filesystem() -> Result<()> {
    let test_dir = tempfile::tempdir()?;
    std::fs::write(test_dir.path().join("test.txt"), "test data")?;

    let wasi = WasiCtxBuilder::new()
        .env("TEST_MODE", "true")?
        .preopened_dir(
            Dir::open_ambient_dir(test_dir.path(), ambient_authority())?,
            "/data",
        )?
        .build();

    // Test component...
    Ok(())
}

Part 8: Debugging

Debugging Workflow

  1. Check target compatibility: rustc --print target-list | grep wasi
  2. Fetch WIT dependencies: # WIT deps are fetched automatically by wash build # For manual management, use the wkg CLI wkg wit fetch
  3. Inspect component imports: wasm-tools component wit your-component.wasm
  4. Check for threading issues:

- Review dependencies for rayon, tokio (threaded), std::thread

Common Error Patterns

ErrorCauseSolution
"operation not supported on this platform"Threading issueRemove threaded dependencies
"unknown import: wasi:cli/..."Runtime doesn't support interfaceUpdate runtime or remove dependency
WIT version mismatchVersion conflictRe-fetch deps with wkg wit fetch or rebuild with wash build
Component instantiation failedAdapter/runtime incompatibilityCheck adapter version

Tools

# Inspect component structure
wasm-tools print component.wasm

# Extract WIT interfaces
wasm-tools component wit component.wasm

# Validate component
wasm-tools validate component.wasm

# Check component info (wasmCloud)
wash inspect component.wasm

Part 9: Performance Optimization

Minimize Cross-Component Calls

// Bad: Multiple fine-grained calls
let name = user_service.get_name(id)?;
let email = user_service.get_email(id)?;

// Good: Single coarse-grained call
let user = user_service.get_user(id)?;

Use Streaming for Large Data

interface data-processor {
    resource stream {
        read-chunk: func() -> option<list<u8>>;
    }
    process-stream: func(input: stream) -> result<_, error>;
}

Batch Operations

// Bad: Many individual calls
for item in items {
    database.insert(item)?;
}

// Good: Single batch operation
database.insert_batch(items)?;

Part 10: Best Practices

Documentation References

Development

  1. Use wash build when the project has .wash/config.yaml; otherwise use wasm-tools component new to produce a component
  2. Avoid Threading: Design for single-threaded execution
  3. Use UTF-8: Don't rely on platform-specific encodings
  4. Minimal Dependencies: Fewer dependencies = fewer WASI compatibility issues
  5. Test Early: Run components in target runtime during development
  6. Async options: Use tokio (1.50+, with --cfg tokio_unstable) or wstd for async in Wasm components

Component Design

  1. Single Responsibility: Each component should have one clear purpose
  2. Coarse-Grained Interfaces: Design for fewer, larger operations
  3. Version Your Interfaces: Use WIT package versioning
  4. Document Dependencies: Note which WASI interfaces your component needs

Runtime Compatibility

  1. Check Runtime Support: Verify WASI interfaces before using them
  2. Keep Tools Updated: Regularly update wash, wasmtime, and Rust
  3. Pin Versions in Production: Use exact versions for reproducibility
  4. Maintain Compatibility Matrix: Document supported runtimes

CI/CD

# .github/workflows/test.yml
- name: Test with wasmtime
  run: wasmtime run component.wasm

- name: Test with wasmCloud
  run: |
    wash build
    wash dev &
    # Run integration tests

Common Architecture Patterns

Microservices

world api-gateway {
    import user:service/handler;
    import order:service/handler;
    import payment:service/handler;
    export http:handler/incoming;
}

Plugin Architecture

world app-core {
    export plugin:host/register;
    export plugin:host/execute;
}

world plugin {
    import plugin:host/core-api;
    export plugin:interface/handler;
}

Data Pipeline

world data-pipeline {
    import source:reader/stream;
    import transform:processor/apply;
    import sink:writer/write;
    export pipeline:orchestrator/run;
}

Summary

  • Component Model enables language-agnostic, composable WebAssembly applications
  • WASI 0.2 (wasip2) is the current standard with full networking and UTF-8 guarantees
  • Design coarse-grained interfaces for better performance
  • Test in target runtime early and often
  • Use wash build for wasmCloud projects - handles compatibility automatically
  • Document runtime requirements and maintain compatibility matrices

平台分布

Codex

34.98%
按下载量换算69

Claude

30.27%
按下载量换算60

Cursor

19.79%
按下载量换算39

Gemini CLI

10.1%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/cosmonic-labs/skills --skill webassembly-component-development 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills