/vstack:statechartfrom vstack
Check a TLA+ model or a Lean 4 proof and draw it as Mermaid. For TLA+, TLC checks rules and shows shortest bug paths. For Lean 4, draw lemma dependencies and proof trees in plain English, flagging unproven gaps, failing steps, native code, and custom axioms. Use for /statechart.
Ships in vstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The chart shows how a TLA+ system moves between states or how a Lean 4 theorem is proved, in the words of the person who reads it. That person, the reader, decides whether the behavior or proof is right. The reader can be a product manager, an engineer, or a reviewer. State labels say what the reader observes, such as "Paying". Step labels say the event that moves the system, such as "tap Pay" or "lease expires". Code identifiers stay out of both.
This skill reads a model and draws it. To build a lasting verify skill around a model, use /create-formal-verification-skill. To bring one back in line with the code, use /maintain-formal-verification-skill.
Pick one, and say which:
If the code already has a spec, copy it to the scratch folder and chart the copy. Keep its invariants. Tie each variable and each action to code that a reviewer can open, and keep one indivisible step in the code as one action in the model. As an option, check your copy against the config that the spec's authors pass with.
scripts/statechart.ts is TypeScript. scripts/statechart is a POSIX shell script that picks 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 TLA+ or Lean 4 mode. --out DIR must be new or empty in both modes. --tactics and --config apply only to their respective modes and exit 2 on the wrong input kind.
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]
The first TLA+ run installs TLC and Java with mise and needs the network. Without mise, set TLA2TOOLS to the path of tla2tools.jar, and JAVA to a java binary (Java 11 or later).
Run against a .lean file pinned to Lean v4.34.1, or a standalone .lean file with no lean-toolchain:
<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. Unsafe declarations and non-theorem definitions exit 2. Without --out, output goes to <short-theorem>-proof beside FILE.lean; prefer a scratch folder outside the repo. Toolchain lookup checks LEAN_SYSROOT, then lean and lake on PATH from the package root, then a pinned mise http:lean install for v4.34.1; any other pin or version exits 2. Lake packages: lake setup-file writes .lake/ in place, so copy the package to a temp folder first. Outputs, view modules, soundness rules, and exit codes: follow references/lean-workflow.md.
Next as a disjunction of the actions, such as YouPressPlay \/ YouPressStop. If you do not, TLC names every step Next. Give an action that the reader drives its own disjunct when the reader must see it apart from what the system does.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.
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". When two steps end in the same state for different causes, name the cause in each label.
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.Groups are optional. A state that breaks a rule keeps its own mark whatever its group.
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. For a large overview, keep the shortest paths to the settled states and each bug path. 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.Read each chart and each report yourself before you show them. Follow each numbered path in order. Fix a label that reads like code.
When you propose a fix, write it as a second model, run the command on it with a new --out folder, and show both charts.
Show chart.mmd for TLA+, or lemmas.mmd first with optional proof.mmd for Lean 4, as mermaid code blocks. For TLA+, 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.
Use this direction when the owners must agree on the behavior before a model exists.
stateDiagram-v2. Give each independent part of the system its own region. Write one %% never comment line for each rule. Draw a restart or a stop as an arrow onward, not as a dead end.Give each chart and its Mermaid text to the person who must decide, with the rendered image when you made one. For TLA+, add one line for each bug: the rule, the reader's sentence for that rule, and the path as the report numbers it. For each bug, also say whether you reproduced it against the real code, and whether the proposed fix holds in the second model. When the chart shows no path for a bug, give the counterexample from the tlc-RULE.out file. Quote the state count and the lists of rules from the report as it prints them. Say what the model leaves out. For Lean 4, lead with lemmas.mmd, include proof.mmd as optional drill-down, list each unproven path and the exit verdict from report.md, and note any supporting lemmas hidden by --view. Give the command that makes the files again, with a new --out folder. Point the people who will maintain the model at /create-formal-verification-skill and /maintain-formal-verification-skill.
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. Drive the code only through its real entry points, and judge it only by what a user or a caller can observe. If a bug does not occur, think that the model is wrong until you show that it is not. Then fix the model, not the rule. When the model describes a design that has no code yet, the checker's trace is the evidence. Say so.
references/lean-workflow.md (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)scripts/lean/backends/lemma-chart.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub blackviperxiii-ui/vstack --plugin vstack74 skills in this plugin
/architectSketch types, signatures, and module structure before code, then stay in the loop while implementation fills in. Use for /architect, 'architect this', 'design this', or non-trivial work where jumping to code would lock in the wrong shape./arenaSpawn N parallel candidates at the same task, pick a base, graft the strongest parts of the losers into it. Use for /arena, 'arena this', 'throw it in the arena', or when one attempt at a large or contested design or other non-trivial artifact would lock in the wrong shape./automate-meUse for 'automate me', 'create/update/refresh my -mode skill', 'turn/capture my preferences or working style into a skill', or wanting agents to follow how the user works. Drafts or revises a personal -mode skill via create-skill + unslop, optionally pulling fresh evidence from recent transcripts. /automate-meOther plugins' skills for the same job