Find the hidden
state machines
Can't play sound? The illustrated version is right below.
Read the transcript
The full narration of the video.
The AI-written code has no typos. So why does the app still act weird? There's one prompt made for exactly this: "Find all of the implicit state machines in my app." It sounds scary, but it's really just a traffic light.
A well-built traffic light has a single dial inside. Point it at red, red lights up; turn it to green, green lights up. The pointer can only sit on one slot, so red and green can never be on together. Now look at a lazy light. Red, yellow and green each get their own switch, and anyone can flip any of them.
Three switches can make eight different patterns. Only three of them make sense. Nobody thought about the other five, like red and green at the same time. Apps work the same way. Many never get a dial, just little switches scattered around: Is it ringing? Is it connected? Is it a group call?
Together those switches are doing a traffic light's job. Nobody ever drew it out, which is why it's called implicit. In January 2019, Apple's FaceTime ran into exactly this. You call someone, and their phone is still ringing. Then you add your own number, turning it into a group call.
Their phone keeps ringing, yet you can already hear what's going on in their room. One of the people who reported it was a high school student. Apple switched off group calls entirely, and shipped a fix ten days later. Apple's notes said only one thing: improved state management. The details were never made public.
In traffic-light terms, it's as if ringing and connected lit up at the same time. That prompt asks the AI to hunt for these lazy lights. It digs out the scattered switches one by one. It lists every state your app can be in, and which action moves it from one slot to the next.
That list is called a state machine. Drawn out, it's a few circles joined by arrows. In code, it's often a single status line that can only hold one value: ringing, in call, or ended. The circles are the light's colors, and the arrows are the pointer clicking to the next slot.
Once the list is laid out, you can spot at a glance the combinations that shouldn't happen but nothing stops. Next, have the AI swap that pile of switches for one dial. As an app grows, the switches keep piling up.
That's why this prompt works: it adds no new features, it just shows you which two lights can come on together. In something you built with AI, is there a button that acts weird when you tap it twice?
Red and green, both on
The AI-written code has no typos,
yet the app still acts weird.
A common cause: a few switches, each minding its own business, end up in a combination nobody planned for. One prompt is made to find exactly that.
Before asking the AI to fix a weird bug, send this first.
A good light has one dial
It sounds scary, but it's really just a traffic light.
Whatever slot it points to lights up.
each get a switch.
Eight patterns, three make sense
Nobody thought about the other five.
Like red and green together.
These eight were computed, not drawn by hand: each switch is on or off, 2 × 2 × 2 = 8.
Switches scattered in your app
Many apps never get a dial, just little switches in different places. Take a video call:
Together these switches are doing a traffic light's job. Nobody ever drew it out, which is why it's called implicit.
In code they often look like isRinging = true and isConnected = false: one line per switch, spread across different files.
Apple's FaceTime
fell into it once
In January 2019, Apple's FaceTime video calls had a bug.
One of the people who reported it was a high school student. Apple switched off group calls entirely, then shipped the fix in iOS 12.1.4 ten days later.
Apple's notes said only: improved state management. The details were never made public.
In traffic-light terms, it's as if "ringing" and "connected" lit up at the same time.
What the prompt
makes the AI do
That list is called a state machine. Drawn out, it's a few circles joined by arrows: the circles are the light's colors, the arrows are the pointer clicking to the next slot.
In code it's often a single line, status = ringing, that can hold only one value: ringing, in call, or ended. Next, have the AI swap the pile of switches for this one dial.
One thing it doesn't do
the switches pile up.
Quick check
What does the prompt "find the implicit state machines" mainly ask the AI to do?
Like checking a lazy traffic light: it adds no lights, it just finds which two can come on together.

