Skip to content
cccskills
FreePublished on GitHub

statechart

Turn a TLA+ model or an agreed system flow into a Mermaid statechart, a diagram of states and transitions. It highlights numbered paths that break stated rules, helps check whether modeled bugs occur in code, and can create a TLA+ skeleton from a chart.

OriginalShow the original description

Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states.

michael-denyer/pstack-claude3,612 stars(GitHub 3,612 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Visualize how a product flow or service changes states
  • Trace the path that violates a system rule
  • Turn an agreed statechart into a TLA+ model skeleton

Files included (200)

  • SKILL.md8.9 KB
  • references/render.md3.6 KB
  • scripts/backends/cfg.ts1.2 KB
  • scripts/backends/mermaid.ts7.3 KB
  • scripts/backends/plain-text.ts2.3 KB
  • scripts/backends/report.ts6.9 KB
  • scripts/bun.lock555 B
  • scripts/frontends/config.ts10.4 KB
  • scripts/frontends/dot.ts2.4 KB
  • scripts/frontends/marks.ts3.2 KB
  • scripts/frontends/messages.ts1.8 KB
  • scripts/frontends/spec.ts4.1 KB
  • scripts/frontends/trace.ts988 B
  • scripts/frontends/value.ts4.6 KB
  • scripts/frontends/verdict.ts1.7 KB
  • scripts/frontends/view.ts4.3 KB
  • scripts/ir.ts14.8 KB
  • scripts/package.json233 B
  • scripts/passes/annotate.ts3.7 KB
  • scripts/passes/label.ts8.4 KB
  • scripts/passes/lift.ts2.8 KB
  • scripts/passes/loop-check.ts2.1 KB
  • scripts/passes/paths.ts1.9 KB
  • scripts/passes/reach.ts4.0 KB
  • scripts/passes/region-check.ts3.4 KB
  • scripts/passes/regions.ts9.3 KB
  • scripts/pipeline.ts2.9 KB
  • scripts/run.ts16.9 KB
  • scripts/statechart991 B
  • scripts/statechart.ts5.9 KB
  • scripts/test/chart.test.ts38.8 KB
  • scripts/test/charts/Braces.mmd312 B
  • scripts/test/charts/Escapes.mmd244 B
  • scripts/test/charts/Phases.mmd584 B
  • scripts/test/cli.test.ts49.2 KB
  • scripts/test/config-fuzz.test.ts8.5 KB
  • scripts/test/ConfigOracle.java2.7 KB
  • scripts/test/corpus.test.ts12.5 KB
  • scripts/test/corpus/Counter/chart.mmd112 B
  • scripts/test/corpus/Counter/ChartRun.out2.6 KB
  • scripts/test/corpus/Counter/Counter.cfg64 B
  • scripts/test/corpus/Counter/Counter.tla185 B
  • scripts/test/corpus/Counter/graph.dot633 B
  • scripts/test/corpus/Counter/report.md243 B
  • scripts/test/corpus/Counter/sany.out37.3 KB
  • scripts/test/corpus/Counter/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterAction/chart.mmd518 B
  • scripts/test/corpus/CounterAction/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterAction/CounterAction.cfg89 B
  • scripts/test/corpus/CounterAction/CounterAction.tla255 B
  • scripts/test/corpus/CounterAction/graph.dot798 B
  • scripts/test/corpus/CounterAction/report.md436 B
  • scripts/test/corpus/CounterAction/sany.out42.9 KB
  • scripts/test/corpus/CounterAction/verdict-1.exit3 B
  • scripts/test/corpus/CounterAction/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterAction/verdict-2.exit3 B
  • scripts/test/corpus/CounterAction/verdict-2.out3.1 KB
  • scripts/test/corpus/CounterAction/verdict-3.out2.6 KB
  • scripts/test/corpus/CounterDeadlock/chart.mmd462 B
  • scripts/test/corpus/CounterDeadlock/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterDeadlock/CounterDeadlock.cfg63 B
  • scripts/test/corpus/CounterDeadlock/CounterDeadlock.tla225 B
  • scripts/test/corpus/CounterDeadlock/graph.dot633 B
  • scripts/test/corpus/CounterDeadlock/report.md624 B
  • scripts/test/corpus/CounterDeadlock/sany.out41.8 KB
  • scripts/test/corpus/CounterDeadlock/verdict-1.exit3 B
  • scripts/test/corpus/CounterDeadlock/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterDeadlock/verdict-2.exit3 B
  • scripts/test/corpus/CounterDeadlock/verdict-2.out3.0 KB
  • scripts/test/corpus/CounterFan/chart.mmd1.7 KB
  • scripts/test/corpus/CounterFan/ChartRun.out3.1 KB
  • scripts/test/corpus/CounterFan/CounterFan.cfg37 B
  • scripts/test/corpus/CounterFan/CounterFan.tla338 B
  • scripts/test/corpus/CounterFan/graph.dot5.3 KB
  • scripts/test/corpus/CounterFan/report.md239 B
  • scripts/test/corpus/CounterFan/sany.out48.4 KB
  • scripts/test/corpus/CounterFan/verdict-1.exit3 B
  • scripts/test/corpus/CounterFan/verdict-1.out2.4 KB
  • scripts/test/corpus/CounterFan/verdict-2.out2.6 KB
  • scripts/test/corpus/CounterGuard/chart.mmd63 B
  • scripts/test/corpus/CounterGuard/ChartRun.exit3 B
  • scripts/test/corpus/CounterGuard/ChartRun.out3.3 KB
  • scripts/test/corpus/CounterGuard/CounterGuard.cfg66 B
  • scripts/test/corpus/CounterGuard/CounterGuard.tla192 B
  • scripts/test/corpus/CounterGuard/graph.dot302 B
  • scripts/test/corpus/CounterGuard/report.md954 B
  • scripts/test/corpus/CounterGuard/sany.out36.1 KB
  • scripts/test/corpus/CounterGuard/verdict-1.exit3 B
  • scripts/test/corpus/CounterGuard/verdict-1.out2.4 KB
  • scripts/test/corpus/CounterGuard/verdict-2.exit3 B
  • scripts/test/corpus/CounterGuard/verdict-2.out2.9 KB
  • scripts/test/corpus/CounterInitPast/chart.mmd282 B
  • scripts/test/corpus/CounterInitPast/ChartRun.out2.5 KB
  • scripts/test/corpus/CounterInitPast/CounterInitPast.cfg54 B
  • scripts/test/corpus/CounterInitPast/CounterInitPast.tla169 B
  • scripts/test/corpus/CounterInitPast/graph.dot84 B
  • scripts/test/corpus/CounterInitPast/report.md425 B
  • scripts/test/corpus/CounterInitPast/sany.out35.3 KB
  • scripts/test/corpus/CounterInitPast/verdict-1.exit3 B
  • scripts/test/corpus/CounterInitPast/verdict-1.out1.3 KB
  • scripts/test/corpus/CounterInitPast/verdict-2.out2.5 KB
  • scripts/test/corpus/CounterInitPastHolds/chart.mmd16 B
  • scripts/test/corpus/CounterInitPastHolds/ChartRun.out2.5 KB
  • scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.cfg50 B
  • scripts/test/corpus/CounterInitPastHolds/CounterInitPastHolds.tla171 B
  • scripts/test/corpus/CounterInitPastHolds/graph.dot84 B
  • scripts/test/corpus/CounterInitPastHolds/report.md211 B
  • scripts/test/corpus/CounterInitPastHolds/sany.out34.8 KB
  • scripts/test/corpus/CounterInitPastHolds/verdict-1.out2.0 KB
  • scripts/test/corpus/CounterInstance/chart.mmd326 B
  • scripts/test/corpus/CounterInstance/ChartRun.out2.8 KB
  • scripts/test/corpus/CounterInstance/CounterInstance.cfg41 B
  • scripts/test/corpus/CounterInstance/CounterInstance.tla217 B
  • scripts/test/corpus/CounterInstance/CounterSteps.tla113 B
  • scripts/test/corpus/CounterInstance/graph.dot599 B
  • scripts/test/corpus/CounterInstance/report.md295 B
  • scripts/test/corpus/CounterInstance/sany.out73.3 KB
  • scripts/test/corpus/CounterInstance/verdict-1.exit3 B
  • scripts/test/corpus/CounterInstance/verdict-1.out3.0 KB
  • scripts/test/corpus/CounterJump/chart.mmd547 B
  • scripts/test/corpus/CounterJump/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterJump/CounterJump.cfg57 B
  • scripts/test/corpus/CounterJump/CounterJump.tla303 B
  • scripts/test/corpus/CounterJump/graph.dot1.0 KB
  • scripts/test/corpus/CounterJump/report.md374 B
  • scripts/test/corpus/CounterJump/sany.out44.9 KB
  • scripts/test/corpus/CounterJump/verdict-1.exit3 B
  • scripts/test/corpus/CounterJump/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterJump/verdict-2.out2.6 KB
  • scripts/test/corpus/CounterLoop/chart.mmd320 B
  • scripts/test/corpus/CounterLoop/ChartRun.out2.6 KB
  • scripts/test/corpus/CounterLoop/CounterLoop.cfg41 B
  • scripts/test/corpus/CounterLoop/CounterLoop.tla232 B
  • scripts/test/corpus/CounterLoop/graph.dot593 B
  • scripts/test/corpus/CounterLoop/report.md285 B
  • scripts/test/corpus/CounterLoop/sany.out41.5 KB
  • scripts/test/corpus/CounterLoop/verdict-1.exit3 B
  • scripts/test/corpus/CounterLoop/verdict-1.out2.8 KB
  • scripts/test/corpus/CounterOrder/chart.mmd406 B
  • scripts/test/corpus/CounterOrder/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterOrder/CounterOrder.cfg51 B
  • scripts/test/corpus/CounterOrder/CounterOrder.tla194 B
  • scripts/test/corpus/CounterOrder/graph.dot299 B
  • scripts/test/corpus/CounterOrder/report.md606 B
  • scripts/test/corpus/CounterOrder/sany.out39.0 KB
  • scripts/test/corpus/CounterOrder/verdict-1.exit3 B
  • scripts/test/corpus/CounterOrder/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterOrder/verdict-2.exit3 B
  • scripts/test/corpus/CounterOrder/verdict-2.out2.7 KB
  • scripts/test/corpus/CounterRules/chart.mmd485 B
  • scripts/test/corpus/CounterRules/ChartRun.out2.9 KB
  • scripts/test/corpus/CounterRules/CounterRules.cfg79 B
  • scripts/test/corpus/CounterRules/CounterRules.tla265 B
  • scripts/test/corpus/CounterRules/graph.dot302 B
  • scripts/test/corpus/CounterRules/Moves.tla70 B
  • scripts/test/corpus/CounterRules/report.md509 B
  • scripts/test/corpus/CounterRules/sany.out60.8 KB
  • scripts/test/corpus/CounterRules/verdict-1.exit3 B
  • scripts/test/corpus/CounterRules/verdict-1.out2.2 KB
  • scripts/test/corpus/CounterRules/verdict-2.exit3 B
  • scripts/test/corpus/CounterRules/verdict-2.out2.7 KB
  • scripts/test/corpus/CounterRules/verdict-3.exit3 B
  • scripts/test/corpus/CounterRules/verdict-3.out3.0 KB
  • scripts/test/corpus/CounterRules/verdict-4.out2.8 KB
  • scripts/test/corpus/CounterStart/chart.mmd351 B
  • scripts/test/corpus/CounterStart/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterStart/CounterStart.cfg53 B
  • scripts/test/corpus/CounterStart/CounterStart.tla180 B
  • scripts/test/corpus/CounterStart/graph.dot466 B
  • scripts/test/corpus/CounterStart/report.md343 B
  • scripts/test/corpus/CounterStart/sany.out36.6 KB
  • scripts/test/corpus/CounterStart/verdict-1.exit3 B
  • scripts/test/corpus/CounterStart/verdict-1.out1.3 KB
  • scripts/test/corpus/CounterStart/verdict-2.out2.6 KB
  • scripts/test/corpus/CounterStop/chart.mmd87 B
  • scripts/test/corpus/CounterStop/ChartRun.out2.6 KB
  • scripts/test/corpus/CounterStop/CounterStop.cfg53 B
  • scripts/test/corpus/CounterStop/CounterStop.tla172 B
  • scripts/test/corpus/CounterStop/graph.dot466 B
  • scripts/test/corpus/CounterStop/report.md127 B
  • scripts/test/corpus/CounterStop/sany.out36.1 KB
  • scripts/test/corpus/CounterStop/verdict-1.out2.2 KB
  • scripts/test/corpus/CounterTie/chart.mmd600 B
  • scripts/test/corpus/CounterTie/ChartRun.out2.8 KB
  • scripts/test/corpus/CounterTie/CounterTie.cfg96 B
  • scripts/test/corpus/CounterTie/CounterTie.tla263 B
  • scripts/test/corpus/CounterTie/graph.dot798 B
  • scripts/test/corpus/CounterTie/report.md675 B
  • scripts/test/corpus/CounterTie/sany.out44.3 KB
  • scripts/test/corpus/CounterTie/verdict-1.exit3 B
  • scripts/test/corpus/CounterTie/verdict-1.out2.1 KB
  • scripts/test/corpus/CounterTie/verdict-2.exit3 B
  • scripts/test/corpus/CounterTie/verdict-2.out2.5 KB
  • scripts/test/corpus/CounterTie/verdict-3.exit3 B
  • scripts/test/corpus/CounterTie/verdict-3.out3.2 KB
  • scripts/test/corpus/CounterTie/verdict-4.out2.6 KB
  • scripts/test/corpus/CounterTieInGraph/chart.mmd455 B
  • scripts/test/corpus/CounterTieInGraph/ChartRun.out2.7 KB
  • scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.cfg72 B
  • scripts/test/corpus/CounterTieInGraph/CounterTieInGraph.tla283 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

Statechart

The chart shows how a system moves between states, in the words of the person who reads it. That person, the reader, decides whether the behavior is right.

Run

Work in a scratch folder outside the repo. Write a TLA+ spec and its config. Then run:

<skill dir>/scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR]

scripts/statechart.ts is TypeScript, so run it with a runtime that can execute TypeScript.

The first run installs TLC and Java with mise and needs the network.

Write the spec

  • Write each rule that the reader agrees to as an INVARIANT. A rule can be about a screen, a result, a stored value, or a message. If the model has no variable for a rule, add the variable. Never weaken a rule to make it hold.
  • Write Next as a disjunction of the actions, such as YouPressPlay \/ YouPressStop. If you do not, TLC names every step Next.
  • A state with no step out breaks NoDeadlock, also when it is a correct end state. When an INVARIANT or a PROPERTY already has that name, the rule is CHECK_DEADLOCK. Add to Next an action that is true only in the end states and changes nothing, such as Done == phase \in {"paid", "failed"} /\ UNCHANGED vars, and give it a label in step().

Pick the chart

You do the work that needs judgment: the words on each state and arrow, the phases and their colors, the title, and the report to the reader. Put your work in a view module, and give it with --view.

To show the reader's words, the view exports state(vars). The value that state() returns picks the form:

  • A string gives a flat chart: export const state = (v) => (v.paid ? "Paid" : "Paying");
  • An array gives parent states: export const state = (v) => v.main.split(".");
  • An object gives one parallel region for each key: export const state = (v) => ({ Playback: v.playback, Volume: v.volume });

Label each state with what the reader can see or cares about, such as "Paying" or "Lease held, write pending". Keep variable names out of labels. In vars, a TLA+ sequence is an object with keys from 1, so v.pc[1] is pc[1]. A set is an array.

The view can also export step(action, from, to). It gets the TLC action name and the values before and after the step, and it returns the label of the arrow. Write each step label as the user sees it happen, such as "you press play" or "the connect fails". Do not name the code or the TLA+ action. Two actions that end the same in the chart get the same label, so that they share one arrow.

When a step can occur only in some conditions, end its label with the condition in brackets, in the reader's words, such as you press play [while the file loads]. In a regions chart, the command writes the condition on the other regions on the arrow, in the words of their labels, such as [when Offline]. Your brackets replace it, and two arrows from one state can then look the same. So in a regions chart, do not write brackets for a condition on another region. When a value that no label shows decides where a step goes, name the result in the label, such as "the roster read fails".

The view can also export these:

  • group(vars) returns the name of a phase. Each chart state gets the color of its group. When the model states behind one chart state are in different groups, that state gets no color.
  • colors gives each group name a color class.
  • title is a string that the chart shows at the top.

The command calls state() and group() at most once for each model state, and step() at most once for each step. The chart and the report both use those answers. So make each function depend only on its arguments.

