We need to build a complex state machine. Is there an AI…
We need to build a complex state machine. Is there an AI that can take a state diagram or a natural language description and generate robust, bug-free state management code?
Data as of Oct 5, 2026ChatGPT SearchGoogle AI ModeBased on 362 AI responses from ChatGPT Search and Google AI Mode·Reviewed by Dimitry Apollonsky ·
For complex state machines, your ideal tool depends on your target platform. Use StateSmith if building embedded systems that require highly reliable C, C++, or C# code. For web applications, Stately (XState) and Eraser.io are preferred for their visual modeling capabilities. For general automation or rapid prototyping within a full app context, agents like Claude Code or Replit Agent can translate natural language requirements directly into functional codebases.
Brands AI recommends here
Mentioned in
1
Stately
Best for web-based state management that requires visual mapping. Using the XState library, it is excellent for TypeScript and JavaScript developers building complex UI flows with predictable, testable logic.
4StateSmithBest for high-reliability embedded and system-level applications. It converts visual diagrams into clean C, C++, or Python with no dependencies, making it ideal for performance-restricted microcontrollers.36%
Recommendations by AI engine
Recommended in · Sep 11 – Sep 27, 2026
StatelyChatGPT Search5 of 5 answersGoogle AI Mode5 of 5 answers
XStateChatGPT Search5 of 5 answersGoogle AI Mode4 of 5 answers
ClaudeChatGPT Search0 of 5 answersGoogle AI Mode4 of 5 answers
GPT-4oChatGPT Search0 of 5 answersGoogle AI Mode4 of 5 answers
MermaidChatGPT Search1 of 5 answersGoogle AI Mode3 of 5 answers
ChatGPT WorkChatGPT Search2 of 5 answersGoogle AI Mode1 of 5 answers
Yes, modern AI and specialized tooling can handle this, but the phrase "bug-free" comes with a caveat: LLMs and AI tools are fantastic at scaffolding, syntax, and finding edge cases, but they still require a structured framework to guarantee correctness.
Instead of asking a general-purpose LLM (like ChatGPT or Claude) to write a raw 1,000-line switch-case state machine from scratch—which easily accumulates silent logic bugs—the best approach is combining visual state orchestration tools with AI or using structured prompt workflows.
Phase 1: Specialized Visual & AI Tooling (The Best Route)
If you want a dedicated ecosystem that translates natural language or diagrams directly into production-ready code, look at specialized statechart platforms:
Stately AI (Stately Studio) : This is the industry gold standard for complex state management. It uses XState (JavaScript/TypeScript). Stately features integrated AI that allows you to describe a flow in natural language, scaffold behaviors visually, expose hidden edge cases, and automatically generate robust, typed code.
Visual Diagram-to-Code Generators : Tools supporting Mermaid AI State Diagrams can take plain English descriptions, map out comprehensive state, transition, and guard logic visually, and export standard diagrams that can be parsed into logic templates.
Phase 2: A Robust Prompt Framework for LLMs
If you are generating state machine code via an advanced general LLM (like Claude 3.5 Sonnet or GPT-4o), use a strict constrained-generation workflow rather than a loose prompt.
Recommended Prompt Template
"Act as a senior systems architect specializing in finite state machines. I need a robust state machine implementation in [Target Language/Framework, e.g., TypeScript / Python / Rust].
Inputs:
Natural language description or transitions: [Insert Description]
Strict Generation Requirements:
Explicit States & Events: Define an explicit enum or type union for all possible states and incoming events.
Transition Table: Implement a strict transition function or dictionary. Invalid state transitions must throw an explicit error or return a safe 'no-op' result rather than silently failing.
Guard Conditions: Include placeholders for guards/conditions on complex transitions.
No Side-Effects in Transitions: Keep state transition logic pure; side-effects (API calls, logging) must be handled via designated entry/exit actions.
Edge Cases: Explicitly handle unexpected or out-of-order events for every state."
Phase 3: Actionable Verification Steps
To ensure your AI-generated state machine is actually "bug-free," don't just read the code—run it through these verification steps:
Exhaustive State-Transition Matrix Test: Ask the AI to write a comprehensive unit test suite that tests every single defined event against every single state , asserting whether it should transition or safely reject.
Dead-End & Unreachable State Check: Verify that every state has a valid exit path (unless it is an intentional terminal/final state) and that there are no orphan states.
Concurrency/Race Condition Audit: If your state machine handles async operations (like network requests), ensure the model accounts for race conditions (e.g., receiving a SUCCESS event after a TIMEOUT / CANCEL).
To help narrow down the best tool or template for your project, tell me:
What programming language or tech stack are you building this in?
Is the state machine running on the frontend UI, backend service, or embedded hardware?
Does it require handling async side effects (like API requests or timers)?
Describe behavior in natural language and have AI generate an XState state machine.
Build/edit the state machine visually.
Import/export diagrams and machine definitions.
Generate TypeScript/JavaScript from the machine.
Automatically generate test paths/tests.
Validate the resulting machine and visualize its behavior.
The important distinction is that the AI isn't the thing you ultimately trust with correctness. You give it a formal state-machine representation, and XState becomes the deterministic runtime. XState supports hierarchical statecharts, guards, actions, actors, parallel states, etc., specifically for complex logic.
What I'd recommend
For a complex system, I'd use this workflow:
Natural-language requirements
↓
AI / LLM
↓
State machine / XState
↓
┌───────────────┐
│ Static checks │
│ Path analysis │
│ Test generation│
└───────────────┘
↓
Human review
↓
Production code
That's substantially safer than asking Claude/Codex/Cursor to simply "implement this state machine" in ordinary imperative code.
Stately actually has an MCP integration where an agent can create a state machine from a natural-language request, validate machines, and generate runnable Vitest tests for paths through the machine.
If your requirements are really complicated
This is where I'd go one step further.
Instead of asking:
"Write me a state manager that does X, Y, Z..."
I'd give the AI something like:
An order can be draft, submitted, payment_pending, paid, fulfillment_pending, shipped, delivered, cancelled, or refunded.
Payment can fail and retry up to 3 times.
Cancellation is permitted before shipment.
A refund can only occur after payment succeeds.
Shipment and payment confirmation can arrive out of order.
Duplicate events must be idempotent.
Network operations must not cause invalid state transitions.
Generate the statechart and identify every ambiguous or underspecified transition before generating code.
Then have it produce the statechart first, rather than code.
That gives you something humans can inspect visually and something the tooling can systematically test.
One important caveat
I wouldn't promise "bug-free" from any AI system. The hardest bugs in state management usually aren't syntax errors—they're missing states, missing transitions, contradictory requirements, race conditions, unexpected event ordering, and poorly specified failure behavior.
The good news is that state-machine tooling is unusually well suited to exposing those problems. Stately can generate test paths, and XState itself has graph traversal/model-based testing capabilities.
If you tell me what language/framework you're using (TypeScript/React, Python, Kotlin, Swift, etc.) and roughly what your state machine does, I can recommend a concrete AI + state-machine workflow—and, if appropriate, we can design the machine from your natural-language requirements before writing any implementation.
Yes. The closest thing to what you’re describing right now is Stately + XState. It is specifically designed around the workflow:
natural language / diagram → state machine → executable code → simulation → generated tests
stately.ai supports visually modeling state machines/statecharts, generating machines with AI, exporting TypeScript/JavaScript, and generating test paths.
What I'd use
1. Stately + XState — probably the best fit
You can give Stately an English description such as:
"An order starts as pending. Payment can succeed, fail, or time out. A failed payment can be retried up to three times. Once paid, fulfillment begins..."
Stately's AI can create an XState v5 machine from a natural-language request, and its tooling can validate the machine and generate runnable Vitest tests for paths through it.
You can also start from a Mermaid state diagram. Stately Sketch currently understands XState, JSON, YAML, and Mermaid diagrams and turns them into an interactive, simulatable machine.
The underlying XState library is particularly appropriate for complicated machines because it supports hierarchical statecharts, guards, actions, actors, asynchronous effects, and TypeScript.
2. Claude / ChatGPT / Copilot — useful as the engineering layer
I'd use a general coding model after establishing the state machine. Give it the generated XState machine plus your requirements and have it implement:
API calls
persistence
side effects
error handling
React/UI integration
TypeScript types
integration tests
property/invariant tests
The important distinction is that I wouldn't ask an LLM to directly invent the state management architecture and trust the resulting code. That's where subtle transition bugs tend to appear.
Instead:
Natural language requirements
↓
State diagram
↓
Formal state machine
↓
Validate / simulate
↓
Generate test paths
↓
XState code
↓
LLM fills in
implementation
↓
Tests + invariants
That gives the AI considerably less room to "creatively" misunderstand your state transitions.
The really interesting part
Stately's current tooling actually exposes an MCP server with operations such as create_state_machine, validate_machine, and generate_test_code. That means an AI coding agent can potentially work with the state machine as a structured artifact, rather than merely generating text that looks like a state machine.
So you could have a workflow like:
You: "Add a cancellation flow. Cancellation is allowed from pending and processing, but not after shipped. If cancellation occurs during processing, abort the fulfillment request."
AI modifies the machine → visualization updates → validation runs → affected test paths are generated → AI implements the side effects.
That's much closer to AI-assisted formal state-machine engineering than ordinary "ChatGPT, write me a Redux reducer."
One important caveat
There is no AI I'd describe as reliably producing "bug-free" complex state-management code. The useful goal is instead to make the state model executable and mechanically testable so that bugs become much harder to introduce.
For a genuinely complex system, I'd strongly favor:
Stately/XState as the source of truth + an LLM as the implementation agent + generated/path/invariant tests as the safety net.
If you tell me what kind of state machine you're building (frontend UI, backend workflow, agent orchestration, payments/order processing, IoT, etc.) and your language/framework, I can recommend a concrete AI + tooling stack and show you what the workflow would look like end-to-end.
Yes,Stately.ai (the creators of XState) provides an AI-powered visual editor specifically designed to turn natural language prompts or state diagrams into robust, production-ready state management code.
While general-purpose LLMs (like GPT-4o or Claude 3.5 Sonnet) can write state machine boilerplate or switch-case logic from a description, they frequently hallucinate invalid transitions or miss deep edge cases. Specialized tooling bridges this gap by combining formal state logic with AI generation.
Top Tools and Approaches for AI State Machine Generation
Stately Studio (Stately AI) : This platform features an integrated AI assistant where you can describe a workflow in plain English or upload/build a visual state chart. It scaffolds the logic, catches unreachable states or missing transitions, and exports type-safe code using XState for JavaScript/TypeScript.
General LLMs with PlantUML/Mermaid : You can prompt Claude or GPT to output a Mermaid.js state diagram first, review the graph visually, and then ask the model to compile that exact Mermaid syntax into target code (like C++, Python, or Rust). This two-step constraint drastically reduces logic errors compared to generating code directly from raw text.
Formal Specification and Model Checkers : For mission-critical systems, tools like TLA+ or Alloy can be assisted by AI to specify invariants, though translating them into executable code still requires a rigorous framework.
If you want to narrow down the best approach, let me know:
What programming language or framework are you targeting?
Do you have an existing natural language description or a rough sketch you want to test?
Yes, there are specialized tools and AI models built precisely for this, though "bug-free" ultimately still requires human verification . For complex systems, standard LLMs (like ChatGPT or Claude) can write state machine code from a description, but they often hallucinate edge cases or miss impossible state transitions.
Dedicated visual and model-driven AI tools bridge the gap between natural language/diagrams and robust code:
Stately AI - The gold standard for complex state management, centered around XState (JavaScript/TypeScript). Stately features built-in AI tools that let you prompt the system to scaffold behavior, uncover hidden edge cases, visually iterate on statecharts, and generate clean production-ready code.
Eraser.io AI State Diagram Generator - Excellent if you want to feed in a dense natural language PRD, text logs, or a system description, and have AI generate structured state diagrams and logical transition breakdowns that you can export or translate into code.
Mermaid AI State Diagram Generator - Allows you to type plain English descriptions of states, guards, and events, and converts them directly into rigorous Mermaid.js state syntax, which can then be fed into code generators.
LLMs with Structured Output (Claude 3.5 Sonnet / GPT-4o) - If you prefer a code-first approach, feeding a strict prompt into advanced models like Anthropic or OpenAI asking them to output formal definitions (like SCXML, XState JSON, or a typed finite state machine in your target language) works well if you enforce strict TypeScript or Rust type-checking to catch invalid transitions at compile time.
To help narrow down the best path, tell me:
What programming language or framework are you targeting?
Do you already have a natural language draft or rough sketch of the states ready?
Yes, but with an important caveat: no AI can reliably guarantee “bug-free” state management code from a diagram or description alone. Complex state machines usually fail because of missing requirements, ambiguous transitions, race conditions, persistence issues, and unhandled edge cases. The best current workflow is AI-assisted modeling + formal state-machine tooling + generated tests.
Some strong options:
1. Stately + XState — closest match to what you described
stately.ai provides visual statechart modeling, AI-assisted generation, and code export around XState. XState turns state diagrams into executable state machines for JavaScript/TypeScript applications.
Workflow:
Describe behavior in natural language:
“A payment starts in pending. It can move to authorized, declined, refunded. Retries happen up to 3 times. Timeout returns to pending.”
Generate/edit a statechart.
Export machine code.
Generate test paths and validate transitions.
Strengths:
Hierarchical states
Parallel states
Guards
Actions
Visualization
Model-based testing support
This is probably the closest match if you are building application/workflow state.
the diagram (Mermaid, PlantUML, draw.io export, image)
state definitions
events
invariants (“these things must never happen”)
target language/framework
A strong prompt is:
“Convert this statechart into production TypeScript. Use exhaustive transition checking, typed events, immutable state updates, and generate unit tests for every reachable transition and invalid transition.”
They are much better at implementation than inventing the correct model.
3. Mermaid/PlantUML → code workflows
If your team already documents architecture in diagrams, a practical approach is:
Natural language → Mermaid state diagram → AI review → executable state machine
4. AI tools specifically focused on state-machine generation
There are newer tools aimed at this exact niche. For example, X-Reason describes generating XState machines from natural-language task descriptions with visualization and error-handling concepts. X-Reason Smaller projects such as StateForge also explore extracting state machines from descriptions and exporting code.
For a genuinely complex machine, I would use this pipeline
Requirements
↓
AI generates statechart
↓
Human reviews states/events/invariants
↓
Executable state machine framework
↓
AI generates tests
↓
Property-based testing + simulation
↓
Production code
The “bug-free” part comes less from the code generator and more from:
making illegal states impossible
exhaustive transition checking
generated transition tests
simulation of random event sequences
persistence/recovery testing
If you tell me the target stack (React/TypeScript, Python, Java, embedded C, backend workflows, etc.) and whether you already have a diagram, I can suggest a more specific toolchain.
Requirements
↓
AI generates statechart
↓
Human reviews states/events/invariants
↓
Executable state machine framework
↓
AI generates tests
↓
Property-based testing + simulation
↓
Production code
The “bug-free” part comes less from the code generator and more from:
4. AI tools specifically focused on state-machine generation
There are newer tools aimed at this exact niche. For example, X-Reason describes generating XState machines from natural-language task descriptions with visualization and error-handling concepts. Smaller projects such as StateForge also explore extracting state machines from descriptions and exporting code.
For a genuinely complex machine, I would use this pipeline
Yes. The closest thing to what you’re describing right now is Stately + XState, especially if the state machine is complex enough that you care about correctness, visualization, testing, and maintainability.
Stately is specifically built around the idea of making the state machine itself the source of truth, rather than asking an LLM to hallucinate a pile of if/else or Redux/Zustand code. Its current tooling can take natural-language descriptions, generate machines, visualize them, simulate transitions, generate tests, and export TypeScript/JavaScript.
What I'd use
Natural language → state machine → executable code → tests
A good workflow is:
Describe the behavior in English
"An order starts as pending. Payment can succeed, fail, or time out. Failed payments can be retried up to 3 times. Once paid, fulfillment can be processing, shipped, delivered, or cancelled..."
Have AI generate an XState statechart rather than directly generating application code.
Visualize the resulting machine and inspect every state/transition.
Use simulation/model-based testing to explore paths and edge cases.
Export the machine as TypeScript and integrate it into your application.
Stately's MCP integration is particularly interesting here: it exposes a create_state_machine operation that takes a natural-language request and produces normalized XState source, with optional visualization. It can also accept/validate formats including XState, SCXML, Mermaid, JSON and YAML.
Why I prefer this over "ask Claude/ChatGPT to write my state management"
The important distinction is:
LLM-generated code:
requirements
↓
LLM
↓
code
versus:
requirements
↓
LLM
↓
state machine / statechart
↓
visualize + simulate + test
↓
XState
↓
application code
That intermediate state-machine representation is extremely valuable. XState is designed specifically for complex state logic and provides hierarchical states, parallel states, guards, actors, events, effects, etc.
And Stately can generate test paths automatically, which is a much better approach to "robust" than simply trusting an LLM's generated implementation.
There's also a particularly useful AI workflow
If you're using Claude Code, Cursor, Codex, or VS Code/Copilot, Stately now has an MCP server. That means the coding agent can interact with the state-machine tooling rather than merely generating XState from scratch.
For example, you could give an agent:
"Implement the checkout state machine described in checkout.md. Use Stately to model it first. Identify ambiguous transitions and ask me about them. Generate the machine, visualize it, generate test paths for every transition, then integrate it into our TypeScript application."
That's considerably more reliable than:
"Write a checkout state manager."
One important caveat
There is no AI that can honestly guarantee "bug-free" state management from an English description.
The hard part isn't generating the syntax. It's resolving ambiguities such as:
What happens if two events arrive simultaneously?
Can a cancelled operation be resumed?
What happens when an async operation completes after its state has changed?
Are transitions idempotent?
What happens on network failure?
Can states be entered recursively?
Which transitions are impossible?
What invariants must always hold?
Statecharts make these questions explicit, and AI is quite good at helping enumerate them. But I'd make the machine + executable tests the authority, not the LLM.
If you tell me your stack, I can recommend the exact setup
For example, if you're building this in TypeScript/React, I'd strongly consider:
Stately → XState → TypeScript → React
If it's Python, Java/Kotlin, C#, a backend workflow engine, or something like Redux/Zustand, the recommendation changes.
If you give me your natural-language description or paste the state diagram, I can also show you what I would feed into Stately/Claude/Codex and design the state-machine architecture before generating the code.
Yes, tools likeStately AI can turn visual state diagrams or natural language prompts into robust state management code, though no AI currently guarantees entirely "bug-free" logic without human review.
When building complex state machines, combining specialized visual tooling with large language models provides the best balance of deterministic safety and automated scaffolding.
Top Tools and Approaches for AI State Machine Generation
Stately AI : A dedicated platform featuring a visual statechart editor that integrates AI to scaffold behaviors, find edge cases, generate documentation, and export production-ready code via XState (JavaScript/TypeScript).
General-Purpose LLMs (Claude 3.5 Sonnet, GPT-4o): Excellent at translating dense natural language requirements or Mermaid.js state diagrams directly into robust boilerplate code for libraries like SCXML, Spring State Machine (Java), or transitions (Python).
Model Context Protocol (MCP) & Guardrail Engines: Emerging tools like Statewright use explicit state machine definitions to constrain LLM agent actions, ensuring code execution follows strict deterministic paths rather than relying on the AI to "guess" state transitions dynamically.
Best Practices to Ensure Robustness
Use Formal Notations: Feed the AI a structured format like Mermaid State Diagrams rather than loose paragraphs to minimize misinterpretation.
Explicitly Define Edge Cases: Prompt the AI to output handling for invalid transitions, race conditions, and unexpected asynchronous timeouts.
Keep Logic Deterministic: Let the AI write the structural scaffolding, but handle critical guards and transition actions with deterministic code rather than letting an LLM interpret state rules on the fly at runtime.
If you'd like, let me know:
Your target programming language or framework (e.g., TypeScript, Python, Java)
Whether you have an existing diagram/text description you want to test
I can help draft the initial structure or recommend the best library for your stack.
Yes, but the reality of "bug-free" depends heavily on how you approach it. No AI is a silver bullet that outputs 100% production-ready code for a deeply complex system on the first try, but specialized tools combined with modern LLMs can get you remarkably close by bridging visual statecharts and code.
The industry standard ecosystem for this workflow centers around Stately AI and XState , alongside general-purpose LLMs.
Dedicated Tools & Platforms
Stately Studio: Accessible via Stately AI , this platform features an AI-powered flow generator where you can type a natural language prompt, and it will visually generate the state machine/statechart canvas for you. You can also import existing code or modify the graph visually. It natively exports robust, typed code (JavaScript/TypeScript) via XState , ensuring the code matches the visual diagram bidirectionally.
Visual Paradigm AI: If you lean toward traditional UML state machine diagrams, Visual Paradigm Online features an AI chatbot that can generate, iterate on, and refine UML state machines from text prompts, helping map out complex transitions and guard conditions before code generation.
Mermaid AI Generators: Tools like Mermaid Online AI Generator can turn complex natural language edge-case descriptions into Mermaid.js state diagrams, which you can then feed into a code-gen LLM or parse programmatically.
The Best Strategy for "Bug-Free" Code
Instead of asking an AI to write raw state management code from scratch in a single prompt (which often leads to hallucinated transition logic or missed edge cases), use a two-step specification approach:
Generate the Statechart First: Use an interactive visual tool like Stately Studio or a strict text notation (like SCXML or XState JSON) via an LLM. Forcing the AI to output a formal model (states, events, guards, and transitions) rather than implementation code drastically reduces logic bugs.
Compile or Export to Code: Use the established library tied to that model (e.g., XState for JS/TS, or actor-model frameworks in other languages) to execute it. Because state transition math is deterministic, executing a formally defined statechart eliminates whole classes of concurrency and race-condition bugs common in hand-written if/else or boolean flag state management.
To help narrow down the right toolchain, tell me:
What programming language or tech stack (e.g., TypeScript, Python, Rust, C++) are you building this in?
Is it for frontend UI orchestration, backend workflow engine , or embedded/IoT systems?
Yes—but I’d distinguish “AI that writes state-management code” from “AI + a formal state-machine tool that can validate the result.” For a complex state machine, the second is much safer.
My strongest recommendation: Stately + XState
Stately is unusually well suited to exactly what you described.
Import/export using formats including XState, SCXML, JSON, YAML, and Mermaid.
Its MCP integration is particularly interesting: create_state_machine can take a natural-language request and produce a normalized XState v5 machine, while validate_machine can analyze the resulting machine and generate_test_code can generate Vitest tests for paths through it.
And XState itself is designed specifically for complex application logic, with hierarchical/parallel statecharts, guards, actors, effects, and event-driven transitions.
Why I prefer this over “just ask Claude/Copilot”
You can absolutely give Claude Code, GitHub Copilot, or another coding agent a diagram and say:
“Implement this state machine.”
They can produce excellent code. But an LLM-generated implementation isn't inherently guaranteed to preserve every transition, guard, invariant, race condition, or unreachable state.
With Stately/XState, the diagram is itself an executable specification:
Natural language
↓
AI generates
↓
Statechart / diagram
↓
validate
↓
simulate all important paths
↓
generate tests
↓
XState / TypeScript
That gives you a much better defense against the classic AI failure mode of producing code that looks correct but subtly changes the state-transition semantics.
Then have the AI turn it into an XState machine, inspect/visualize it, and generate tests.
Stately's tooling explicitly supports Mermaid and other machine representations, and its visual editor can serve as the source of truth while the code remains synchronized.
What I'd use for a serious project
If you're building something genuinely complicated—say a workflow with 20–100+ states, nested states, async operations, retries, cancellation, permissions, timeouts, and parallel activities—I'd use:
Stately Studio + XState + Claude Code/Codex
Each has a different job:
Stately → model the behavior and visualize it.
XState → execute the state machine.
AI coding agent → implement the surrounding application code, actions, API calls, persistence, UI, etc.
Generated tests → catch discrepancies between intended and implemented behavior.
The important architectural principle is: don't make the LLM the source of truth. Make the state machine the source of truth and make the LLM operate on it.
Stately is explicitly positioning its visual model as that source of truth, including AI-assisted generation and test generation.
One caveat
I would not promise “bug-free.” No current AI can honestly guarantee that for a sufficiently complex system.
But you can get surprisingly close to mechanically constrained correctness by having AI generate a formal state machine, then validating and exhaustively/path-wise testing the machine rather than trusting generated imperative code.
If you tell me what language/framework you're using (TypeScript/React, Python, Kotlin, Swift, etc.) and roughly how complicated the state machine is, I can recommend a concrete AI → diagram → validation → production-code workflow—and potentially show you what the generated architecture would look like.
Then have the AI turn it into an XState machine, inspect/visualize it, and generate tests.
Stately's tooling explicitly supports Mermaid and other machine representations, and its visual editor can serve as the source of truth while the code remains synchronized.
What I'd use for a serious project
If you're building something genuinely complicated—say a workflow with 20–100+ states, nested states, async operations, retries, cancellation, permissions, timeouts, and parallel activities—I'd use: