/proof-skills:tlaplus-modelfrom Proof Skills
Writes, runs, and debugs TLA+/PlusCal/Quint specs with TLC model-checker. Handles counterexample traces, invariant violations, liveness, fairness, and concurrency bugs in distributed systems.
Ships in Proof 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.
TLA+ describes a system as state plus actions (atomic steps). TLC explores every interleaving of those actions from every initial state, within the bounds you give it, and returns the shortest trace that breaks a property. That exhaustive search is what finds races no test would hit. The skill's job is to make the model faithful, small, and able to fail.
When the task is a full bug hunt, follow formal-verify for the outer loop: scope, properties,
correspondence map, reproduction, fix, and report. This skill covers the modeling and checking inside it.
S=${CLAUDE_SKILL_DIR}/scripts
$S/setup_tla.sh --with-jre # tla2tools.jar + CommunityModules (+ portable JRE if no Java)
$S/tlc.sh Spec.tla --sany-only # parse/level-check: the fast inner loop
$S/tlc.sh Spec.tla --config MC.cfg # model check; writes .tlc-out/MC/{tlc.log,cex.json,trace.md}
$S/tlc.sh Spec.tla --config MC.cfg -- -simulate num=200000 -depth 60 # random walks for big models
tlc.sh runs SANY, then TLC with -workers auto, and saves the JSON counterexample. It also
prints a step table (action, code pointer, changed variables) produced by parse_tlc_trace.py.
It exits with TLC's code: 0 ok, 11 deadlock, 12 invariant, 13 temporal/action property,
10 ASSUME/POSTCONDITION false, 150 parse error. Full CLI notes: references/tlc-cli.md.
Start from a pattern. assets/patterns/ has seven small, runnable, checked specs.
Each has a fix toggle and three configs (MC.cfg passes, MC_bug.cfg fails, and
MC_sanity.cfg fails on purpose). Copy the closest one, then read references/patterns.md.
| Code shape | Pattern |
|---|---|
| read-modify-write, counters, check-then-act, locks | LostUpdate |
| async/await, cache-aside, fill vs. invalidate | CacheAside (+ trace validation harness) |
| retries, webhooks, at-least-once delivery, dedup tables | IdempotentRetry |
| leases, job claiming, leader leases, GC pauses, fencing tokens | JobLease |
| streams, queues, batching, backpressure, end-of-stream | BatchPipeline |
| DAG executors, build systems, workflow engines, graph invariants | DagScheduler |
| persisted status fields, order/payment/ticket lifecycles | OrderStateMachine |
Pick the atomicity. One action is one atomic region of the real code:
awaits,Merging regions the code runs separately hides exactly the race you want. Put
\* src: path:lines above each action. formal-verify uses these tags for its
correspondence map, drift checks, and trace tables.
Model only what the properties need. Collections become sets or functions, and
payloads become small ranges. Keep 2 actors and 2–3 values at first. Time becomes an
Expire/Timeout action rather than a clock. The environment (network drop, crash, pause)
becomes explicit actions, so their interleavings are explored too.
Write properties before running.
[][status' # status => <<status, status'>> \in Allowed]_vars.<>, ~>) needs fairness (see step 6).Guard "coherence" invariants with a quiescence predicate when mid-flight staleness is legitimate.
Prove the model can fail. Before trusting a green run:
-coverage 1 shows no action that is never enabled.A spec that has never failed is not evidence.
Add fairness honestly. Liveness needs WF_vars(A) or SF_vars(A) on the actions the
real system guarantees will eventually run (a scheduler runs ready work, a consumer keeps
polling). Never put fairness on environment faults, and never add it only to make a
property pass. Keep liveness and symmetry in separate configs: symmetry reduction is unsound
for liveness.
Read the counterexample. Use trace.md, then tell the story in domain terms. Decide
between a real bug, a model artifact (a missing guard, or steps merged or split wrongly),
and a property that is too strong. Hand real bugs back to formal-verify for reproduction.
Scale carefully. Grow one bound at a time. If the state space explodes:
SYMMETRY set (safety only),VIEW to drop auxiliary variables,CONSTRAINT (and report it),-simulate,references/apalache-quint.md).None == -1 needs EXTENDS Integers; Naturals has no unary minus. Mixing strings, model
values, and integers in comparisons is legal only for model values; otherwise use one type per variable.IF … THEN … ELSE … swallows every conjunct after it. Parenthesize: x' = (IF c THEN a ELSE b).UNCHANGED). A missing one means
"any value", which gives states that make no sense. TypeOK catches it.Terminated == Done /\ UNCHANGED vars
disjunct rather than disabling deadlock checking; -deadlock hides real stuck states.Properties.tla),
CONSTRAINTs, and fairness changes are reported in the findings, never quietly edited.assets/patterns/CacheAside/TraceCacheAside.tla is a
working harness (trace-ok.ndjson is accepted; trace-drift.ndjson is rejected with
exit 10). See references/trace-validation.md.quint run --mbt, or TLC -simulate with -dumpTrace json).INSTANCE … WITH, checked as
a PROPERTY). proof-simplify uses refinement to show a simpler design keeps the guarantees.references/patterns.md — the seven patterns: the bug each one finds, the fix, and how to adapt it.references/tlc-cli.md — TLC/SANY/PlusCal flags, .cfg keywords, exit codes, performance.references/pitfalls.md — vacuity, over- and under-modeling, liveness traps, agent reward hacking.references/trace-validation.md — logging events from code and replaying them in TLC.references/apalache-quint.md — when and how to use Apalache and Quint instead of TLC.assets/patterns/BatchPipeline/BatchPipeline.tla (opens in a new tab)assets/patterns/BatchPipeline/MC.cfg (opens in a new tab)assets/patterns/BatchPipeline/MC_bug.cfg (opens in a new tab)assets/patterns/BatchPipeline/MC_sanity.cfg (opens in a new tab)assets/patterns/CacheAside/CacheAside.tla (opens in a new tab)assets/patterns/CacheAside/MC.cfg (opens in a new tab)assets/patterns/CacheAside/MC_bug.cfg (opens in a new tab)assets/patterns/CacheAside/MC_sanity.cfg (opens in a new tab)assets/patterns/CacheAside/Trace.cfg (opens in a new tab)assets/patterns/CacheAside/TraceCacheAside.tla (opens in a new tab)assets/patterns/CacheAside/trace-drift.ndjson (opens in a new tab)assets/patterns/CacheAside/trace-ok.ndjson (opens in a new tab)assets/patterns/DagScheduler/DagScheduler.tla (opens in a new tab)assets/patterns/DagScheduler/MC.cfg (opens in a new tab)assets/patterns/DagScheduler/MC_bug.cfg (opens in a new tab)assets/patterns/DagScheduler/MC_sanity.cfg (opens in a new tab)assets/patterns/IdempotentRetry/IdempotentRetry.tla (opens in a new tab)assets/patterns/IdempotentRetry/MC.cfg (opens in a new tab)assets/patterns/IdempotentRetry/MC_bug.cfg (opens in a new tab)assets/patterns/IdempotentRetry/MC_sanity.cfg (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
proof-skills@opum is listed by opum-ai/opum-marketplace — review the source before installing
npx claudepluginhub opum-ai/opum-marketplace --plugin proof-skills4 skills in this plugin
/formal-verifyEnd-to-end formal-methods bug hunting for real codebases in any language — scope a risky concern, model it in TLA+ and/or Lean 4, check it, turn every counterexample into a failing test, fix the code, re-verify, and publish the results as an Artifact report. Use this skill whenever the user wants to find race conditions, lost updates, deadlocks, stale caches, double-applied retries, broken idempotency, message reordering or loss bugs, state-machine violations, dataflow/pipeline loss or duplication, or graph/DAG/scheduler bugs; whenever they say "formally verify", "model check", "prove", "TLA+", "Lean", "invariant", "spec this out", "is this thread-safe", "can this race", or ask for a concurrency/async/distributed review of a module or PR — even if they never name a formal-methods tool. Also the entry point for keeping specs in CI and detecting spec/code drift. Routes to tlaplus-model, lean-model, and proof-simplify for the tool-specific work./lean-modelUse this skill to prove or refute properties of real software in Lean 4. The target is the user's own code, not textbook math. It covers state machines, concurrency and interleavings, async handlers, retries and idempotency, queues, batching pipelines, and graph algorithms such as topological order, acyclicity and DAG scheduling. Trigger it when the user wants a guarantee for every input or size ("holds for all N"), beyond what TLC, tests or a model checker showed. Also trigger it for invariant proofs by induction, a concrete counterexample trace, an executable reference model for differential testing, or setting up a Lean/lake project to model code. Also use it to audit a Lean development's trust base: sorry, axioms, native_decide. Do NOT use it for pure mathematics such as analysis, algebra or Mathlib coursework and homework. Do NOT use it to translate code into Lean syntax, or for other provers like Dafny, Coq or Isabelle. Pairs with formal-verify for bug hunts and tlaplus-model for protocol exploration./proof-simplifyUse verified TLA+ specs and Lean proofs to simplify real code safely — delete defensive checks the invariants make dead, remove locks/transactions/retries that do no work, collapse redundant states and flags, replace complex implementations with simpler ones proven equivalent, and encode invariants in types — re-verifying every change (re-check, refinement, reachable-state equivalence) before touching code. Use this skill whenever the user asks to simplify, clean up, de-risk a refactor, or reduce complexity in code that has (or could get) a formal model; asks "do we still need this lock / check / retry / state"; wants to turn proofs into code improvements; or finishes a formal-verify bug hunt and wants the payoff. If no verified model exists yet, it starts one via formal-verify first.Other plugins' skills for the same job