用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill state-machine命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | state-machine |
| description | | Use when this capability is needed. |
Model behavior as a finite state machine to eliminate impossible states and make every transition explicit.
This skill is for state-machine design, not tool installation. Model first; choose tools later only when the model needs them.
Before changing code, produce or hold in working context:
Inspect the repository first. Reuse existing state patterns and dependencies. Do not introduce a visualization tool or runtime library just because this skill triggered.
isXxx booleans gate behavior and can drift out of syncPrefer explicit, reviewable artifacts:
| Situation | Output |
|---|---|
| Design or review request | State list, event list, transition table, impossible states |
| Human review needed | Mermaid stateDiagram-v2 plus the transition table |
| Simple TypeScript state | Discriminated union and transition function |
| React local UI state | useReducer state/event reducer |
| Complex app logic | XState only when hierarchy, parallel regions, history, actors, or inspection justify it |
| Rust | Typestate or statig, matching repo style |
| Embedded C/C++ | Explicit transition table or QP/QM if already part of the stack |
Load only the implementation reference that matches the selected stack.
Pause for human review before implementation when:
For review, use a text-first Mermaid diagram. Do not install visual tools unless the user explicitly asks for them.
| Component | Definition |
|---|---|
| State | Distinct mode the system can occupy (idle, loading, success...) |
| Event | Trigger for a transition (click, submit, response, timeout) |
| Transition | In state A, on event E, go to state B (optional guard / action) |
| Action | Side effect run on transition, entry, or exit (fetch, log, toast) |
| Guard | Boolean condition that must hold for the transition to fire |
Full glossary with citations: references/concepts.md
stateDiagram-v2 only when it improves review. See references/visual-notation.md.Worked example: references/modeling-process.md
| Stack | Reference |
|---|---|
| TypeScript, no lib | references/implementations/typescript-discriminated-unions.md |
| React, no lib | references/implementations/react-usereducer.md |
| Svelte 5 runes | references/implementations/svelte5-runes.md |
| XState v5 (cross-framework, statecharts) | references/implementations/xstate.md |
| C (embedded, kernel) | references/implementations/c.md |
| Java (backend, workflows) | references/implementations/java.md |
| Rust (typestate, embedded) | references/implementations/rust.md |
Validation manifest and rerunner: config/validation/manifest.json and
scripts/validate-references.sh.
Reach for a statechart library (XState, statig, QP, Spring StateMachine) when a
flat reducer becomes hard to audit or needs hierarchy, parallel regions, or
history. See references/statecharts-extensions.md.
Form, data fetching with retry, auth, multi-step wizard, toggle with optimistic
UI, network protocol handshake. Diagrams and implementation sketches in
references/patterns.md.
references/anti-patterns.md covers boolean explosion, isLoading flags, syncing
derivable state, dead-end states, and switch-FSM without a typed table.
references/further-reading.md curates Harel 1987, the W3C SCXML 1.0
recommendation, statecharts.dev, Samek's PSiCC2, Khourshid talks, and Wuyts'
state-machine blog series.
Source: bengous/agents-skills — distributed by TomeVault.