Understand how your app behaves
Stately turns app behavior into diagrams you can explore and share. Map flows from your code, simulate what can happen, and review what changed in a pull request.
See how it works
In this checkout example, a pull request adds a payment retry and removes the only path to a refund.
Compare behavior before and after
- Before
- From
declined, theREFUNDevent led torefund. - After
- From
declined, the newRETRYevent leads back topayment. Therefundstate has no incoming transition.
The dashed REFUND arrow marks the removed transition. The refund state is unreachable.
Try the simulator
Start simulation in the editor and send ADD_ITEM, CHECKOUT, SUBMIT, and FAIL one at a time. Then try RETRY or CANCEL.
Map a flow from your code
Import a machine in a supported format to see its possible paths. For flows spread across application code, ask your agent to draft a model and link its transitions to the relevant source.
Use the Stately CLI to find XState machines in your repo, render them as SVG, or export them to formats such as Mermaid and SCXML.
$ npx statelyai scanterminal
$ claude mcp add --transport http stately https://mcp.stately.ai/mcpIn Claude Code, run /mcp and complete Stately sign-in.
terminal
$ codex mcp add stately --url https://mcp.stately.ai/mcpSign in with codex mcp login stately.
.cursor/mcp.json
{"mcpServers":{" stately":{"url":" https://mcp.stately.ai/mcp"}}}Enable the server in Cursor Settings → MCP and complete Stately sign-in.
terminal
$ code --add-mcp '{"name":" stately","type":"http","url":" https://mcp.stately.ai/mcp"}'Run MCP: List Servers, start stately, and complete Stately sign-in.
any MCP client · server URL (streamable HTTP)
https://mcp.stately.ai/mcpStart the server in your client and complete Stately sign-in (OAuth).
Add the skills with npx skills add statelyai/skills.
- MCP URL
- https://mcp.stately.ai/mcp
- Docs
- MCP server · llms.txt
Validate and convert
stableFind missing targets, unreachable states, and invalid config, then translate between XState, SCXML, Mermaid, and D2.
- validate_machine
- convert_machine
Diff and patch
stableList the states and transitions that changed between two machines, and apply structured edits.
- diff_machines
- apply_machine_patches
Simulate and visualize
stableExplore paths, step a machine through events, and render statecharts or sequence diagrams.
- generate_graph_paths
- simulate_machine
- visualize_machinebeta
- visualize_sequence
Extract and review
betaExtract machines from source and compare a model with implementation evidence.
- extract_machines_from_code
- review_machine_implementation
How an agent's change gets reviewed.
Map behavior, review a proposed change, and compare the implementation with the model.
Mapped
A model inferred from the code, with citations to the source.
statechart + source hash
Proposed
A proposed edit to the graph, made in the editor or over MCP.
proposed change
Approved
A reviewer examines the proposed change and approves it.
review + approval
Implemented
The approved edit, written into the source.
commit
Compared
The agent compares the implementation with the approved model and reports differences.
review findings
CI gate
The diff command can fail a build when machine semantics change.
$ statelyai diff <base> <head> --fail-on-changesReview the evidence
Review the source citations behind the model. Run application tests to confirm how the code behaves. MCP docs
Runs over MCP, with the CLI for scan, push, pull, and diff. The editor is optional, and so is XState in your code.
Try it on your own code.
Understand the whole system.
Storefront
Next.js
Checkout
Node service
Orders
Postgres
Payments
Node service
Queue
Architecture
Map how services, actors, and machines connect. Import Structurizr JSON, D2, or Mermaid, including Mermaid C4 diagrams.


