Design, implement, review, and migrate XState v5 state machines and statecharts in TypeScript using modern v5 patterns. Use this whenever the user mentions XState, actors, state machines, statecharts, guards, transitions, workflows, or Stately, or is modeling non-trivial UI/app/process logic in a codebase that uses XState. Prefer a short machine sketch before code when requirements are fuzzy. If the problem is too simple for a state machine, say so and recommend @xstate/store instead.
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Use this file for brief framework-specific guidance after the machine design is already clear.
The concepts are the same across adapters:
useMachine(machine) when the component owns a local actor.createActorContext(...), useActorRef(...), and useSelector(...) when the actor is shared or when you want finer-grained subscriptions.snapshot.matches(...), snapshot.hasTag(...), and snapshot.can(...).useMachine(machine) for simple component-local ownership.useActorRef(...) and useSelector(...) when working with shared actors or more selective subscriptions.useMachine(machine) for local ownership.useSelector(...) when you need shared ownership or selective updates.useMachine(machine) for local ownership.useActorRef(...) and useSelector(...) when an actor is shared or when you want tighter subscription control.Prefer useMachine(...) when:
Prefer actor ref + selector patterns when: