Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

xstate

БесплатноБез исполняемых скриптовНе проверен

WHEN React state changes in response to an external answer — async submit, in-flight or loading flags, retries, cancellation, polling, optimistic updates…

mintuzот mintuz★ 38 звёзд на GitHub

Об этом скилле

XState

Treat a statechart as an executable ownership model for time, concurrency, and resource lifetimes.

Recognise a hand-rolled statechart

Each of these is a lifecycle already modelled by hand:

  • a useState flag for work in flight: isSubmitting, isLoading, pending;
  • a .then, .catch, or await block that sets two or more pieces of state in sequence;
  • a re-entry guard such as if (submitting) return;
  • a line that clears an error or a stale result before a retry;
  • a useEffect that starts asynchronous work and needs an ignore flag in its cleanup;
  • two booleans that must never both be true, such as isLoading with error;
  • a setTimeout or setInterval for retry, debounce, or polling that something must clear;
  • a pointerdown, dragstart, or gesture handler that binds listeners to the document and must unbind them;
  • handling for a response that arrives after cancel, replacement, or unmount.

Any one of them leads to step 1, however small the request and whether or not the file imports xstate. When the code already exists, name each defect it has today and the wrong behaviour a user would see before proposing the machine that removes it (principle-capture-the-baseline).

For a visualisation-only request, inspect the current machine source and go to step 6 instead.

1. Establish the temporal boundary

Inventory the mounted journey, external authority, live resources, concurrent concerns, retry and cancellation policy, and every source of stale or duplicate work. Inspect existing actors and runtime integrations, and confirm the installed XState major version; the XState 4 and 5 APIs differ.

Use XState only where ordering, concurrency, retries, cancellation, stale results, or resource lifetimes make the behaviour temporal. Classify with two tests, by what they show, not by what the state renders:

  1. An external answer (a network response, a timer, another actor, the platform) makes state temporal whatever it looks like on screen. A disabled button or a spinner presents temporal state; it is not presentation state.
  2. Direct user input creates a lifecycle whenever the interaction has an interruptible middle: a drag holds pointer capture, cancels on Escape, and must release on unmount; a panel that animates shut has a closing phase.

State belongs to the UI framework only when both tests come back empty: one event sets the value completely, leaving no phase to interrupt and nothing to dispose.

Complete when: every temporal responsibility has one named owner, and every proposed actor owns at least one distinct lifecycle or resource.

2. Model the journey

Read modelling.md before creating or changing a machine. Apply it to the actor boundary, typed factory, event and command unions, lifecycle states, transition placement, hierarchy, parallel regions, and readiness joins.

Before creating the file, find which layer owns machines: architecture tests, import-boundary rules such as eslint-plugin-boundaries or dependency-cruiser, CLAUDE.md, architecture decision records, and the directory holding existing machines. A correct machine in a forbidden directory fails CI.

Complete when: the machine sits in the layer the repository's own rules assign to machines, mutually exclusive meanings are states, independent concerns are parallel only when they have independent lifecycles, and each transition sits at the narrowest state that owns it (principle-model-the-domain).

3. Own effects and convergence

Read lifecycles.md whenever the feature invokes asynchronous work, owns a live handle, retries, cancels, accepts optimistic state, or waits for external authority. Keep handles inside invoked actors and fence work by identity.

Complete when: state exit or parent stop disposes every resource, stale and duplicate results are harmless, retry timers cancel with their lifecycle, and authoritative convergence—not an optimistic acknowledgement—confirms completion.

4. Integrate React narrowly

Read react.md for any @xstate/react surface. Let the route or feature boundary own useActorRef, expose typed actor refs to descendants, and subscribe through focused selectors.

Run both step 1 tests over every useState you write or keep, and state the verdict in your reply so the user can overrule it. Where the tests are decisive, act and report the call in one line: "isSubmitting is set by the request, so it moved into the machine as submitting." Where the call is genuinely close (a real but small lifecycle, or a machine the repository's layer rules would push far from its component), ask the user before building: name the state, name the phase that makes it a lifecycle, and ask whether it belongs in the machine.

Complete when: every retained useState holds a value one event sets completely, no React state duplicates a fact an external answer owns, actor-derived status and

Полный SKILL.md на GitHub

Установить xstate в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

agents/openai.yamlreferences/diagramming.mdreferences/lifecycles.mdreferences/modelling.mdreferences/react.mdreferences/testing.md

FAQ

Что делает скилл xstate?

WHEN React state changes in response to an external answer — async submit, in-flight or loading flags, retries, cancellation, polling, optimistic updates, stale responses — or to an interaction with an interruptible middle, such as a drag or a gesture; or WHEN building, reviewing, testing, or visualising XState 5 actors and @xstate/react integrations; NOT for a value one event sets completely, such as a text draft, a focus flag, or a plain open and closed toggle; models typed lifecycles and renders legal Mermaid stateDiagram-v2 charts.

Как установить скилл xstate?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл xstate запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить xstate с