webgpu

Design, debug, and optimize portable WebGPU applications and WGSL shaders.

31|4|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/cazala/webgpu-skill --skill webgpu-cazala
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: webgpu
Source: https://github.com/cazala/webgpu-skill
Command: npx skills add https://github.com/cazala/webgpu-skill --skill webgpu-cazala

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @webgpu/types, typescript, vite, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Building WebGPU applications involves subtle pitfalls: incorrect WGSL buffer layouts, unguarded compute dispatches, device loss, canvas resize bugs, and silent validation failures. This Skill guides agents through explicit capability, data, pass, presentation, and lifecycle contracts so GPU code is correct, portable, and diagnosable from the first frame. ## Core Features & Use Cases - Contract-driven workflow: Build from a resource and pass graph with exact WGSL data layout, ping-pong state ownership, and guarded dispatches before scaling up. - Task-specific references: Deep guidance on initialization and lifecycle, WGSL data layout, compute patterns, rendering patterns, debugging and performance, compatibility, and creative simulation recipes. - Typed starter application: A copyable Vite + TypeScript particle field demonstrating compute-and-render pipelines, compilation diagnostics, resize handling, pointer interaction, device-loss reporting, and cleanup. - Use Case: Ask the agent to build a GPU particle simulation; it will request only needed device features, define exact buffer offsets, set up ping-pong storage buffers, surface shader compilation errors, and handle resize and teardown correctly. ## Quick Start Use the webgpu skill to build a portable WebGPU particle simulation with exact WGSL buffer layout, compilation diagnostics, and device-loss handling.

Frequently Asked Questions about webgpu

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a WebGPU compute and render pipeline?▼

Start from a resource and pass graph, define exact WGSL struct layouts, compile shader modules with getCompilationInfo diagnostics, then create pipelines and stable bind groups. The bundled Vite starter demonstrates a complete compute-and-render particle field with ping-pong buffers.

How do I define WGSL buffer layouts that match JavaScript?▼

Calculate AlignOf, SizeOf, member offsets, and array strides from WGSL layout rules rather than assuming 16-byte alignment for all structs. Pack mixed scalar types with DataView at explicit byte offsets, and remember uniform arrays require 16-byte strides.

Why is my WebGPU canvas blank or flickering on resize?▼

Blank output usually comes from format mismatches, missing getCurrentTexture calls, or silent validation errors. Flicker on resize comes from reassigning equal canvas dimensions; size the backing store from CSS pixels and DPR, and skip no-op assignments.

Does WebGPU work when optional features are unavailable?▼

Yes, if you build a portable core path and gate optional features like shader-f16, timestamp queries, and subgroups behind adapter feature checks. Request only the features and raised limits the workload actually uses, and provide a fallback or clear failure UI.

How do I read GPU simulation results back to the CPU?▼

Avoid full-buffer readback in animation loops. Compact results on the GPU into a bounded output using atomics, copy a small staging buffer, and map it asynchronously with mapAsync, rotating staging buffers for recurring reads.

How should WebGPU device loss be handled?▼

Treat device loss as a lifecycle transition: listen to device.lost, stop animation loops and observers, and rebuild from a new adapter or switch to a fallback. Resources from a lost device cannot be reused, so keep CPU-side descriptors for recovery.