Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

wit-interface-design

БесплатноБез исполняемых скриптовНе проверен

Design and review WIT (WebAssembly Interface Types) interfaces, worlds and packages so they are capability-scoped, async, virtualizable and portable. Use this…

cosmonic-labsот cosmonic-labs★ 22 звезды на GitHub

Об этом скилле

WIT Interface Design

Design the contract first, then write the code. A good WIT API reads as a capability grant: someone can look at a component's imports and know exactly what it is allowed to do. The rules below are modeled on the WASI 0.3.x proposals (wasi:cli, clocks, filesystem, http, random, sockets) and wasmcloud:[email protected].

Start with the four areas

Every component's contract has four parts. Settle each one before writing WIT.

Area Question Where it lives in WIT
Triggers What events, requests or streams start the component's work? Exports
Responses What does it return, and who owns the data? Return types, own vs borrow, stream / future
Side-effects What can it change outside itself? Imports, one per capability
Errors Which failures does it deliberately return? result<T, E> with a typed E

Every component is a reactor: each export is a reaction to something (handle a request, run, on-message). Design components as handlers that are given work, not scripts that fetch it. The world is the whole contract: exports say what starts it, imports say what it may do. Traps mean bugs or violated preconditions; expected failures belong in the signature.

A good WIT API is strictly decoupled (names a capability, not a vendor), virtualizable, mockable (a test double is just another component implementing the interface), and portable (maps cleanly to any language: no exceptions, callbacks, pointers, OS paths, or threads).

Core rules and why

Imports are grants. Write "the guest may ___" for every interface (resolve names, read the system clock, get-directories from preopens, reveal a secret). If the sentence needs "and", split the interface. This keeps least privilege auditable from the world alone. One capability per interface, named for the capability, not the implementation. See capability-grants.md.

One singular thing = a labeled import. To give a guest one secret, import db-password: wasmcloud:secrets/secret with get: async func() -> secret, not get(key: string). There is no key to forge, and the runtime can check the binding before instantiation. Also in capability-grants.md.

Import WASI; never reinvent it. Clocks, random, filesystem, sockets, name lookup, HTTP and stdio already exist. Reuse its interfaces and types (duration, ip-address) so grants stay legible and components stay interoperable. See capability-grants.md.

Keep interfaces granular. Split by independently grantable power (read vs write, lookup vs reveal, consumer vs producer). A guest that only needs one power shouldn't receive another.

Async by default. Declare async func unless the call is time-sensitive and must be sync (system-clock.now). Cheap is not a reason to be sync: changing sync to async later breaks every consumer. This applies to resource methods too.

Every API must be virtualizable. Design as if another guest component implements it, never "something the host provides". Document in terms of implementer and caller. Give the consumer and provider sides symmetric shapes (as wasi:http client.send and handler.handle) so components chain as middleware. See async-and-resources.md and http-derived-patterns.md.

Resources are singular nouns (descriptor, secret, tcp-socket). Collections are list<secret>. Consume-by-move for one-shot operations, and document parent/child lifetimes and mutability.

Open sets use variant + other; closed sets use enum. An enum can never gain a case without breaking consumers, so choose it only for sets you commit to never extending (ip-address-family). Otherwise end a variant with other(option<string>). See errors-and-enums.md.

Typed errors. Return result<T, E> where E names the failure modes callers can act on. A string payload is fine for detail; a bare string error is not. Model cases on an industry standard (IANA, RFC, POSIX) when one exists. See errors-and-enums.md.

Version for compatibility. @since on every interface; @deprecated instead of deleting; break only on a minor bump at 0.x or a major bump at 1.0+. See versioning.md.

Name consistently. Kebab-case, verb-first functions, get- / set- on resource accessors, shared types in an interface named types, uppercase acronyms only when required (DNS-error). Details, worlds, types and documentation in conventions.md.

Review checklist

  1. Can you state triggers (exports), responses and ownership, side-effects (imports) and errors in one sentence each?
  2. Does it reimplement something WASI already provides? Import it instead.
  3. Is every function async (except time-sensitive one
Полный SKILL.md на GitHub

Установить wit-interface-design в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

async-and-resources.mdcapability-grants.mdconventions.mderrors-and-enums.mdhttp-derived-patterns.mdversioning.md

FAQ

Что делает скилл wit-interface-design?

Design and review WIT (WebAssembly Interface Types) interfaces, worlds and packages so they are capability-scoped, async, virtualizable and portable. Use this skill whenever the user is designing or reviewing a `.wit` file, adding a function, resource or interface to a WIT package, deciding what a component should import or export, designing a plugin or provider API (for example `wasmcloud:` packages), choosing between `enum` and `variant`, modeling errors, naming interfaces or resources, versioning a WIT package, or asking "how should I model this in WIT?", even if they never say "interface design". For building, composing, or running components, use webassembly-component-development instead.

Как установить скилл wit-interface-design?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл wit-interface-design запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить wit-interface-design с