xstate-store
Installation
SKILL.md
XState Store
Targets @xstate/store v4 and @xstate/store-react v2 (TypeScript 5.4+). Match the task to one or more Branches rows and read every listed file in full before producing output — those references are the contract; the tripwires below are only a final self-check.
Pick the primitive first
| State | Primitive | Why |
|---|---|---|
| Domain state updated through named events | createStore({ context, on }) |
Typed trigger, can, emitted events, replayable transitions |
| Per-instance state built from input | createStoreLogic({ context: (input) => … }) |
One definition, many instances; selectors come along |
| A single value set directly | createAtom(value) |
No event vocabulary to justify a store |
| A value computed from other atoms or selectors | createAtom(() => …) |
Read-only, recomputes on dependency change |
| Modes, guards, delays, hierarchical or parallel states | xstate machine |
A store models data, not lifecycle |
Done when: the primitive is chosen from this table and its justification holds.