/code-slop:statechartfrom code-slop
Model a flow of an app in TLA+, check its rules with TLC, and draw it as a PlantUML statechart for a stakeholder to review. Use for /statechart, to review a requirement as states and steps, or to show a bug as a path through states. The commands that write and check a chart need the JVM library code-slop-models in any JVM build, and without it, the skill runs TLC by hand.
Ships in code-slop. 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.
None: SKILL.md is the whole skill.
A statechart shows one flow of an app as states and steps, labeled in the words of the person who judges the behavior:
the stakeholder of a requirement, a student, or a reviewer. TLC checks the rules of the flow in every state of a TLA+
model, and the chart marks the states in which a rule breaks. The rules of
rules/models.toml of
code-slop, except structure-model-matches-classes and value-rules-match-model, state the principles, and a copy that
code-slop vendor wrote has them in <skill-dir>/../../code-slop/catalog/rules/models.toml. This skill applies them
with TLA+, TLC, and PlantUML.
The table [models] of code-slop.toml (or .code-slop.toml, config/code-slop.toml, or
.claude/code-slop/code-slop.toml) names each path. Without a key, use the files that the repository already has. For
a new model, propose the default to the user, and record the path in [models] when the user changes it.
| Key | Default | Content |
|---|---|---|
readme | the existing README of the models, else models/README.md | the models, the commands that check them, and what they leave out |
tla | the folder of the existing .tla files, else models/tla | <Model>.tla, the TLA+ module, and <Model>.cfg, its constants and INVARIANTS |
views | the folder of the existing views | <Model>View, the words of the chart |
statecharts | the folder of the existing charts, else docs/statecharts | <Model>.puml and <Model>.svg, the chart |
reports | a folder that Git ignores, such as the build output of the repository | <Model>/report.txt, the report, next to the output of each run of TLC |
Read the file readme first. It names each model with the requirements that it covers, the commands of the
repository, the replay tests, and what the models leave out. The repository lists the view of each model that has a
chart in one place, such as a map VIEWS in the main function of the models on the JVM.
Run the commands that the file readme names. A JVM build with the library code-slop-models has the command
statechart <write|check> <tla> <statecharts> <reports>, which the main function of the views of the repository runs
(models/README.md of code-slop):
gradle statecharts and gradle checkStatecharts.java -cp, with the jars of the library, PlantUML, the Kotlin standard library, and the
classes of the views on the classpath.TLA2TOOLS names the jar of TLC. Without it, the library takes the jar that mise pins as
http:tla2tools.The mode write checks each model and writes the chart of each model with a view. The mode check fails when a rule
breaks, or when a view has a sentence for a rule that the configuration does not check. It also fails when a chart
differs from its model, or when a chart has no model with a view (rules-as-invariants, diagrams-derived-from-model).
Commit the .puml and the .svg together with the model. PlantUML lays out the chart with Smetana, its port of
Graphviz dot, so the build needs no Graphviz.
Without the library, run TLC by hand, which writes the state graph:
java -cp tla2tools.jar tlc2.TLC -config <Model>.cfg -dump dot,actionlabels <reports>/<Model>.dot <Model>.tla
Then write the PlantUML chart from the state graph in the words of the view, and render it with PlantUML. Tell the
user that no check compares the chart with the model (diagrams-derived-from-model).
model-order-dependent-flows). The comment at the top of the module names the requirements
and the classes that it follows.CanCancel for the function cancel of an order service (small-model-named-steps)..cfg. A rule about information that the model does not
hold needs a new variable. A broken rule is a finding, so do not change the rule to make it hold
(rules-as-invariants).Next is a disjunction of named actions, such as Place \/ Pay \/ Cancel, because the view labels each step by
its action and the replay test maps each action to a function (small-model-named-steps).MaxItems = 2, and an order of events instead of a clock keep the number of states small.
For example, a model of a time window can store the age of each payment as "recent" or "old" and close the windows
in the order of the payments (small-model-named-steps).NoDeadlock. When such a state is a correct end,
add an action that only this state enables and that changes no variable. The command does not support a CONSTRAINT,
with which TLC leaves out the steps from the states at the bound, or a PROPERTY.The view gives the chart the words of its reader (statechart-in-reader-words). On the JVM, it implements ChartView
of the library code-slop-models.
state() maps a model state to its label, after the labels of its parent states, such as
listOf("The order is paid", "A customer can cancel the order"). A label states the property that defines the
state, with the terms of GLOSSARY.md, not the names of variables. Model states with the same label become one chart
state.title names the flow and its requirements in the words of the stakeholder, such as "Order of a customer (FR-2,
FR-5)". The caption names the TLA+ model as the source of the chart, so that a reader knows that TLC derived
every state and step and that a test checks the model against the code.step() maps a step to the label of its arrow, or returns null to hide the step. A label names the actor in the third
person, such as "a customer cancels an order" or "a clerk refunds an order". The reader of the chart is a
stakeholder or a reviewer, not an actor in the model, so a label never says "you". A label says "a customer", not
"the customer", because no label refers to a customer that the reader already knows.rules maps each INVARIANT to the sentence that the stakeholder accepted.panels splits the chart into panels side by side, such as one for the steps of a customer and one for the steps of a
clerk. Each panel draws every state and the arrows of the actions that it lists. The command fails unless exactly one
panel lists the action of an arrow. Use panels when the steps of one actor lead between almost all states and hide the
flow of another actor.NoDeadlock.
The report gives the shortest path to a state that breaks each rule, in the words of the chart.A model of existing code gets a replay test (replay-model-steps-on-code), which the file readme names for each
model:
<Model>Replay.cfg. For
each step, it builds the state before the step in the code in several ways. Examples are other orders of the earlier
steps and, in a flow with a time window, its last instant. Then it calls the function of the action and compares the
result with the state after the step.map-actions-to-functions).replay-model-bounds-at-limits).replay-model-bounds-at-limits).A model of concurrent requests has no chart. It extends the model of one request and computes the result of each
request with its operators, which the replay test of the model of one request checks against the code. Its rule
Serializable requires that the requests end in a state that some order of the same requests reaches one after
another. When the code uses transactions, locks, or versions, its test checks the model with and without each of these
mechanisms. The test also checks each assumption of the model in the code, such as the transaction of each function and
the function that reads a row with a lock (test-model-assumptions).
docs/models/jvm.md of
code-slop shows how a JVM app connects its functions to the actions and how the tests find them.
Give the stakeholder the SVG, and for each broken rule its sentence and its shortest path from the report. Name what the
model leaves out (report-model-to-stakeholder). When the replay test fails, compare the step with the requirement
before you change the model or the code.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub se-uhd/code-slop-skill --plugin code-slop9 skills in this plugin
/adversarial-reviewReview the code of a whole repository adversarially for defects of functional correctness, safety and security, robustness, maintainability and readability, architecture, and documentation, and for fixes that hide a defect instead of removing its cause, and report only the defects that a reproduction or the exact lines show. Use when the user asks for an adversarial, critical, deep, or security review of a repository or a code base, asks to find the bugs or the weak points of a project, wants an audit before a release, or runs `/code-slop:adversarial-review`. Runs the deterministic checks of code-slop first, gives each area to an independent reviewer (a subagent in Claude Code and Codex), lets a second pass try to disprove each finding, and writes `build/code-slop/adversarial-review.md`. Changes nothing in the repository. For a change, a branch, a commit range, or a pull request, use `/code-slop:adversarial-review-diff`./adversarial-review-diffReview one change adversarially for defects of functional correctness, safety and security, robustness, maintainability and readability, architecture, and documentation, and for fixes that hide a defect instead of removing its cause in the changed lines and the code that depends on them. The change is the diff from the merge base with the default branch to the working tree, a commit range, or a pull request or merge request by its number, which gh or glab read without changing it. Use when the user asks to review, break, or audit a change, a branch, a commit range, a PR, or an MR adversarially, asks what a change breaks, wants a critical review before a merge, or runs `/code-slop:adversarial-review-diff`. Runs the deterministic checks of code-slop on the change, gives each area to an independent reviewer, lets a second pass try to disprove each finding, and writes `build/code-slop/adversarial-review-diff.md`. Changes nothing in the repository./domain-modelModel the stored classes of an app and the rules for their values in Alloy, check the model against the code, and draw it as a PlantUML class diagram. Use for /domain-model, when a class or a property of the domain changes, to find where the layers of an app state different limits, or to review the domain as a diagram. The commands that write and check a diagram need the JVM library code-slop-models, and without it, the skill runs the Alloy Analyzer by hand./glossaryBuild or maintain GLOSSARY.md for a code repository and check its terminology. Use when the user asks for a glossary of a code base, for proposed definitions, for a check of competing names, or for a check that the comments, the Markdown documents, the messages of the program, and the identifiers use one term for each concept, or runs `/code-slop:glossary`. Reads the text through the language adapters and lexers of code-slop with `code-slop glossary`, and writes definitions in the form of ISO 704 and in the format of the glossary of ai-slop. Flags competing names, avoided terms, new terms without a definition, and deficient definitions. Writes the glossary and `build/code-slop/glossary-report.md`, and validates an existing glossary with --check./review-commentsReview the comments and doc comments of a repository, or of the files that a change touches, against the comment catalog of code-slop. Finds comments that narrate or restate the code, explanations that belong in a decision record, pointers to missing records, doc comments that are too long or document private code, missing contracts, filler phrases, and markers of unfinished work. Use when the user asks to review, audit, or clean up the comments of a repository or a change, or runs `/code-slop:review-comments`. Runs `check-comments` and the native tools that the language profiles name, judges the rest against the catalog, and writes `build/code-slop/review-comments.md`. Covers Kotlin, Go, TypeScript and JavaScript, Swift, shell, Lua, Python, and AppleScript./review-testsReview the tests of a whole repository for tests that cannot fail when the behavior breaks (tautological tests), tests that fail when only the implementation changes, tests that never run, and flaky tests. Use when the user asks to review, audit, or check the tests or the test quality of a repository, or runs `/code-slop:review-tests`. Runs the deterministic scanner first, then judges the candidates and the patterns that need judgment against the test catalog, confirms the strongest findings by changing the code in a scratch worktree, and writes `build/code-slop/review-tests.md`. Covers Kotlin, Go, TypeScript and JavaScript, Swift, and shell tests through the profiles of their frameworks.