# /state-machine: See every state of a component on one throwaway page

Source: https://trendhub.net/skills/jakubkrehel-skills/state-machine
Skill folder: https://github.com/jakubkrehel/skills/tree/main/skills/state-machine
Pack: Jakub Krehel's Interface Skills (https://trendhub.net/skills/jakubkrehel-skills)
Works with: Agents supported by the skills CLI

state-machine gives you a workbench for a single component. The agent reads the code for every branch it can render, builds a scratch route that imports the real component, feeds each state with realistic mock data and adds a grouped switcher driven by a search parameter. The page stays up while you work and is removed in one step when you say so.

## When to use it

- You are polishing a table or card and need to see its empty, loading and error states quickly.
- Plan tiers, roles or feature flags change what a component shows.
- Designers want to review states that are hard to reach in the running app.

## How it works

1. **Pick one component**: The agent scopes the run to a single component and restates what it shows, where it renders and where its data comes from.
2. **List reachable states**: It reads the component and its data hooks for data, account and feature states, leaving out anything the code cannot reach and listing designed-but-missing states.
3. **Build the scratch route**: A route inside the app imports the untouched component, inherits the app's layout and providers and keeps fixtures and switcher in one folder.
4. **Feed data at the boundary**: Mock data enters through props or the app's own data seam, looks like real product data, and loading states stay pending until switched.
5. **Confirm and hand over**: Every state is loaded once to confirm the mock data appears, then the agent hands over the URL and stops.

## What it steers the agent away from

- Editing the component or adding branches just to display a state.
- Placeholder data like three rows of test items that hides real layout problems.
- Restyling the component on the scratch page or changing visuals unasked.

## What it can touch

It adds a temporary route folder with fixtures to your app and deletes it, then searches for leftovers, only when you ask.

## Pairs well with

- `/break`
- `/variant`

## Questions

### How is it different from break?

state-machine shows one product state at a time for ongoing work, while break stacks worst-case scenarios on one page for a single inspection.

### Does it work with Next.js server components?

Yes; the skill notes that the scratch page must be client code in Next so fixture data is not lost across the server boundary.
