lean-interact: Skill for Claude Code

.claude/skills/formalize/SKILL.md

formalize is a skill for Claude Code from nasqret/lean-interact. It costs 168 tokens per session (4,398 once invoked), scanned A, original, MIT.

A workflow for expressing ordinary mathematics as Lean 4 code and making Lean verify the proof. Lean 4 is a programming language and proof checker, while Mathlib is its library of mathematical results.

In plain words
What is it for?
Use it for mathematical claims, definitions, exercises, conjectures, or questions about how to state and prove something in Lean.
Why use it?
It turns informal claims into precise statements and catches missing assumptions or errors through compilation. The workflow also guides the user through understanding the claim before writing code.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: reads .claude/ paths.

This is nasqret/lean-interact's own configuration. It tells Claude Code how to work on lean-interact itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything lean-interact configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is python3 tools/mlq.py "modEq trans" # free-text over the index.

Reuse

Borrowing it

Nothing to install: this file belongs to nasqret/lean-interact. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/nasqret/lean-interact/main/.claude/skills/formalize/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/nasqret/lean-interact

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for formalize

README.md
[![agentmods](https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize/github.svg)](https://agentmods.dev/skills/nasqret/lean-interact/formalize)
Your own site
<a href="https://agentmods.dev/skills/nasqret/lean-interact/formalize"><img src="https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for formalize

Your own site · 80×15
<a href="https://agentmods.dev/skills/nasqret/lean-interact/formalize"><img src="https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 168 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,398 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00168 $0.04398
Opus 5.5 $0.00067 $0.01759
Sonnet 5.5 $0.00034 $0.00880
Haiku 4.5 $0.00017 $0.00440

Measured 2mo ago against content hash 4f6a803e68ff, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

formalize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/formalize/SKILL.md · 315 lines

How it starts

The opening of the file, as written. The whole thing — 315 lines — stays where its author put it; the contents beside it link to each section on GitHub.

formalize

The core loop of this repository. The user — a working mathematician who knows the mathematics and is learning Lean — types a sentence of ordinary mathematics; you return compiled Lean plus a short teaching note.

Repository root: /path/to/lean-interact, the directory this clone lives in. Use absolute paths when reading and editing files. Run the tools/ scripts from the repository root with repo-relative paths (python3 tools/mlq.py …): that is the form .claude/settings.json allows without a permission prompt, and it is the form to show the user.

Before the first formalization of a session, read MEMORY.md and vault/Formalization Style.md. They contain decisions you would otherwise contradict.

Run the steps in order. Do not skip steps because the claim looks easy; the cheap steps are the ones that prevent the expensive mistakes.


Step 1 - UNDERSTAND

Restate the claim as precise mathematics before touching any file. Make explicit, in one short paragraph:

  • every quantifier and its range;
  • every hypothesis, including the ones ordinary prose leaves silent (p prime often means odd; "a/b" often means b ∣ a; "the order of a" presupposes gcd(a, n) = 1);
  • the ambient type.

Choose the ambient type using vault/Nat vs Int vs ZMod.md. If that note is not present yet, use the table in vault/Formalization Style.md section 1. The short version:

The claim is about Type
counting, divisibility, gcd, primes, no subtraction ℕ, with Nat.ModEq for congruences
genuine differences, negatives, Bezout coefficients ℤ, with Int.ModEq
a fixed numeral modulus, ring or unit structure mod n, squares, orders ZMod n
a quantified modulus n Nat.ModEq / Int.ModEq, never ZMod n (dependent type pain)

Ambiguity rule. Ask at most ONE short question, and only if the answer would change the statement. Otherwise state the assumption in one clause and continue: "Taking n > 0 and a coprime to n; say if you meant otherwise." Never open a formalization with a list of questions.

Read the full file on GitHub · 315 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 315 lines · 168 tokens per session scan A 4f6a803e68ff

Subscribe to this mod's changes

formalize is a skill published in the GitHub repository nasqret/lean-interact (11 stars, last pushed 2mo ago), licensed MIT. It adds 168 tokens to every session and 4,398 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

screen

Screen informal↔Lean 4 statement pairs for faithfulness defects. Use whenever writing, editing, translating, or reviewing Lean 4 theorem or definition statements that are meant to formalize informal mathematics: after drafting a statement, before committing formalizations, when auditing a benchmark file, or when the…

ibrahimmian36/leanscreen · 0 tokens

lean-probe

Fast Lean 4 proof verification for coding agents via the LeanProbe MCP server's warm REPL. Use when you need to know whether Lean 4 code compiles (no errors, no sorry), iterate on a declaration inside a Lake/Mathlib project, test a replacement proof candidate, or explore a goal tactic by tactic — far faster than lake…

epfl-lara/LeanProbe · 139 tokens

mathlib-api

Evidence-driven workflow for designing a Mathlib definition and the API around it. Use when adding a new structure/def intended for mathlib; when choosing between design alternatives (index type as field vs parameter, Set vs indexed family, coarse set vs finer indexed structure and when the fine one should exist at…

homeowmorphism/mathlib-api · 234 tokens

lean-expert

Lean 4 theorem-prover expertise for agents -- current versions, tactic cookbook, Mathlib search, compiler-error recoveries. Use when proving, debugging, or explaining Lean 4 proofs via leanforge-mcp.

sandraschi/leanforge-mcp · 47 tokens

pub-cycle

Publication Cycle — scans the main theory paper, identifies new paper extractions and existing paper gaps, then orchestrates the full review+fix pipeline. Workflow: Triage → Codex review+fix (2 rounds) → ChatGPT review → Codex fix → Claude review → Codex fix → ChatGPT journal-targeted acceptance gate. During wait…

the-omega-institute/automath · 103 tokens

lean4-proof

This skill covers proving bounds on recursively-defined sequences in Lean 4, using the pattern of.

EtaYang10th/spark-skills · 0 tokens