/inconvenient-skills:statechartfrom inconvenient-skills
Turn a TLA+ model of a product flow, protocol, or service into a reader-facing Mermaid statechart with counterexample paths, or chart a Lean 4 proof as a plain-English lemma graph and proof tree that flags gaps, failing steps, native code, and custom axioms. Use when asked to draw state transitions, explain a modeled bug as a path through states, explain or audit a Lean proof, or chart a model or proof from formal-verify.
Ships in inconvenient-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The chart shows how a system moves between states, or how a Lean 4 proof holds together, in the words of the person who reads it. That person, the reader, decides whether the behavior or the proof is right.
scripts/statechart.ts is TypeScript, so run it with a runtime that can execute TypeScript. scripts/statechart is a POSIX shell script that picks one: Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. On native Windows, run node --disable-warning=ExperimentalWarning <skill dir>/scripts/statechart.ts with Node 22.18 to 22.x, or Node 23.6 or later. The first positional argument picks the mode: a .tla spec or a .lean file. --out DIR must be new or empty in both modes.
Work in a scratch folder outside the repo. For a standalone chart, write a TLA+ spec and its config if the user has not supplied them. If formal-verify sent you here, use the exact spec and config it checked, including its bounds and rules, and use the same TLC build where supported. If the chart requires a different checker build, disclose the difference and keep the original verdict authoritative. Put presentation changes in the view, not in the model or config. Then run:
<skill dir>/scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR]
Use mise to install the pinned TLC and Java on first run (network required), or set TLA2TOOLS to the absolute path of an existing tla2tools.jar and optionally JAVA to a Java 11 or later binary. --tactics applies only to Lean and exits 2 on a .tla input.
Run against a .lean file in a package pinned to Lean v4.34.1, or a standalone .lean file with no lean-toolchain. If formal-verify sent you here, chart the exact file and theorem it checked.
<skill dir>/scripts/statechart FILE.lean THEOREM [--view FILE] [--tactics] [--out DIR]
THEOREM is a full declaration name or a unique dotted suffix in FILE.lean. An unsafe declaration or a definition that is not a theorem exits 2.--out at a scratch folder outside the repo. Without it, output goes to <short-theorem>-proof beside FILE.lean.--tactics shows the raw Lean tactic lines inside the proof-tree boxes. --config applies only to TLA+ and exits 2 on a .lean input.LEAN_SYSROOT, then lean and lake on PATH from the package root, then a pinned mise http:lean install of v4.34.1, which needs the network on first run. Every binary it finds must report v4.34.1; any other pin or version exits 2.lake setup-file in place, which writes the gitignored .lake/ folder and may create lake-manifest.json. Copy the package into a scratch folder first to keep those out of the checkout.Use these rules when writing a standalone model.
Next as a disjunction of the actions, such as YouPressPlay \/ YouPressStop. If you do not, TLC names every step Next.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().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.
Use only a trusted view module: the compiler executes its JavaScript or TypeScript.
To show the reader's words, the view exports state(vars). The value that state() returns picks the form:
export const state = (v) => (v.paid ? "Paid" : "Paying");export const state = (v) => v.main.split(".");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:
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.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.One run elaborates FILE.lean once and writes up to four files:
lemmas.mmd: the theorem's dependency graph as a flowchart TD, capped at 60 nodes. Each lemma shows its docstring summary above its short name, and arrows mean "uses". Solid edges cross only compiler auxiliaries; dotted via def edges cross user definitions, opaques, or inductives; thick edges trace the shortest unproven paths.proof.mmd: the proof tree as a flowchart TD when the theorem has tactic steps, capped at 40 blocks. Boxes drop type and binder preambles and translate the standard case tags (mp, mpr, inl, inr, zero, succ, nil, cons, true, false) into plain English. Without --tactics, a box shows the claim, new local assumptions, lemmas used, and one outcome: Proven, Unproven gap (sorry), Failing step, Open goal, or Depends on unproven gap.report.md: the verdict, the shortest unproven paths, the full axiom list, untruncated hypotheses, goals, and tactic scripts for each block, lemma statements, and the Lean diagnostics for the target theorem.facts.json: the raw facts that scripts/lean/Extract.lean extracted.Put the reader's words in a trusted --view module; the compiler executes it. Each export is optional:
title: a string, or { lemmas?, proof? } for one title per chart.lemma(info): a plain-English label, { label, group?, hide? }, null to hide a clean supporting lemma, or undefined for the default.group(info): a plain-English subgraph title in place of a raw module name, null, or undefined.branch(info): a plain-English label, or { label, detail? }, for a proof-tree box. info has a stable id such as "root" or "root.0", plus goal, newHyps, tactics, lemmas, status, caseTag, rawCaseTag, depth, isRoot, isLeaf, and times. When times > 1 folds branches with different goals, goal is "" and newHyps is empty.caseLabel(tag, info): a plain-English label for the edge into a split branch, or undefined.The compiler keeps the chart honest whatever the view says:
sorry or a failing step, a custom axiom, a native computation, or a lemma that depends on an unproven gap or an axiom. Trying exits 2.report.md.0: the proof is closed and uses at most propext, Classical.choice, and Quot.sound.1: an audit finding: sorry, a failing step in the target theorem, an open goal, unchecked native code such as native_decide or Lean.ofReduceBool, or a custom axiom.2: bad arguments, a bad --view export or a view that breaks the rules above, an unsupported Lean pin, a file with a module header, a missing or ambiguous theorem, or an internal invariant failure.130 or 143: SIGINT or SIGTERM stopped the run, and it wrote nothing.The chart explains a proof. It does not replace a standalone lake build or an axiom check as a verification gate.
For TLA+, 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.
For Lean 4, show lemmas.mmd first and offer proof.mmd as the drill-down, each as a mermaid code block.
When the user asks for an image, or a chart is too large to read as text, follow the Pele render instructions. Mermaid-only output does not need Pele. Use a different renderer only if the user asks for it.
Give each chart and its Mermaid text to the person who must decide, with the command that makes the files again into a new --out folder.
report.md, and any supporting lemmas the view hides.For TLA+, treat each path as evidence about the model and config, not the implementation. When formal-verify sent you here, return the chart and report to that caller for its own evidence hand-off. Otherwise, when the model describes existing code, replay each bug path against the real code, as a test or a live repro, one step for each action. If replay needs the real user-facing surface, call the Skill tool with verify for that path. If a bug does not occur, treat it as a model mismatch until you show otherwise. Report model findings and replay results separately, including any paths you could not replay.
LICENSE (opens in a new tab)agents/openai.yaml (opens in a new tab)references/render.md (opens in a new tab)scripts/backends/cfg.ts (opens in a new tab)scripts/backends/mermaid.ts (opens in a new tab)scripts/backends/plain-text.ts (opens in a new tab)scripts/backends/report.ts (opens in a new tab)scripts/frontends/config.ts (opens in a new tab)scripts/frontends/dot.ts (opens in a new tab)scripts/frontends/marks.ts (opens in a new tab)scripts/frontends/messages.ts (opens in a new tab)scripts/frontends/spec.ts (opens in a new tab)scripts/frontends/trace.ts (opens in a new tab)scripts/frontends/value.ts (opens in a new tab)scripts/frontends/verdict.ts (opens in a new tab)scripts/frontends/view.ts (opens in a new tab)scripts/ir.ts (opens in a new tab)scripts/janitor.ts (opens in a new tab)scripts/kill.ts (opens in a new tab)scripts/lean/Extract.lean (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub the-inconvenience-store/skills --plugin inconvenient-skills45 skills in this plugin
/ask-inconvenientAsk which skill or flow fits your situation. A router over the skills in this repo./blast-radiusCheck what a risky change could break beyond the diff and test the safety assumption on real code. Use when asked for the blast radius or when a change can affect downstream consumers, shared state, or durable data./bootstrap-skillsConfigure a repo for the engineering skills: issue tracking, triage labels, domain docs, development guardrails, and repeatable real-surface verification. Run once before first use of the other engineering skills./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./code-reviewReview the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X"./diagnosing-bugsDiagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.