Command Palette

Search for a command to run...

Назад к скиллам
скилл № 99174

formal-verification

Use when tests cannot reach the case that breaks the code: a race, a retry or lease, an out-of-order message, a state machine, a multi-device flow, a parser…

БесплатноЗапускает вложенные скрипты
fcsouzaот fcsouza★ 29 звёзд на GitHub

Установить formal-verification в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Formal verification

A test checks the cases someone thought to write. A formal check covers every case in a stated scope: every order of steps in a model, every input up to a bound, or every input. This skill verifies one property where that matters, and leaves a way to recheck it.

Adapted from the create-formal-verification-skill, maintain-formal-verification-skill and statechart skills in pstack v0.15.46 by Lauren Tan, https://github.com/cursor/plugins/tree/main/pstack, under the MIT licence. Modified: one skill with two modes, a chart drawn from the checker's own output instead of a bundled toolchain, and a property-based route for code no verifier runs on. Licence details: NOTICE.md.

It is one layer, not a replacement for tests. A pass covers the model or the bound, never the whole system.

Pick the mode

  • Create: no check exists for this area. Go to "Create".
  • Maintain: a project skill already runs a model checker, a prover, a verifier or property-based tests against named code, and that code changed. Go to "Maintain".

Find an existing check by what it does, not by its name. If the user asks for maintenance and none exists, say so and offer Create.

Create

1. Choose the target from the code

Answer from the codebase. Ask the user only what you cannot observe. If the user named an area or a bug, start there.

A good target is a promise the code makes, where a break harms users and tests rarely reach the breaking case. Pick the strongest such target, not the one that is easiest to verify. Write the promise and the harm in one plain sentence each before you touch a tool:

  • Promise: "A job never commits its result twice."
  • Harm: "The customer is charged twice."

2. Let the question pick the tool

Question Tool
Can events happen in a bad order? A model checker over a small model of the design. TLA+ with TLC is the default, in any language. See references/tlc.md.
Does the code behave for every input? A verifier that runs on the code itself, if one exists for the language.
No verifier runs on this language Say so. Test the real code with generated inputs. See references/property-based.md. Never test a hand copy of the function.
Must it hold at every size, where a bound is not enough? A proof, for example in Lean. Costly. Say why a bound will not do.

Prefer a tool the repo's developers can install and run. Tell the user which tool you chose and why.

3. Write the check to this standard

  • True to the code. Each step of the model points to code a reviewer can open. One indivisible step in the model is one indivisible step in the code. Names come from this repo.
  • Able to fail. A check you have never seen fail proves nothing. Show each property failing on a broken variant: a removed check, a reordered step.
  • Findings stay findings. If the current code breaks the property, report it. Do not weaken the property or the model until it passes. Do not change product code unless the user asks.
  • Honest about scope. State what is verified, under which bounds and assumptions, and what is left out.
  • Readable without the tool. Tell a counterexample as a short list of steps in the code's own words.
  • Cheap to rerun. One command, a pinned tool version, a run short enough to use on every relevant change.
  • Kept in step. Record the files and functions each check covers, and the commit where you last confirmed the check describes them.

references/example-job-lease/README.md walks one small case end to end: the model in JobLease.tla, a passing config in JobLease.cfg, a broken variant in JobLeaseBroken.cfg, the reader's labels in view.ts, the counterexample as steps, and the chart.

4. Draw the behaviour

A counterexample in model terms convinces you. The person who owns the behaviour needs it in their words. Draw a Mermaid stateDiagram-v2 from the checker's state graph with scripts/dot-to-mermaid.ts, not from memory, so the picture and the checked model cannot drift apart. Mark each state that breaks a rule and give the shortest path to it. Follow references/statechart.md.

Before you show a bug path to anyone, replay it against the real code as a test or a live reproduction, one step per action. If the bug does not occur, assume the model is wrong until you show otherwise.

5. Generate the project skill

Steps 5 and 6 and Maintain mode were not run end to end while this skill was written. The model check, the broken variant, the chart script and the property-based test were.

Write .claude/skills/verify-<area>/SKILL.md in the target repo. Name it after the verified area, such as `verify-job-lease

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • NOTICE.md
  • references/example-job-lease/JobLease.cfg
  • references/example-job-lease/JobLease.tla
  • references/example-job-lease/JobLeaseBroken.cfg
  • references/example-job-lease/README.md
  • references/example-job-lease/view.ts
  • references/property-based.md
  • references/sources.md
  • references/statechart.md
  • references/tlc.md
  • scripts/dot-to-mermaid.ts

FAQ

Что делает скилл formal-verification?

Use when tests cannot reach the case that breaks the code: a race, a retry or lease, an out-of-order message, a state machine, a multi-device flow, a parser. Verifies one property with the tool that fits (a TLA+ model checked with TLC by default, property-based tests on the real code otherwise), shows the check failing on a broken variant, draws the behaviour as a Mermaid statechart a product owner can review, and leaves a project-local skill that rechecks it on every change. Also use when code covered by an existing model has changed and the model must be brought back in line. Phrases: "model check this race", "prove this invariant", "can these two retries overlap", "is the model still true to the code", "prova esse invariante", "model check dessa race", "desenha a máquina de estados".

Как установить скилл formal-verification?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл formal-verification запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить formal-verification с