Build high-performance desktop apps with GPUI using Rust. Best practices for state, UI, and async interaction.
Install
mkdir -p .claude/skills/gpui && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14282" && unzip -o skill.zip -d .claude/skills/gpui && rm skill.zipInstalls to .claude/skills/gpui
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
GPUI UI framework best practices for building desktop applications. Use when writing GPUI code, creating UI components, handling state/events, async tasks, animations, lists, forms, testing, or working with Zed-style Rust GUI code.Key capabilities
- →Write new GPUI views or components
- →Implement state management with Entity
- →Handle events and keyboard shortcuts
- →Work with async tasks and background work
- →Build forms, lists, or dialogs
- →Style components with Tailwind-like API
How it works
This skill provides a guide with 40+ rules across 8 categories for building desktop applications with the GPUI UI framework.
Inputs & outputs
When to use gpui
- →Build GPUI components
- →Manage state with Entity
- →Implement keyboard shortcuts
- →Handle async UI tasks
About this skill
GPUI Best Practices
Comprehensive guide for building desktop applications with GPUI, the UI framework powering Zed editor. Contains 40+ rules across 8 categories, prioritized by impact.
When to Apply
Reference these guidelines when:
- Writing new GPUI views or components
- Implementing state management with Entity
- Handling events and keyboard shortcuts
- Working with async tasks and background work
- Building forms, lists, or dialogs
- Styling components with Tailwind-like API
- Testing GPUI applications
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Core Concepts | CRITICAL | core- |
| 2 | Rendering | CRITICAL | render- |
| 3 | State Management | HIGH | state- |
| 4 | Event Handling | HIGH | event- |
| 5 | Async & Concurrency | MEDIUM-HIGH | async- |
| 6 | Styling | MEDIUM | style- |
| 7 | Components | MEDIUM | comp- |
| 8 | Anti-patterns | CRITICAL | anti- |
Quick Reference
1. Core Concepts (CRITICAL)
core-ownership-model- Understand GPUI's single ownership modelcore-entity-operations- Use read/update/observe/subscribe correctlycore-weak-entity- Use WeakEntity to break circular referencescore-context-types- Know when to use App, Context<T>, AsyncApp
2. Rendering (CRITICAL)
render-render-vs-renderonce- Choose Render for stateful, RenderOnce for componentsrender-element-composition- Build element trees with div() and method chainingrender-conditional- Use .when() and .when_some() for conditional stylingrender-shared-string- Use SharedString to avoid string copyingrender-builder-pattern- Design components with builder pattern
3. State Management (HIGH)
state-notify- Always call cx.notify() after state changesstate-observe- Use cx.observe() to react to Entity changesstate-subscribe- Use cx.subscribe() for typed eventsstate-global- Use Global trait for app-wide statestate-keyed-state- Use window.use_keyed_state() for persistent state
4. Event Handling (HIGH)
event-actions- Define and register actions for keyboard shortcutsevent-listener- Use cx.listener() for view-bound event handlersevent-focus- Manage focus with FocusHandle and key_contextevent-propagation- Understand event bubbling and stop_propagation
5. Async & Concurrency (MEDIUM-HIGH)
async-task-lifecycle- Store or detach tasks to prevent cancellationasync-debounce- Implement debounce with timer + task replacementasync-background-spawn- Use background_spawn for CPU-intensive workasync-weak-entity- Use WeakEntity for safe cross-await accessasync-error-handling- Use .log_err() and .detach_and_log_err()
6. Styling (MEDIUM)
style-flexbox- Use h_flex() and v_flex() for layoutsstyle-theme-colors- Always use cx.theme() for colorsstyle-spacing- Use DynamicSpacing for responsive spacingstyle-elevation- Use elevation system for layered surfaces
7. Components (MEDIUM)
comp-stateless- Prefer RenderOnce with #[derive(IntoElement)]comp-traits- Implement Disableable, Selectable, Sizable traitscomp-focus-ring- Add focus ring for accessibilitycomp-dialog- Use WindowExt for dialog managementcomp-variant- Use variant enums for component styles
8. Anti-patterns (CRITICAL)
anti-silent-error- Never silently discard errors with let _ =anti-drop-task- Never drop Task without storing or detachinganti-drop-subscription- Always detach or store subscriptionsanti-circular-reference- Avoid Entity cycles, use WeakEntityanti-missing-notify- Never forget cx.notify() after state changesanti-unwrap- Avoid unwrap(), use ? or explicit handling
Architecture Overview
┌─────────────────────────────────────────────────────────┐
│ Application (App) │
│ (Single owner of all Entities) │
└─────────────────────────────────────────────────────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
┌───────────┐ ┌───────────┐ ┌──────────┐
│ Entity<A> │ │ Entity<B> │ │ Global<C>│
└───────────┘ └───────────┘ └──────────┘
│ │ │
│ read/update │ read/update │ via App
│ via Context<A> │ via Context<B> │
│
┌─────────────────────────────────────────────────┐
│ UI Rendering (Render trait) │
│ Each frame: fn render(&mut self, ...) │
│ Returns: impl IntoElement (Element tree) │
└─────────────────────────────────────────────────┘
│
├─ observe() → changes trigger render
├─ subscribe() → events trigger reactions
├─ notify() → signal changes
└─ emit() → send typed events
How to Use
Read individual rule files for detailed explanations and code examples:
rules/core-ownership-model.md
rules/render-render-vs-renderonce.md
rules/anti-silent-error.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
When not to use it
- →When not working with GPUI
- →When not building desktop applications
Limitations
- →Specific to the GPUI UI framework
- →Focuses on Zed-style Rust GUI code
How it compares
This guide offers categorized and prioritized rules for GPUI development, contrasting with an unguided approach.
Compared to similar skills
gpui side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| gpui (this skill) | 0 | 6mo | No flags | Intermediate |
| tauri | 76 | 1mo | Review | Advanced |
| rust-errors | 5 | 1mo | No flags | Advanced |
| hula-skill | 3 | 7mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
tauri
EpicenterHQ
Tauri path handling, cross-platform file operations, and API usage. Use when working with file paths in Tauri frontend code, accessing filesystem APIs, or handling platform differences in desktop apps.
rust-errors
EpicenterHQ
Rust to TypeScript error handling patterns for Tauri apps. Use when defining Rust errors that will be passed to TypeScript, handling Tauri command errors, or creating discriminated union error types.
hula-skill
HuLaSpark
HuLa project skill for frontend (Vue 3 + Vite + UnoCSS + Naive UI/Vant), backend (Tauri v2 + Rust + SeaORM/SQLite), full-stack flows, and build/release work. Use when the user mentions hula or HuLa or requests changes in this repository; after triggering, ask which scope (frontend/backend/fullstack/build-release) to enable.
makepad-shaders
ZhangHanDong
CRITICAL: Use for Makepad shader system. Triggers on: makepad shader, makepad draw_bg, Sdf2d, makepad pixel, makepad glsl, makepad sdf, draw_quad, makepad gpu, makepad 着色器, makepad shader 语法, makepad 绘制
waterui
water-rs
Build cross-platform apps with WaterUI. Use when writing views, handling state, styling UI, or debugging WaterUI Rust code. Covers reactive bindings, layout, components, and the water CLI.
waller-wallpaper-session
gvastethecreator
Extend or debug the Wallpaper Session, monitor drafts, preview flows, editor flow, and profile composition across React, Tauri, and Rust. Use for monitor wallpaper features, profile bugs, preview issues, or domain-model changes.