xstate
AGENTS.md30k starsChanged 21 months agoMITView on GitHub
Author, inspect and test XState with the installed version's contracts.
Trending
Less talk lately.about the whole repository
Who's talking about statelyai/xstate
- Stately“React & XState Tutorial #1 - Intro and setup”YouTube · Apr 20, 2022 · 26k views
- Stately“React & XState Tutorial #2 - Building our first machine”YouTube · Apr 20, 2022 · 17k views
- Stately“React & XState Tutorial #3 - The visual editor”YouTube · Apr 20, 2022 · 14k views
- Stately“React & XState Tutorial #4 - Event types and typegen”YouTube · Apr 20, 2022 · 13k views
- Stately“React & XState Tutorial #5 - Services, onDone and onError”YouTube · Apr 20, 2022 · 12k views
The biggest 5 of 68 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 68
Talked about on GitHub, YouTube, Hacker News, Bluesky and Stack Overflow (68 times).
On GitHub · 38
- Aug 12, 2023Bug: — statelyai/docs6 reactions
- Jun 22, 2026chore(deps): Bump xstate from 5.30.0 to 5.32.4 — Hardonian/Keys3 reactions · 5 comments
- Oct 11, 2021Add support for inspecting via websocket — statelyai/xstate-viz3 reactions · 4 comments
- Aug 31, 2021This repo is outdated and should be removed in favor of new example location — davidkpiano/xstate-todomvc3 reactions
- Jun 18, 2026build(deps): bump xstate from 5.31.1 to 5.32.1 — Timothy191/Arch-System2 reactions · 1 comment
33 more on GitHub
- Sep 25, 2024Inspector and parent window freeze when attempting to serialize an HTML element — statelyai/inspect2 reactions · 5 comments
- Sep 27, 2021additional Testing with tests derived from xstate.core 4.25 — statelyai/xstate-pythonsays it tested it2 reactions · 12 comments
- Nov 6, 2026chore(deps): bump xstate from 5.32.6 to 5.33.3 in the xstate group — speakeasy-api/gram1 reaction · 1 comment
- Oct 30, 2026chore(deps): bump the minor-and-patch group across 1 directory with 18 updates — guyghost/dodash1 reaction
- Oct 26, 2026Bump the frontend group across 1 directory with 21 updates — glimpse-hq/Glimpse1 reaction · 2 comments
- Oct 25, 2026Support XState v6 behavioral graphs and preserve input/history identity — statelyai/graph1 reaction · 1 comment
- Oct 15, 2026chore(deps): bump the minor-and-patch group across 1 directory with 20 updates — guyghost/dodash1 reaction · 1 comment
- Sep 28, 2026chore(deps): bump the minor-and-patch group across 1 directory with 19 updates — guyghost/dodash1 reaction · 1 comment
- Sep 28, 2026chore(deps): Bump xstate from 5.32.6 to 5.33.2 — leynos/vibe-coder1 reaction · 1 comment
- Sep 2, 2026Bump xstate from 5.32.5 to 5.32.6 — leynos/vibe-coder1 reaction
- Aug 31, 2026Bump the frontend group with 6 updates — glimpse-hq/Glimpse1 reaction · 2 comments
- Jul 22, 2026Bump xstate from 5.32.4 to 5.32.5 — leynos/vibe-coder1 reaction
- Jul 20, 2026Bump the frontend group with 7 updates — glimpse-hq/Glimpse1 reaction · 2 comments
- Jul 13, 2026Bump the frontend group across 1 directory with 15 updates — glimpse-hq/Glimpse1 reaction · 2 comments
- Jul 10, 2026Bump xstate from 5.32.3 to 5.32.4 — leynos/vibe-coder1 reaction
- Jul 9, 2026Bump xstate from 5.32.2 to 5.32.3 — leynos/vibe-coder1 reaction
- Jul 6, 2026Bump the frontend group with 6 updates — glimpse-hq/Glimpse1 reaction · 2 comments
- Jul 6, 2026Bump xstate from 5.31.1 to 5.32.2 — leynos/vibe-coder1 reaction
- Apr 17, 2026Implement Epics 1-6: Scaffolding, Shared Types, Board Engine, Rulesets, State Machines, Room Management & Socket Layer — Trinityy2/discord-sudoku1 reaction
- Mar 30, 2026chore(deps): bump xstate from 5.29.0 to 5.30.0 in /client — arkanwolfshade/MythosMUD1 reaction · 1 comment
- Oct 22, 2024Fix fine-grained reactivity and nested actor support — NullVoxPopuli/ember-statechart-component1 reaction
- Dec 27, 2023Port xstate to Dart / Flutter — statelyai/feedback1 reaction
- Jul 6, 2023[XState Inspect] Bug: Inspector fails when there are raise actions in state definitions. — statelyai/xstate-viz1 reaction · 4 comments
- May 24, 2023Bug: [xstate/inspect] Send event dialogue does not send any events — statelyai/xstate-viz1 reaction · 4 comments
- May 11, 2023Document action groups — statelyai/docs1 reaction
- Apr 16, 2023Add `useDeclarationFileForTypegenData` option — statelyai/xstate-tools1 reaction · 2 comments
- Aug 30, 2022enable typegen for action groups — statelyai/xstate-tools1 reaction · 3 comments
- Jul 3, 2022stately-xstate.edit not found — statelyai/xstate-tools1 reaction · 1 comment
- Jun 8, 2022add `stateValues` to typegen output — statelyai/xstate-tools1 reaction · 4 comments
- May 27, 2022Testing with `xstate@5` — huan/mailboxsays it tested it1 reaction
- Mar 17, 2022Epic: Enable secure, friction-less & reproducible bug reports — npm/statusboard1 reaction · 3 comments
- Sep 19, 2026Visual State Machine Management — Sportinger/MasterSelects0 reactions · 2 comments
- Dec 3, 2021Track the Modeling Events of XState — wechaty/bot5-assistant0 reactions
On YouTube · 24
- Apr 20, 2022React & XState Tutorial #1 - Intro and setup — Stately26k views · 10 comments
- Apr 20, 2022React & XState Tutorial #2 - Building our first machine — Stately17k views · 5 comments
- Apr 20, 2022React & XState Tutorial #3 - The visual editor — Stately14k views · 7 comments
- Apr 20, 2022React & XState Tutorial #4 - Event types and typegen — Stately13k views · 7 comments
- Apr 20, 2022React & XState Tutorial #5 - Services, onDone and onError — Stately12k views · 7 comments
19 more on YouTube
- Apr 20, 2022React & XState Tutorial #6 - Context and assign — Stately9.8k views · 7 comments
- Apr 20, 2022React & XState Tutorial #7 - Hierarchical states — Stately8.8k views · 3 comments
- Apr 20, 2022React & XState Tutorial #8 - Adding a todo item — Stately5.9k views · 4 comments
- Apr 20, 2022React & XState Tutorial #11 - Adding if/else logic with guards — Stately5.5k views · 19 comments
- Apr 20, 2022React & XState Tutorial #9 - Deleting a todo item — Stately4.2k views · 1 comment
- Apr 20, 2022React & XState Tutorial #10 - Using after to manage timeouts — Stately3.8k views · 3 comments
- Mar 1, 2022Visually Create State Machines — CodeTV3.4k views
- Jan 23, 2024Backend workflows with Stately: Credit checking flow — Stately3.2k views · 16 comments
- Jan 11, 2024Building backend workflows with Stately: Media scanning — Stately3.2k views · 12 comments
- Jul 26, 2026Effective State Machines with XState | David Khourshid | Effect Miami 2 — Effect | TypeScript for the AI Era3k views · 6 comments
- Mar 11, 2023Intro to Stately and XState webinar — Stately2.1k views · 5 comments
- Jan 6, 2024Stately Office Hours January 5 2024 — Stately1.9k views · 2 comments
- Sep 9, 2022🤖 Finite State Machines with XSTATE & Svelte 🔴 LIVE Coding & Chill — Johnny Magrippis1.3k views · 5 comments
- Feb 17, 2024Stately Office Hours February 16 2024 — Stately777 views · 1 comment
- Jan 29, 2022Stately Office Hours January 28 2022 — Stately538 views · 3 comments
- Feb 4, 2023Stately Office Hours February 3 2023 — Stately257 views · 2 comments
- Mar 4, 2023Stately Office Hours March 3 2023 — Stately249 views · 1 comment
- Apr 23, 2022Stately Office Hours April 22 2021 — Stately187 views
- Apr 9, 2022Stately Office Hours April 8 2021 — Stately154 views · 1 comment
On Hacker News · 2
- Mar 27, 2023Xstate: State machines and statecharts for the modern web178 points · 77 comments
- Dec 22, 2024XState – State machines for state management in JavaScript29 points · 9 comments
On Bluesky · 2
- Dec 24, 2024deserves a star that is for sure github.com/statelyai/xs... — @handle.invalid1 likes and repost
- Dec 22, 2024XState – State machines for state management in JavaScript Discussion — @hn100.bsky.social1 likes and repost
On Stack Overflow · 2
- May 15, 2022Issue upgrading XState's Reddit sample from Vue 2 to Vue 30 votes
- Jul 20, 2022Using XState, how can I access name of current state in an action?-1 votes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this agents.md into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 6
Read this page from the installed package, usually node_modules/xstate/docs/agents.md.
- Very specific: line 16
Use { target: 'next' } for a static transition.
- Distinctive: line 23
Put transient data in state input when it belongs to the active state.
- Very specific: line 28
Keep target literals visible when visual inspection matters.
- Very specific: line 31
Before exporting code-authored definitions, inspect getMachineSerializationDiagnostics(machine).
- Very specific: line 36
Use machineToJSON, machineConfigToJSON and machineFromJSON for definitions.
- Very specific: line 37
Use getPersistedSnapshot and the persistence guide for running state.
- Very specific: line 46
No command installs packages, imports application modules, executes code expressions or runs external effects.
- Distinctive: line 138
Keep sampled tests, bounded exploration and proof distinct.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Read this page from the installed package, usually node_modules/xstate/docs/agents.md.
docs/index.md identifies the exact version. docs/api-stability.json classifies
exports from that source tree. Prefer these files over examples for another major
version. Install framework and integration packages from the same release family.
Author v6 machines
- Declare contracts under
schemas, usingtypes<T>()for TypeScript-only inference or Standard Schema for runtime schemas. Inference alone does not validate input. See runtime validation. - Use
{ target: 'next' }for a static transition. Use one synchronous function for a conditional transition; returnundefinedbefore any enqueue call to refuse the event. String transitions and transition arrays are not v6 authoring syntax. See transitions. - Return a shallow
{ context: { field: value } }patch. Keep I/O, time reads, randomness and external mutation outside transition calculation. Queue effects withenq, or invoke actor logic for asynchronous work. - Put transient data in state input when it belongs to the active state. Use typestates to refine root context. State input is removed on exit; root context survives state changes.
- Invoke for work owned by a state's lifetime; spawn for actors with an explicit longer lifetime. Stop, cancellation and service failure need tests.
- Keep target literals visible when visual inspection matters. A graph is not
complete when
analysis.transitionTargetsCompleteis false. Read its diagnostics rather than guessing the missing destinations. - Before exporting code-authored definitions, inspect
getMachineSerializationDiagnostics(machine). Serialization can omit inline actors and runtime schemas. Code expressions need explicit evaluators and dependencies; JSON conversion does not preserve arbitrary closures.
Use machineToJSON, machineConfigToJSON and machineFromJSON for definitions.
Use getPersistedSnapshot and the persistence guide for running
state. A definition and a checkpoint are different artifacts. Do not restore old
snapshots without checking their version and migration requirements.
Local JSON operations
The core CLI's agent commands return one JSON object with schemaVersion,
xstateVersion, command, ok and either result or error. Failures exit with
status 1. --json is accepted; JSON is also the default for these commands.
No command installs packages, imports application modules, executes code
expressions or runs external effects. migrate remains a separate source
transformation command that delegates to the codemod package.
To migrate a v5 machine file, use the @xstate/codemod loop. Run
xstate-codemod baseline <file> before editing, then
xstate-codemod migrate <file> --json. Exit code 2 means the report's
manualSites need manual changes. Then run
xstate-codemod verify --baseline <baseline.json> <file> --json. It exits with
0 when the v6 behavior matches the v5 trace, 3 when a diff is unclassified, 4 when
a module fails to load or run, and 1 on a usage error. See
the migration guide.
| Command | Contract |
xstate docs | Locate installed documentation and read export stability. |
xstate inspect machine.json | Inspect a data-only definition and static graph completeness. |
xstate validate machine.json | Check definition structure. This does not validate runtime event payloads. |
xstate simulate machine.json events.json | Calculate stable snapshots and describe effects without executing them. |
xstate test machine.json checks.json | Explore supplied event representatives and check stable-state safety and reachability assertions. |
xstate replay machine.json fixture.json | Replay a counterexample against the same definition and XState version. |
xstate diff before.json after.json | Report structural JSON changes. Compatibility is explicitly notChecked. |
These commands accept JSON definitions, not TypeScript source files. Definitions
with @code expressions return EVALUATOR_REQUIRED and their JSON Pointer paths.
Definitions requiring custom runtime implementations must use the library with
explicit sources instead. The CLI never fills missing implementations with stubs.
For example, save this as machine.json:
{
"id": "review",
"initial": "pending",
"states": {
"pending": {
"on": {
"APPROVE": { "target": "approved" },
"REJECT": { "target": "rejected" }
}
},
"approved": { "type": "final" },
"rejected": { "type": "final" }
}
}An events file is an array such as [{ "type": "APPROVE" }], or an object
{ "events": [...], "input": ... } when startup input is required.
A checks file supplies event representatives and at least one assertion:
{
"events": [{ "type": "APPROVE" }],
"never": ["#review.rejected"],
"reachable": ["#review.approved"],
"limit": 1000
}never and reachable use existing state IDs prefixed with #. Coverage is
relative to the supplied event representatives and stable macrostep snapshots.
The example's event array excludes REJECT; it makes no assertion about runs
that send it. An event map instead augments the machine's default cases,
including unconfigured payload-free events and synthetic actor/timer events;
see event cases.
The default traversal limit is 10,000. Exceeding a bound fails instead of reporting
success. A reachability failure means no supplied representative witnessed the
state, not that the state is proven unreachable.
A forbidden-state failure contains error.details.fixture. Save that object and
pass it to replay. Its definition hash and XState version prevent accidental
replay against another model. Replay reports a property violation again while the
same assertion still fails. These CLI fixtures are separate from @xstate/test
fixtures. Use model-based testing for PBT, payload
shrinking, service outcomes, concurrency testing and comparison with an actual
system under test.
Repair and verify
Preserve the failing event sequence before editing. Reproduce it, make the smallest behavior change, then replay it and run relevant tests. Check forbidden behavior and resource cleanup as well as successful outcomes. A corrected type error must also compile without suppressions or broad casts.
For a running agent, expose public event schemas and descriptions through a
host adapter. Type-only schemas do not describe runtime parameters. Recheck state
revision and host authorization when accepting a command. snapshot.can(event)
is advisory, and sending an event does not establish durable commit or completion.
Actor completion capability is distinct from idleness or waiting for input.
Keep sampled tests, bounded exploration and proof distinct. State the event representatives, state abstraction, time and schedule assumptions, and limits with the result. Experimental APIs may still change independently of the public beta surface.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

