formal-verify
БесплатноЗапускает вложенные скриптыНе проверенEnd-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…
от opum-ai★ 30 звёзд на GitHubОб этом скилле
formal-verify
Formal models find bugs that tests and reviewers miss because they explore every interleaving and every small input, not the handful someone thought of. An agent can now write the models quickly; the hard parts are choosing what to model, keeping the model honest to the code, and proving a counterexample is real. This skill owns those parts. The tool-specific mechanics live in sibling skills:
| Skill | Use it for |
|---|---|
tlaplus-model |
Interleavings, message passing, retries, liveness, protocols. Exhaustive on small models (TLC) or bounded-symbolic (Apalache/Quint). |
lean-model |
Pure logic and data structures, graph algorithms, state machines needing unbounded proofs, executable reference models for differential testing. |
proof-simplify |
After something is verified: use the proven invariants to delete redundant code, then re-verify. |
Shared material for all four skills sits in this skill's references/. Sibling skills
reach it at ${CLAUDE_SKILL_DIR}/../formal-verify/references/.
Pick the workflow
Read references/workflows.md for the full step list of each. Match the request:
| The user wants… | Workflow |
|---|---|
| "Find bugs / races in X", "is this safe under concurrency" | W1 Bug hunt (default) |
| "Review this PR/diff for races" | W2 Change review — model only the delta and what it touches |
| "Check this design / protocol before we build it" | W3 Design verification — no code yet; spec is the design |
| "Simplify this using the proofs", "is this lock/check needed" | W4 Proof-guided simplification → proof-simplify |
| "Keep this verified", "add the spec to CI" | W5 Regression guard |
| "The code changed — is the spec still right?" | W6 Drift check |
| "Prove it for all N", "TLC passed but I want certainty" | W7 Escalate TLA+ → Lean |
| "Explain this counterexample / TLC trace" | W8 Explain a trace |
W1 Bug hunt — the core loop
Each step exists because skipping it is how formal-methods efforts fail in practice.
- Scope one concern. Pick one shared resource or protocol ("cache fill vs. invalidation", "job claim vs. lease expiry", "DAG executor dispatch"). Rank candidates by blast radius × concurrency. Write a short scope note (in scope, abstracted, out of scope). A whole-system model never converges; a 150-line spec of one concern finds the bug.
- Harvest properties before modeling. Pull invariants from docs, comments,
issue trackers, past fix commits, and API contracts. Cite a source for each
(
README.md:40,#1234). Split them into protocol-level properties (any correct implementation must satisfy them) and code-level ones. Freeze the protocol-level set in its own file (Properties.tla/Properties.lean) and do not weaken it later without the user's explicit OK. Agents that edit their own success criteria "find" no bugs. - Choose the tool. Use
references/choosing-tools.md. Default: TLA+ for anything with interleavings; Lean for algorithmic/data-structure correctness or when an unbounded proof is wanted; both when a protocol wraps a non-trivial algorithm. - Build the correspondence map as you model. Every model action/function gets a
row pointing to
file:linein the source and stating what was abstracted (references/correspondence.md, template inassets/CORRESPONDENCE.md). This is what turns a counterexample into a code-level explanation, and what W6 drift checks read. - Model and check via
tlaplus-modelorlean-model. Always run the sanity checks those skills describe (must-fail invariants, action coverage, mutation of a guard). A spec that cannot fail proves nothing. - Reproduce every counterexample in real code before calling it a bug
(
references/reproduce-and-fix.md). Write a deterministic reproduction that forces the trace's interleaving (barriers, injected delays, fake clocks, controllable executors). Run it against the unchanged code and save the failing log first. It must fail on the property assertion, not on an API or signature change. Honor the user's stated deliverable: if they said "no more unit tests", put the reproduction informal/<concern>/repro/as a script instead of adding it to their test suite. If it will not reproduce, fix the model, not the verdict. Record unreproduced traces as suspected, never as bugs. - Fix, then re-verify. Fix the code, mirror the fix in the model, re-run the model and the new test. Mutation-check the fix: revert it in the model and confirm the property fails again. This proves the property actually guards the bug.
- Record and report. Keep a log of every check you cite in
formal/<concern>/evidence/: TLC or Lean output, coverage,correspondence_check.py, mutation runs, and test runs before and after the fix. Report other problems you noticed along the way (for example, an input the code silently mishandles) as
Установить formal-verify в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл formal-verify?
End-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.
Как установить скилл formal-verify?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл formal-verify запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic