webgpu
БесплатноБез исполняемых скриптовНе проверенDesign, implement, debug, review, and optimize portable WebGPU applications and WGSL shaders. Use when building render or compute pipelines; GPU simulations…
от cazala★ 35 звёзд на GitHubОб этом скилле
WebGPU
Build the smallest observable GPU result first, then scale it. Treat every WebGPU feature as five explicit contracts:
- Capability contract: baseline, optional features and limits, fallback.
- Data contract: WGSL types, byte offsets, strides, usage flags.
- Pass contract: reads, writes, ordering, ping-pong ownership.
- Presentation contract: canvas format, physical size, alpha and color.
- Lifecycle contract: creation, resize, errors, loss and destruction.
Copy the full Vite starter for a new browser project. It contains a typed compute-and-render particle field with ping-pong buffers, compilation diagnostics, resize handling, pointer interaction, device-loss reporting, and cleanup.
Work from a resource and pass graph
Before writing WGSL, list persistent resources and pass ownership:
CPU seed ─writeBuffer─> state A
│
state A ─compute step─> state B ─render─> canvas
state B ─compute step─> state A ─render─> canvas
For every pass, record:
- entry point and dispatch/draw dimensions;
- bindings and shader visibility;
- resources read, written or copied;
- state that becomes authoritative after the pass;
- bounds guards and synchronization assumptions.
Use different resources when a pass needs the previous state while producing the next state. A pass boundary orders commands, but it does not make an algorithm with cross-invocation in-place reads deterministic.
Build in this order
- Decide whether unsupported WebGPU means fallback, reduced mode, or a clear failure.
- Request an adapter and only the optional features and raised limits the workload actually uses.
- Define WGSL structs and calculate exact host offsets and array strides.
- Allocate persistent resources and label them.
- Compile shader modules, inspect
getCompilationInfo(), then create pipelines. - Create stable bind groups or rebuild them only when their resources change.
- Encode a minimal pass, submit it, and verify visible or numeric output.
- Add resize, input, simulation timing, readback, and teardown one concern at a time.
- Profile only after correctness is stable at the intended workload.
Keep these invariants
- Treat
adapter.featuresandadapter.limitsas possibilities. The device exposes only the capabilities requested and granted atrequestDevice(). - Never use “all structs are 16-byte aligned” as a packing rule. Calculate
AlignOf,SizeOf, member offsets, array stride, and uniform-specific constraints. - Guard every over-dispatched compute invocation before accessing resources.
- Keep
workgroupBarrier()andstorageBarrier()in uniform control flow for the participating workgroup. - Do not create buffers, textures, samplers, bind groups, or pipelines every frame unless the workload truly changes their descriptors.
- Avoid full GPU-to-CPU readback in animation or pointer loops. Compact bounded results on the GPU and map a small staging buffer.
- Treat WGSL passed to
createShaderModule()as executable input. Prefer bundled, reviewed shader source; do not make the application compile network-fetched or end-user-supplied WGSL at runtime by default. - Resize the canvas backing store from its rendered CSS size and DPR, clamp it to device limits, and skip no-op assignments.
- Surface shader compilation messages, uncaptured errors, pipeline validation failures, and
device.lost. - Stop animation and observers before destroying resources; unconfigure owned canvas contexts and destroy the device when appropriate.
Choose a pattern by workload
| Workload | Start with |
|---|---|
| Independent particles or records | Storage buffers, guarded 1D dispatch, instanced render |
| Neighbor-based particles | Spatial binning or tiled neighborhoods before pairwise work |
| Cellular automata or stencils | Ping-pong state, 2D dispatch, fixed simulation cadence |
| Trails, blur or iterative images | Ping-pong textures and explicit compute/render passes |
| Post-processing | Render to an intermediate texture, then composite |
| Interactive inspection | GPU filter/compact pass plus a bounded staging readback |
| Generated or modular shaders | Stable binding contract, composed pass phases, compile diagnostics |
Start with a portable core path. Gate shader-f16, timestamp queries, subgroups, storage formats, language extensions, and raised limits as optional accelerators—not silent requirements.
Load the right detail
- Read initialization-and-lifecycle.md for adapters, devices, features, limits, canvas configuration, loss and cleanup.
- Read wgsl-data-layout.md before defining or debugging host-shareable buffers.
- Read compute-patterns.md for workgroups, ping-pong state, fixed steps, grids, barriers and bounded readback.
- Read rendering-patterns.md for canvas sizing, instancing, intermed
Установить webgpu в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл webgpu?
Design, implement, debug, review, and optimize portable WebGPU applications and WGSL shaders. Use when building render or compute pipelines; GPU simulations, cellular automata, particles, image processing, feedback effects, or data-parallel workloads; defining buffers, textures, bind groups, and host-shareable layouts; handling canvas sizing, optional features, errors, device loss, readback, and cleanup; or diagnosing validation, correctness, compatibility, and performance problems.
Как установить скилл webgpu?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл webgpu запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic