Model a flow that moves between states in TLA+, check the rules its reader agrees to with the everystate model checker over every order of events, and chart it in the reader's words with the shortest path to each rule that breaks. Use when a flow, protocol, retry loop or state machine needs its rules checked, a bug shown as a path through states, or formal verification is asked for.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
The chart shows how a system moves between states, in the words of its reader: the person who decides whether the behavior is right.
Pick the promise whose break harms users most and that tests rarely reach: the strongest one in the code, never the easiest to model. Read the code for it; ask the user only what the code cannot show.
Name the question before the tool:
| The question | The tool |
|---|---|
| Can events happen in a bad order? | A model checker: this skill |
| Does the code hold for every input? | A verifier that runs on the code; with none for its language, generated inputs on the real code |
| Does it hold at every size, past any bound? | A proof |
A question that is not about order → say which kind it is and stop; sound:find picks the tool.
Write SPEC.tla and SPEC.cfg in a scratch folder, or beside the code they cover when the project keeps them.
\* path:line comment. What the code does in one indivisible step is one action; two steps are two.\* covers: and \* synced:, so a later change to them shows the model may be stale.Next is a disjunction of named actions, Pay \/ Decline, so each step has a name.Done == phase \in {"paid", "failed"} /\ UNCHANGED vars.A module that exports:
state(vars): the reader's words for a state, such as "Paying" or "Lease held, write pending", never a variable name. A set arrives as an array; a sequence, record or function as an object keyed by its domain, so v.pc[1] is pc[1].step(action, from, to): the step as the reader sees it happen, such as "you press pay", or null to hide it. A step that happens only in some conditions ends with them in brackets, in the reader's words: you press play [while the file loads]. Two actions that end the same share a label, and so an arrow.title.Aim for about 20 arrows. First give one label to states that act the same; never one label to states that break different rules. Then hide steps the reader does not need, such as a reset every state has. Hiding keeps every state reachable from a start, one arrow out of each state that has a step out, and all of an arrow or none.
bun ${CLAUDE_SKILL_DIR}/scripts/statechart.ts SPEC.tla --view view.ts --out <folder>It runs everystate, a TLC-compatible model checker, through bunx, so it needs only bun.
It checks each rule in its own run, so one break hides no other rule's verdict, and gives the shortest path to each rule that breaks. It refuses a spec or config everystate cannot read, and a view that would make the chart claim what the model does not do; the message says what to change. Above 500 states it draws only the paths to broken rules. It exits 0 when every rule holds, 1 when one breaks, 2 when it refuses.
Before trusting a pass, break the promise in the real code on a scratch change, such as a removed guard or two steps swapped. Update the model as the code now reads and rerun: a rule must break. Drop the change and rerun: the verdicts are back where they started. A check never seen failing proves nothing.
Diff the covered files from the sync commit, and read each commit message. Sort each change:
Rerun, then give each check one outcome: in sync, updated, bug, or blocked and why. Move the sync commit only once the model describes the code at the new commit.
Show chart.mmd where Mermaid draws: a Pad, a doc, a pull request. Then one line per bug: the rule, the reader's sentence for it, and its path as report.md numbers it. Say what the model leaves out and which steps the chart hides, and give the command that makes the files again.
When the model describes code, replay each bug path against the real code, one step per action, as a test or a live repro. A path that does not replay means the model is wrong until shown otherwise.
saadshahd/moo.md
2a844a8
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.