lean-interact: Skill for Claude Code

.claude/skills/formalize-from-magma/SKILL.md

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

A workflow that turns Magma code into a formal theorem in Lean, a system for writing and checking mathematical proofs. It first runs the Magma program, then identifies and proves the mathematical claim behind it.

In plain words
What is it for?
Use it to examine Magma routines, formalize computations or discovered patterns, and produce a general Lean theorem.
Why use it?
Program output is evidence of a pattern, not automatically a proof; running the code helps avoid formalizing an incorrect interpretation.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

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 →

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-from-magma/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-from-magma

README.md
[![agentmods](https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize-from-magma/github.svg)](https://agentmods.dev/skills/nasqret/lean-interact/formalize-from-magma)
Your own site
<a href="https://agentmods.dev/skills/nasqret/lean-interact/formalize-from-magma"><img src="https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize-from-magma/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-from-magma

Your own site · 80×15
<a href="https://agentmods.dev/skills/nasqret/lean-interact/formalize-from-magma"><img src="https://agentmods.dev/badge/skills/nasqret/lean-interact/formalize-from-magma.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 109 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,656 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.00109 $0.01656
Opus 5 $0.00055 $0.00828
Sonnet 5 $0.00022 $0.00331
Haiku 4.5 $0.00011 $0.00166

Measured 9d ago against content hash 982acf8dafab, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

formalize-from-magma 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 9d 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-from-magma/SKILL.md · 135 lines

How it starts

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

formalize-from-magma

The second input path of this project. formalize takes a sentence of ordinary mathematics; this skill takes Magma code and turns it into the same thing.

Magma code is not a theorem. It is an algorithm plus evidence. The work is to recover the mathematical claim the code embodies, decide which part of it is actually provable, and only then formalize. Skipping to Lean without running the code is the characteristic mistake: you end up formalizing what you assumed the code did.

Repository root: /path/to/lean-interact. Magma runs remotely — there is no local binary. See magma/README.md.


Step 1 - RUN IT, before reading it closely

tools/magma_run.sh path/to/file.m          # a file
echo 'print 2^10 mod 11; quit;' | tools/magma_run.sh -

Read the actual output. Magma's semantics differ from the mental model you bring from Lean or Python in ways that change the claim:

Magma Trap
n mod m for negative n, Magma returns a value in [0, m) — like Int.emod, unlike truncation
Modexp(a, e, m) handles negative a and huge e; do not "simplify" it to a^e mod m in your head
Gcd(0, 0) 0; edge cases at zero are where computational claims quietly fail
[a..b] empty when a > b, so a sweep can silently check nothing
EulerPhi(1) 1, and 1 mod 1 = 0 — degenerate moduli are the usual source of a false pattern

If the code defines functions but runs nothing, add a driver that exercises them and run that. Never formalize from unexecuted code.

Step 2 - EXTRACT THE CLAIM

Ask what the code asserts, and classify it. The classification decides everything downstream:

  1. A closed computation. Modexp(2, 560, 561) eq 1. Formalizes to a concrete Lean statement provable by decide or norm_num. Cheap, honest, and worth keeping when it is a witness or a counterexample.
  2. A universally quantified claim, verified on a range. A forall{...} over [1..1000] returning true. The Magma output is evidence, not proof. The Lean statement must quantify over all n, and the proof must be a real argument.
  3. A pattern with a hidden hypothesis. The sweep skipped cases (if n mod p ne 0), or the range excluded them ([1..N] hides the negative and zero cases). That skipped condition is the hypothesis of the theorem. This is the most valuable thing this skill finds — see the worked example below.
  4. An algorithm. A routine computing something. Formalizing an algorithm means stating its specification; that is a much larger job. Say so, and offer the specification as the claim instead of the implementation.

Read the full file on GitHub · 135 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. 9d ago First seen · 135 lines · 109 tokens per session scan A 982acf8dafab

Subscribe to this mod's changes

formalize-from-magma is a skill published in the GitHub repository nasqret/lean-interact (10 stars, last pushed 1mo ago), licensed MIT. It adds 109 tokens to every session and 1,656 once invoked, about $0.0005 per session on Opus 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

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-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

lean4-proof

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

EtaYang10th/spark-skills · 0 tokens

formal-logic

Use this Skill for formal logic and automated reasoning: Z3 SMT solver for propositional/first-order logic, modal logic S5, SAT problem encoding, and Lean4 proof verification.

xjtulyc/awesome-rosetta-skills · 41 tokens

instrument-data-to-allotrope

Convert laboratory instrument output files (PDF, CSV, Excel, TXT) to Allotrope Simple Model (ASM) JSON format or flattened 2D CSV. Use this skill when scientists need to standardize instrument data for LIMS systems, data lakes, or downstream analysis. Supports auto-detection of instrument types. Outputs include full…

anthropics/knowledge-work-plugins · 123 tokens