The chart does not draw a step that stays in one label. Split a label when the reader must see such a step.

Aim for about 20 arrows or fewer, because a busier chart is hard to read. First return coarser labels from state(). Give one label to values that act the same, and leave out a detail that the reader does not need, such as a call in flight whose return changes nothing. Keep each state of a bug path, and keep each mark. When a merge changes a breaks state to mayBreak, it hides where a rule breaks. Do not merge two states that break different rules, because the reader then cannot see which rule breaks where. If the chart is still too busy, return null from step() for the steps that the reader does not need, such as a reset that every state has, or a step whose arrow repeats what other arrows show. Obey these rules when you hide steps:

  • Keep each chart state reachable by arrows from a start state.
  • Keep at least one arrow out of each chart state that has a step out in the model.
  • Hide all the steps of an arrow, or none of them. When you hide only some, its condition gets narrower.
  • In the hand-off, say which steps the chart hides.

Read the report

  • In the chart, a state that breaks a rule has the class breaks. When only some model states behind it break the rule, it has the class mayBreak. The Legend names the rules of each mark. When two rules break, it names both on one mark, so say in the hand-off which state breaks which rule. In a regions chart, a state gets a mark when each combination of region states that includes it can break a rule. When a combination can break a rule and none of its states has a mark, each state in that combination gets a mark.
  • TLC goes past a state that breaks a rule, so the chart shows the states after a bug.
  • Because TLC goes past bugs, a model with no limit on its states can run without end. Keep the constants small, or add a CONSTRAINT.
  • With a VIEW or a SYMMETRY, TLC counts states that it treats as the same as one state, and the chart draws that one state. An arrow can lead to it rather than to the state that the step reaches, and the report says so.
  • TLC checks the rules in each state past a CONSTRAINT or an ACTION_CONSTRAINT, but it does not explore that state or check it for deadlock. When TLC's shortest path for a rule ends in such a state, the chart draws that state, and the report gives that path. The chart does not draw the other states past the bound. A deadlock in such a state does not show. TLC also checks the rules after each step that an ACTION_CONSTRAINT excludes, also when it reaches the next state another way. When TLC's shortest path for a rule ends with such a step, the chart draws that step.
  • The command checks the rules with TLC on the config as written, with one worker. When a rule breaks, the command removes that rule and runs TLC again, until no rule breaks. After the first break, each run stops at 100,000 distinct states, so that a large model does not run without end. When a run reaches that bound or stops on an error, the report lists the rules that it did not check under "Rules not checked", and the chart does not mark them. A rule that is not checked can hold or break. To check it, remove the rules that break from the config, or make the model smaller. The bound adds a module that changes TLC's order of the variables, so for a property TLC can find a different counterexample than a run without the bound.
  • tlc.out is what TLC printed on the config as written. When the chart does not show the bug path of a rule that breaks, tlc-RULE.out is what TLC printed for the run that found it. When TLC repeats its first warning, plain TLC prints it twice, but tlc.out shows it once, because TLC leaves the second copy out of the output that this command reads. That happens only when Java runs with -XX:+UseParallelGC, since otherwise TLC's first warning is its advice to pass that flag, which it prints once.

