Implicit state machines prompt: what "find all of the implicit state machines in my app" does, and how to run it
Short answer
The implicit state machines prompt is one line you paste into a coding agent: "find all of the implicit state machines in my app". tldraw founder Steve Ruiz posted it on October 31, 2026, and it now has 1.87 million views and 15,381 bookmarks on X. It asks Claude Code, Codex or Cursor to list every feature whose states are hidden in scattered booleans and if-checks. Those hidden combinations, like "loading" and "error" both true, are where weird bugs live. Run it read-only first, fix the riskiest two or three, and use a discriminated union instead of a big rewrite.
The post is nine words and a pair of quote marks: good prompt "find all of the implicit state machines in my app". It went up at 19:24 Dubai time on October 31. Nine days later it had 1,865,643 views, 8,158 likes and 15,381 bookmarks (X API, November 9). Then it went around a second time. Shopify CEO Tobi Lutke quoted it with "It works" on November 7 (163,279 views, 1,825 bookmarks), and a longer version from @Voxyz_ai on November 8 added 681,497 views and 15,492 bookmarks. Posts on X that mention "implicit state machine" jumped from 12 on November 5 to 146 on November 6 and 372 on November 7.
Lots of people bookmarked it without knowing what the term means. This page covers that, what the prompt actually finds, a safer version to paste, and how to fix the results without breaking your app.
What is an implicit state machine?
An implicit state machine is a feature that has modes but never names them. A checkout can be idle, submitting, failed or paid. A call can be ringing, connected or ended. If the code tracks that with a few booleans and a nullable field, spread across files, the state machine still exists. It is just written down nowhere. statecharts.dev calls this an implied state machine: you have to read the code to work out which states exist and how the feature moves between them.
The problem is the math. Three independent booleans allow 2 x 2 x 2 = 8 combinations. A loading flow usually has 3 or 4 real states. The other combinations, like loading and error both true, or an error with data still showing, are states nobody designed. Nothing in the code stops them, so they show up as the bug that happens once in a while and never on your machine.
let isLoading = false;
let hasError = false;
let user: User | null = null;
// 3 flags = 8 combinations. Which ones are real?
// isLoading && hasError? hasError && user? Nothing stops them.
XState creator David Khourshid put it this way in a quote reproduced by Scott Logic: the logic of an implicit state machine "only exists in the developers' heads". That was a problem when humans wrote all the code. It is a bigger one when an agent adds a new flag every time you ask for a feature.
What does the prompt actually find?
It does not ask the agent to refactor anything. It asks for a list. The agent reads your code, groups the flags that move together, and names the states it thinks they represent. When Steve Ruiz was asked why he runs it, he replied: "so that I can make them explicit, tends to find conflicts." Those conflicts are the impossible combinations above, plus transitions that skip a step, such as a "paid" screen that can be reached without passing through "submitting".
A real-world example of the kind of bug this targets: in January 2019 a Group FaceTime flaw let a caller hear the person they were calling before that person picked up. Apple's fix note for iOS 12.1.4 (released February 7, 2019) describes it as "a logic issue ... in the handling of Group FaceTime calls", "addressed with improved state management." Apple never published the code, so we can't say it was a set of booleans. But "ringing" and "connected" being true at once is exactly the shape of bug the prompt hunts.
What did people get when they ran it?
| Who | What they reported | Post numbers (X API, Nov 9) |
|---|---|---|
| Steve Ruiz (tldraw) | Benchmark charts for the tldraw engine stepping down after the prompt: recolor 500 at 1.33 ms vs a 1.57 ms median, delete selection 1.16 ms vs 1.43 ms, undo delete 7.33 ms vs 7.84 ms (53 runs) | 118,975 views |
| Jamon Holmgren | "I'm up to 200 implicit state machines in my game code base." | 3,858 views |
| Luke Parker (opencode) | 15 opencode desktop PRs merged, "about 250 more implicit state machines are migrating" | 32,438 views, 433 bookmarks |
| Tobi Lutke (Shopify) | "It works" | 163,279 views, 1,825 bookmarks |
| Garrett Petersen | "Major refactor as a result of this", plus a "no implicit state machines" rule in his agent skills | 52,156 views, 1,094 bookmarks |
| Joel Hooks | 24 removed and 3 more gutted in one weekend, using XState | 6,382 views |
| Garry Tan (YC) | Testing the Voxyz version with his own agent setup, results not posted yet | 79,416 views, 758 bookmarks |
Two cautions. First, these are counts people reported, not audited numbers. A model asked to "find all" of something will happily list two booleans that were always meant to be independent. Second, Steve did not say the speedup came only from this prompt; he posted the charts with "Guess which release came after this prompt". We did not run the prompt on a production app for this article.
Get the AI tools worth your time
Era of Minds by Salman Ahmed: one short email with the AI tools and news that actually matter. Free.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime.
How do I run the implicit state machines prompt safely?
The one-liner works as is in Claude Code, Codex, Cursor, Gemini CLI or any agent that can read your repo:
find all of the implicit state machines in my app
On a real codebase we would give it more structure so the output is easy to check and nothing changes yet. This is our version, not Steve's:
Find all of the implicit state machines in this app.
Read only: do not change any code yet.
For each one, list:
1. The feature and the file paths involved
2. The flags, nullable fields or status strings that together act as its state
3. The states you think exist and the transitions between them
4. At least one combination of those values that should be impossible
but the code still allows, with the line that allows it
5. Risk (high / medium / low) and a one-line fix idea
Sort by risk. Skip pairs of booleans that are truly independent.
- Start on a clean branch and commit first, so any change is one command to undo.
- Scope it if the repo is big. "in src/checkout" or "in the sync engine" gives a shorter, more accurate list than the whole monorepo.
- Read the top five yourself. Open each file it names and confirm the impossible combination can really happen. Drop the false positives.
- Fix one at a time with a second prompt, so each change is a small PR with tests:
Take the highest-risk item from your list.
Replace its flags with one explicit state value (a discriminated union
or a reducer) with named transitions. Keep behavior the same.
Add a test for each transition and one for the impossible combination
you found. Show me the diff before touching anything else.
If you already use custom instructions, this pairs well with a skill. Our posts on Taste-Skill and Anatomy show how skills change what Claude Code does by default.
How do I fix implicit state machines without a big rewrite?
You don't need a library. Steve Ruiz says state machines "are just a software pattern, really simple to implement with like a discriminated union. You don't need a library to get majority benefits of the pattern." In TypeScript, the three flags above become one value that can only be in one state:
type UserState =
| { status: "idle" }
| { status: "loading" }
| { status: "error"; message: string }
| { status: "done"; user: User };
// Exactly one state at a time. "loading and error" can't be written.
David Khourshid, who created XState, suggests going from least to most complex:
- Reducers and discriminated unions for most features.
- An event-based store such as Zustand, @xstate/store or Redux Toolkit when several components send events to the same state.
- A statechart library (XState) when you need nested states, testing of every path, or a diagram you can show the team.
His other tip is shorter: "Make sure to use state machine thinking" is his secret prompt weapon when agents create state bugs.
How do I stop my agent from creating new ones?
Finding them once helps. Not creating them again helps more, because agents add a flag every time you ask for "one more loading state". Garrett Petersen's fix was to add the rule to his agent skills. Put a line like this in CLAUDE.md, AGENTS.md or your Cursor rules:
No implicit state machines: when a feature has more than two modes,
model it as one explicit state value (discriminated union or reducer)
with named transitions, not several booleans spread across files.
Then run the audit prompt again after big features. If you run several agents at once, as in Claude Code Projects, give each thread the same rule so they don't each invent their own flags for the same feature.
What is the Voxyz version of the prompt?
The November 8 variant that drove the second wave reads: "Find all of the implicit state machines in my app. Make the best decision that will elevate all three: the user experience (UX), developer experience (DX), and agent experience (AX) always, without breaking anything." It skips the read-only step and lets the agent decide and edit. That is fine on a side project. On anything with users, we would still run the list-first version above, then hand the agent one item at a time.
Why do one-line prompts like this spread so fast? The same thing happened with the advice for next 10 years prompt: a short phrase carries a whole idea the model already knows. Here, the model has read decades of writing about state machines. The phrase just tells it to apply that to your code. For more agents that can run it, see our list of AI tools for coding.
Get the AI tools worth your time
Era of Minds by Salman Ahmed: one short email with the AI tools and news that actually matter. Free.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime.
FAQ: implicit state machines prompt
What is the implicit state machines prompt?
It is the one-line prompt "find all of the implicit state machines in my app", posted by tldraw founder Steve Ruiz on X on October 31, 2026. You paste it into Claude Code, Codex, Cursor or another coding agent, and the agent lists the places where your code tracks a mode with scattered flags instead of one named state. By November 9 the post had about 1.87 million views and 15,381 bookmarks.
What is an implicit state machine?
It is a feature that has states (idle, loading, failed, done) but never names them in one place. The states live in a few booleans, nullable fields and if-checks spread across files. statecharts.dev calls this an implied state machine: you have to read the code to find out which states exist and how the feature moves between them.
Why does the prompt find bugs?
Three independent booleans allow 8 combinations, and usually only 3 or 4 of them make sense. The rest, like loading and error both true, are states nobody designed for. Asking the agent to list each hidden state machine and its transitions puts those impossible-but-reachable combinations in front of you. Steve Ruiz said it "tends to find conflicts".
Does the implicit state machines prompt work in Claude Code and Codex?
Yes. It is plain English, so it works in any coding agent that can read your repository, including Claude Code, Codex, Cursor and Gemini CLI. The people sharing results on X used several of them; one developer described Gemini designing the explicit machines, Opus 5.5 building them, and a separate agent reviewing the PRs.
Should the agent fix the state machines right away?
Not on the first pass. Run it read-only, get a list with file paths, the flags involved and one impossible combination for each, then pick the riskiest two or three. The counts a model reports can be inflated, so treat the list as candidates to check, not a finished inventory.
Do I need XState to fix implicit state machines?
No. Steve Ruiz says a discriminated union gets you most of the benefit without a library. XState creator David Khourshid suggests going from least to most complex: reducers and discriminated unions, then an event-based store such as Zustand, @xstate/store or Redux Toolkit, then a statechart library like XState when you need testing or visualization.
How many implicit state machines will it find?
It depends on the codebase. Jamon Holmgren reported 200 in his game codebase on the first day, Luke Parker said about 250 were migrating in the opencode desktop app after 15 merged PRs, and Joel Hooks said his team removed 24 in one weekend. Those are counts reported on X, not audited numbers.
Is there a version of the prompt for other parts of my work?
Yes. A variant that went viral on November 8 asks the agent to find all implicit state machines and improve user experience, developer experience and agent experience at once without breaking anything (681K views). Garrett Petersen added a "no implicit state machines" rule to his agent skills so new code avoids them from the start.
Sources
- @steveruizok on X, October 31, 2026 and replies 1, 2, 3 (metrics via X API, November 9, 2026)
- @Voxyz_ai, November 8, 2026; @tobi, November 7, 2026; @jamonholmgren, October 31, 2026; @GarrettPetersen, November 7, 2026; @LukeParkerDev, November 4, 2026; @joelhooks, November 8, 2026; @garrytan, November 9, 2026
- @DavidKPiano on fixing state and on state machine thinking
- statecharts.dev: You're already coding statecharts, they're just implied
- Scott Logic: Finite State Machines, the developer's bug spray (2020)
- Apple: About the security content of iOS 12.1.4 (CVE-2019-6223)
Get AI news decoded weekly.
Decoded is a free weekly email from Era of Minds. The AI stories that actually matter, in plain English. Five minutes, no hype.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime. Free gift: 50 AI prompts that actually work, sent the moment you join. More about Decoded