‹ 首页

state-machine

@wellapp-ai · 收录于 5 天前 · 上游提交 1 个月前

Document UI component states (current vs expected) with transitions

适合你,如果你需要文档化UI组件的状态变化

/ 通过 npx 安装 校验哈希
npx oh-my-skill add wellapp-ai/well/state-machine
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- wellapp-ai/well/state-machine
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify wellapp-ai/well/state-machine
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
340GitHub stars
~800上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 782601c · 表述以原文为准
它做什么

装上后,Claude 能帮你分析 UI 组件的各种状态(如初始、加载、成功、错误、空),列出当前行为和预期行为,并绘制状态转换图、记录边界情况。

什么时候触发

在 Ask 模式的 CONVERGE 循环中处理有状态组件,或重构复杂状态组件,或实现新交互组件时,可手动触发或遵循 CONVERGE 循环引用。

装好后可以这样说
Claude 会生成状态表、转换图和边界情况。
Claude 会对比当前与预期状态。
技能原文 SKILL.md作者撰写 · MIT · 782601c

State Machine Skill

Document the state machine for UI components, comparing current behavior to expected behavior and mapping all state transitions.

When to Use
  • During Ask mode CONVERGE loop for stateful components
  • When refactoring existing components with complex state
  • Before implementing new interactive UI components
Instructions
Phase 1: Identify States

List all possible states for the component:

| State | Current Behavior | Expected Behavior | |-------|------------------|-------------------| | Initial | [What happens now] | [What should happen] | | Loading | [Current loading UX] | [Expected loading UX] | | Success | [Current success display] | [Expected success display] | | Error | [Current error handling] | [Expected error handling] | | Empty | [Current empty state] | [Expected empty state] |

Common States to Consider:

| State Type | Examples | |------------|----------| | Data states | Initial, Loading, Success, Error, Empty, Stale | | Interaction states | Idle, Hover, Focus, Active, Disabled | | Visibility states | Hidden, Visible, Collapsed, Expanded | | Selection states | Unselected, Selected, Partially selected | | Validation states | Valid, Invalid, Pending validation |

Phase 2: Map Transitions

Define what triggers each state change:

| From | To | Trigger | Side Effects | |------|----|---------|--------------| | Initial | Loading | User action / Mount | Start fetch | | Loading | Success | Data received | Populate UI | | Loading | Error | Request failed | Show error message | | Loading | Empty | Empty response | Show empty state | | Error | Loading | Retry clicked | Restart fetch | | Success | Loading | Refresh clicked | Refetch data |

Phase 3: State Diagram

Create a Mermaid state diagram:

stateDiagram-v2
    [*] --> Initial
    Initial --> Loading : fetch
    Loading --> Success : data received
    Loading --> Error : request failed
    Loading --> Empty : no data
    Error --> Loading : retry
    Success --> Loading : refresh
    Empty --> Loading : refresh
    Success --> [*] : unmount
Phase 4: Data Requirements

For each state, define what data is needed:

| State | Required Data | UI Elements | |-------|---------------|-------------| | Initial | None | Placeholder or skeleton | | Loading | None | Spinner, skeleton, progress | | Success | [List required fields] | Full component | | Error | Error message, retry action | Error banner, retry button | | Empty | Empty message, CTA | Empty illustration, CTA button |

Phase 5: Edge Cases

Identify edge cases and how to handle:

| Edge Case | Current | Expected | |-----------|---------|----------| | Network timeout | [Current] | Show timeout message, retry option | | Partial data | [Current] | Graceful degradation, show available | | Stale data | [Current] | Show stale indicator, background refresh | | Concurrent updates | [Current] | Optimistic update, rollback on conflict | | Auth expired | [Current] | Redirect to login, preserve state |

Output Format
## State Machine: [Component Name]

### State Table

| State | Current | Expected | Data Required |
|-------|---------|----------|---------------|
| Initial | [Behavior] | [Behavior] | [Data] |
| Loading | [Behavior] | [Behavior] | [Data] |
| Success | [Behavior] | [Behavior] | [Data] |
| Error | [Behavior] | [Behavior] | [Data] |
| Empty | [Behavior] | [Behavior] | [Data] |

### Transition Diagram

[Mermaid stateDiagram]

### Edge Cases

| Case | Handling |
|------|----------|
| [Case] | [How to handle] |

### Summary
- States: [N] identified
- Transitions: [N] mapped
- Edge cases: [N] documented
Invocation

Invoke manually with "use state-machine skill" or follow Ask mode CONVERGE loop which references this skill.

Related Skills
  • qa-planning - Uses states to define test coverage
  • design-context - Check existing component states in Storybook
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。