Show the chart

Show chart.mmd to the user as a mermaid code block. The chart has a budget of 500 states, counted by TLC on the config as written. Above that, the chart draws only the paths to the rules that break, and when no rule breaks, the command writes no chart.mmd. It still checks each rule, and the report gives the state count and each bug path. To see the whole graph, make the model smaller.

Render charts with Pele. When the user asks for an image, or a chart is too large to read as text, follow references/render.md. Do not use a different renderer unless the user asks for it.

Hand off

Give each chart and its Mermaid text to the person who must decide. Add one line for each bug: the rule, the reader's sentence for that rule, and the path as the report numbers it. Say what the model leaves out. Give the command that makes the files again, with a new --out folder.

When the model describes code, replay each bug path against the real code, as a test or a live repro, one step for each action. If a bug does not occur, think that the model is wrong until you show that it is not.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

architect

FreeSummary

Plan types, function inputs and outputs, and module boundaries before implementation. Compare structurally different designs from multiple AI models, document the chosen approach, and guide coding while tracking changes to the agreed design.

  • Designing a complex feature before coding
  • Comparing alternative module structures
  • Keeping implementation aligned with design decisions
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

arena

FreeSummary

Generate several candidate solutions in parallel, compare them against concrete criteria, and choose a base. Combine useful parts from other candidates, then verify the final artifact and document why each major choice was made.

  • Compare multiple designs before choosing a direction
  • Explore different implementations of the same task
  • Combine useful elements from competing drafts
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

automate-me

FreeSummary

Turn recurring work habits and communication preferences into a personal agent skill. It combines evidence from workspace conversations with direct questions, then drafts or updates instructions for how agents should work with you.

  • Capture preferred response length and tone
  • Document testing and review expectations
  • Update personal instructions as work habits change
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

babysit

FreeSummary

Monitor an open pull request, fix failing automated checks and merge conflicts, and address straightforward review feedback. Recheck after updates, report the resulting status, and hand decisions requiring design judgment back to the user.

  • Following up on an open PR without repeated prompts
  • Fixing failed automated checks and rechecking results
  • Addressing straightforward review comments
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

Checks whether performance measurements support a speedup, slowdown, or technology choice. It examines bottlenecks, production settings, errors, repeatability, and completed work, then guides reporting with run counts, ranges, and a clear verdict.

  • Checking before-and-after performance claims in a PR
  • Comparing libraries or configurations fairly
  • Investigating suspicious benchmark results
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

blast-radius

FreeSummary

Investigate what a code change could break beyond the edited files. Trace downstream effects, identify the key assumption behind its safety, and test that assumption with real code while clearly reporting unresolved risks.

  • Checking the wider impact of a small code change
  • Verifying assumptions about existing code before design
  • Testing the safety assumption before merging a change
michael-denyer/pstack-claude3.6KUpdated Oct 29, 2026

See all skills by michael-denyer

Report a problem with this skill