What this thread does
The claim
@mattpocockuk (15 October 2026, a self-described XState core team member) says that when an agent builds a state machine, or even just a reducer, the code feels much more robust, and he expects later changes to be simple and testable. He recommends it for frontend work. He gave no numbers. He calls himself an "XState Core Team Member" in a reply to the post; this is his own role description.
The reasoning is familiar: instead of several booleans that can combine into impossible states (isLoading and error both set), the component has a named set of states and explicit transitions. An agent asked to change behaviour then edits one transition table instead of scattered ifs, and transitions are easy to unit-test.
Three ways to try it
- Plain reducer, no dependency: a discriminated-union state type plus
useReducer(or any reducer). Easiest for agents to write and review. - XState v5 (MIT; as of November 2026, 5.33.4, released 7 November 2026): full statecharts with actors, guards and delayed transitions, plus visual tooling from Stately. More power, more code.
- @xstate/store (MIT; as of November 2026, 4.3.0, released 8 October 2026): a small event-driven store when you want explicit events without a full statechart.
A rule you can put in AGENTS.md or CLAUDE.md: "For components with more than two async or UI states, model state as a discriminated union with a reducer (or an XState machine). No combinations of boolean flags. Write a test for each transition."
Caveats
- For simple components this adds code with no benefit. Agents may over-model.
- Machines can hide logic in configuration that reviewers skim. Keep transitions small and named.
- Robustness is easy to feel and hard to measure.
How to test it and what to report
Pick one real feature. Build it twice from the same prompt, once with the rule above and once without. Then give both versions the same three or four follow-up change requests and count failing tests, bugs found in review and reverted changes.
Please report: the model and harness, which form you used (reducer, XState, @xstate/store), how many follow-up changes you made, and what broke in each version. Counter-examples are as useful as wins.
Sources
- State machines and statecharts (Stately docs), read. Checked: it says state machines make it easier to find impossible states and spot undesirable transitions; transitions are deterministic (each state and event pair leads to one next state); you can test all possible states and transitions. It does not mention reducers, and does not say agent-built machines make later changes safer.
- statelyai/xstate (GitHub, read with the GitHub API). Checked: licence MIT; as of November 2026,
xstate5.33.4 (released 7 Nov 2026) and@xstate/store4.3.0 (released 8 Oct 2026) in the stable GitHub releases; the user @mattpocock is listed as a contributor. His reply to the linked X post supplies the self-described "core team" role. - Qualification added: the body attributes the core-team label to his own reply.
Checked 2026-11-24: the post, its date and wording; it gives no measured robustness result. Not checked: whether XState v6 previews change the picture, the Stately visual tooling, and everything in "Three ways to try it" beyond versions and licence. The claim that agent-built machines or reducers make code more robust is his opinion and is untested; the suggested experiment was not run.
Started from a post by @mattpocockuk, packaged by the editor. Original post