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.
curl -O https://raw.githubusercontent.com/nasqret/lean-interact/main/.claude/skills/formalize-from-magma/SKILL.mdgit clone --depth 1 https://github.com/nasqret/lean-interactWrote 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.
[](https://agentmods.dev/skills/nasqret/lean-interact/formalize-from-magma)<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.
<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>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.
| Model | Per session | Once 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 |
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.
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:
- A closed computation.
Modexp(2, 560, 561) eq 1. Formalizes to a concrete Lean statement provable bydecideornorm_num. Cheap, honest, and worth keeping when it is a witness or a counterexample. - A universally quantified claim, verified on a range. A
forall{...}over[1..1000]returningtrue. The Magma output is evidence, not proof. The Lean statement must quantify over alln, and the proof must be a real argument. - 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. - 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.
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.
- 9d ago First seen · 135 lines · 109 tokens per session scan A 982acf8dafab
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.
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…
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…
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…
lean4-proof
This skill covers proving bounds on recursively-defined sequences in Lean 4, using the pattern of.
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.
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…