Inspection
Attach to a running app and watch states, events, and actors as they happen. Sequence diagrams show who sent what to whom.
// xstate-version: 6
states: {
declined: {
on: {
RETRY: { target: 'payment' }
},
},
}Edit in either direction
Open a supported source file in VS Code, edit its machine visually, and save supported changes back to the file.
Embed the editor or inspector in your app with the Stately SDK.
Connect behavior across your stack.
Stately imports supported machine, store, workflow, and diagram formats into one graph model. Explore paths through the graph and export it to supported formats. Source write-back depends on the format.
Supported sources, tools, and outputs:
- Libraries: XState, XState Store, Redux, Zustand
- Workflow and agent runtimes: LangGraph, Inngest, Restate
- Diagram and model formats: Mermaid, SCXML, D2
- Tools and outputs: Graph paths, Inspector, TypeScript
With Inngest, Restate, and LangGraph, Stately reads the workflows you already run and models the behavior around them. It sits above those runtimes and does not replace them.
See it on a running app.
Built on XState.
XState is an MIT-licensed library for running state machines in the browser or in Node.js.
- weekly npm downloads
- 7.9M+
- GitHub stars
- 30K+
- repositories depend on it
- 338K+
- years in production
- 10
$ npm install xstateFor multi-step flows, async orchestration, retries and timeouts, and any behavior that must be reviewed.
Inspect a running XState app.
Attach the inspector to a running app and watch states, events, and actors as they happen.
Open the inspector docsxstate 5 · xstate/graph · @xstate/store · xstate 6 beta
XState naturally separates the logic and makes it simple to mock out API calls, so it's easier to test the code and organize it!
Presley PizzoCoderXState is used by engineers at
We use XState to implement business workflows as statecharts. The visualizer helps us collaborate more closely with customers, the ability to externalize workflows as JSON configuration makes complex workflow changes surprisingly simple to roll out, and test case generation makes it easier than ever to move forward with confidence. XState makes it all possible!
James TharpeT-MobileStart free.
Community is the editor, simulation, and code export. Pro adds private projects, codebase sync, and version history. Team shares all of it with up to 10 people. Enterprise runs where you need it to.
| Plan | Features | Price |
|---|---|---|
| Community |
| $0 |
| Pro |
| $39 / mo$33 / mo billed yearly |
| Team |
| $199 / mo$167 / mo billed yearly |
| Enterprise |
| Book a demo (opens in a new tab) |
Enterprise-ready.
Self-host it, sign in through your identity provider, and keep the model inside your boundary.
- Run the editor on your own network. Local editing and simulation need no database.
- Sign in through your identity provider: an SSO proxy or your OAuth issuer.
- Disable AI features with AI_ENABLED=false.
- Run machine conversion, comparison, and patching over HTTP or MCP on your host.
- Commercial license, with MIT-licensed SDK and CLI.
AI_ENABLED=false
# Configure comments separatelyWhat runs on your host
- Visual editing and simulation
- Source editing for supported formats
- SCXML export
Questions.
Start with what a state machine is, then explore state machines and statecharts, state chart examples, and the actor model.
What is a state machine?
A state machine models behavior as states and transitions between them. Events can trigger transitions, changing the current state. Statecharts extend state machines with nested states and parallel regions for concurrent behavior.
Does Stately replace my workflow runtime?
No. Temporal, Inngest, Restate, and LangGraph keep running your workflows. Stately models and analyzes the behavior they run.
Do I need XState?
No. Stately maps existing code from many libraries and formats, and can capture behavior from a running app. Use XState when you want to execute the model directly.
Does my code leave my network?
The hosted service processes submitted code under the Stately privacy policy. For a self-hosted deployment, configure AI, comments, and network access to match your data policy.
What does my agent actually do with Stately?
It can map code into a statechart with cited evidence, propose graph changes, and compare a model with implementation evidence. People can review the resulting changes.
Where are the machine-readable docs?
Start with /llms.txt and /llms-full.txt. Docs pages are available as markdown by adding .mdx to the URL. The MCP server is at https://mcp.stately.ai/mcp, and npx skills add statelyai/skills installs the agent skills.
- /llms.txtSite summary for agents
- /llms-full.txtFull docs as plain text
- https://mcp.stately.ai/mcpHosted MCP server
- claude mcp add --transport http
stately https://mcp.stately.ai/mcpAdd the MCP server to Claude Code - codex mcp add
stately --url https://mcp.stately.ai/mcpAdd the MCP server to Codex - {"mcpServers":{"
stately":{"url":" https://mcp.stately.ai/mcp"}}}Cursor: .cursor/mcp.json - code --add-mcp '{"name":"
stately","type":"http","url":" https://mcp.stately.ai/mcp"}'Add the MCP server to VS Code - npx
statelyai scanFind the machines in a repo - npx skills add
statelyai/skillsAgent skills - /docs/packages/mcp.mdxMCP docs as markdown
- https://github.com/statelyai (opens in a new tab)Source
Map your first repo.
$ npx statelyai scan$ npx -y @statelyai/mcp
