AI Coding Weekly

Pocock says agent-built state machines make frontend sturdier

A prompt-level steer from an XState core team member, backed by the person who wrote XState.

Matt Pocock says he is addicted to getting agents to build state machines. Every time he sees an agent produce one, or even just a reducer, he says he can feel a huge bump in the robustness of the result, and that he knows future updates will be trivial and testable. He recommends it for frontend work, and notes that this is the XState core team member in him coming out again.

Matt Pocock
@mattpocockuk
X
Every time I see an agent has built a state machine (or even just a reducer) I can feel a huge bump in the robustness
Oct 15, 2026 · View on X

That is an impression rather than a measurement. Pocock is not reporting a benchmark or a bug count, he is reporting what he notices when he reads the diff. It is worth weighing accordingly, with the caveat that he is weighing code written in a style he has spent years working on.

The person who built XState agrees

David K, who Pocock calls out by name in the post, replied that state machines are underrated because they make complex logic explicit and impossible states impossible, and that agents are extremely good at making them now. He also called Pocock a state machine expert.

For anyone who has not touched one, a finite state machine is an explicit list of the states a piece of UI can be in and the transitions allowed between them, so there is no way to end up loading and errored at the same time. A reducer is the lighter version of the same idea, a single function that takes current state plus an event and returns the next state. XState is the library David K maintains for the heavier version.

Why this is cheap to try

The useful part is that nothing here is a tool. There is no MCP server, no skill file, no new harness. It is a line in the prompt, or a line in your AGENTS.md, asking the agent to model the feature as an explicit state machine or reducer instead of scattering booleans across a component.

The argument underneath is about reviewability as much as correctness. A state machine collapses a feature's behaviour into a table you can read in one sitting, which matters more when the code was written by something that does not get tired and will happily add a fourth boolean flag.

David K 🎹
@DavidKPiano
X
they make complex logic explicit, impossible states impossible, and agents are extremely good at making them now
Oct 15, 2026 · View on X

Have the good opinion, not the loud one

One email a day. Under three minutes. What working engineers found out about coding with AI.

Get the next one by email

Coding with AI, read daily so you do not have to. The experiments, the receipts and the arguments from engineers shipping real software. Not a changelog.