Command Palette

Search for a command to run...

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

xstate-helper

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

XState v5 state machines, statecharts, and the actor model for complex, event-driven application logic. When user works with XState, state machines…

shepherdjerredот shepherdjerred★ 85 звёзд на GitHub

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

XState Helper Agent

Guidance for XState v5 — state machines, statecharts, and actors. This monorepo uses Bun and a strict ESLint config; read the Monorepo Gotchas section before writing any machine here — the documented setup({ types }) idiom from the official docs does not lint-pass in this repo and there is a specific workaround.

Versions (verified mid-2026)

Package Latest Notes
xstate 5.32.0 Core. In-repo use: discord-plays-pokemon/.../backend pins ^5.32.0
@xstate/react 6.1.0 React hooks. peer: react 16.8–19, xstate ^5.28
@xstate/store 4.1.0 Lightweight store (Zustand-like). React binding is a separate package
@xstate/store-react 2.0.0 React binding for store v4 — @xstate/store/react was removed in v4
bun add xstate                 # core
bun add @xstate/react          # React bindings
bun add @xstate/store @xstate/store-react   # lightweight store + its React binding

Requires TypeScript 5.0+. In tsconfig.json set "strictNullChecks": true (required — types break without it) and "skipLibCheck": true (recommended).

What's New in XState v5 (2024–2026)

v5 made actors first-class, removed v4 magic (typegen, implicit string events, external-by-default transitions), and added setup() for type safety. Recent 5.x minors:

  • actor.select(selector, eq?) (5.29) — derive a framework-agnostic Readable<T> off any actor's snapshot; .get() + .subscribe() (only fires when the selected value changes). No hook needed.
  • Routable states (5.28) — a state with route: {} + explicit id is reachable from anywhere via { type: 'xstate.route', to: '#id' }. Routes accept a guard (string ref resolved since 5.31.1).
  • getMicrosteps() / getInitialMicrosteps() (5.27) — pure [snapshot, actions] tuples per microstep, so you can inspect every intermediate (incl. always) state without executing actions.
  • maxIterations (5.31) — infinite-loop guard for eventless transitions (default Infinity).
  • filterEvents (5.30) — xstate/graph + createTestModel traversal limited to currently-enabled events (e.g. state.can(event)).
  • setup().assign/raise/sendTo/emit/spawnChild/enqueueActions(...) (5.22) — type-bound action helpers; no inline generics. Current best practice for typed enqueueActions/emit/spawnChild.
  • setup.extend() (5.24) and setup().createStateConfig() (5.21) — composable, modular setups.
  • mapState(snapshot, mapper) (5.31), getNextTransitions(snapshot) (5.26), partial descriptors in assertEvent(event, 'FEEDBACK.*') (5.25).
  • Model-based testing moved into core — import from xstate/graph (@xstate/test is deprecated).
  • @xstate/store v3/v4 — store.trigger.someEvent(...) typed API, .with(persist({ name })), atoms, schema validation; v4 split framework bindings into @xstate/store-react etc.

Core Mental Model

Everything is an actor. An actor is a live entity with private state, a mailbox (one event at a time), and async message passing. A state machine is the most robust way to describe an actor's behavior — but fromPromise, fromCallback, fromObservable, and fromTransition are actor logic too.

  • Logic (the machine/definition) is inert. createActor(logic) makes a running actor.
  • actor.send({ type }) — events are objects, never bare strings (v4 allowed strings; v5 does not).
  • actor.getSnapshot() reads current state; actor.subscribe(fn) observes changes (does not emit the current value immediately — read getSnapshot() for that).
import { createMachine, createActor } from "xstate";

const toggleMachine = createMachine({
  id: "toggle",
  initial: "inactive",
  states: {
    inactive: { on: { toggle: { target: "active" } } },
    active: { on: { toggle: { target: "inactive" } } },
  },
});

const actor = createActor(toggleMachine);
actor.subscribe((snapshot) => console.log(snapshot.value));
actor.start();            // logs "inactive"
actor.send({ type: "toggle" }); // logs "active"
actor.stop();

Machine vs Store — pick the right tool

  • State machine (xstate) — many discrete states, guarded transitions, hierarchy/parallelism, async orchestration. Use when the transitions are the hard part (wizards, checkout, auth, media players).
  • Store (@xstate/store) — a small, event-based shared-state container (Zustand-like) when you do not need statecharts. See references/xstate-store.md.
  • Not XState at all — for a bag of independent values prefer Zustand/Jotai; for server cache use TanStack Query. A localized form/wizard reducer can just be useReducer. XState earns its weight when illegal states and complex transitions are the actual problem (it makes impossible states unrepresentable). Don't reach for it to hold three booleans.

setup() + createMachine — the typed entry point

`setup({ typ

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

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

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

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

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

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

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

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

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

references/actors-and-machines.mdreferences/react-integration.mdreferences/testing-and-migration.mdreferences/xstate-store.md

FAQ

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

XState v5 state machines, statecharts, and the actor model for complex, event-driven application logic. When user works with XState, state machines, statecharts, actors, createMachine/setup, createActor, @xstate/react, @xstate/store, useMachine/useActor/useSelector, invoke/spawn, guards/actions/assign, or needs to model complex async flows, wizards, and event-driven state.

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

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

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

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

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

Сравнить xstate-helper с