proof-repair

proof-repair is an agent for Claude Code from cameronfreer/lean4-skills. It costs 35 tokens per session (1,634 once invoked), scanned A, original, MIT.

A helper that fixes errors in Lean 4 proofs by examining compiler messages and trying repairs in stages. Lean 4 is a programming language and proof checker for formal mathematics.

In plain words
What is it for?
Use it to repair a Lean file with type mismatches, unsolved goals, unknown identifiers, missing typeclass instances, or timeouts.
Why use it?
It reduces the manual work of interpreting type errors, missing names, unfinished goals, and similar proof failures. It uses the reported error and local proof context to guide changes.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the lean4 plugin — 1 skill, 12 commands, 4 agents, 3 hooks shipped together

Good fit Use it to repair a Lean file with type mismatches, unsolved goals, unknown identifiers, missing typeclass instances, or timeouts.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/cameronfreer/lean4-skills/proof-repair
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/cameronfreer/lean4-skills

Made for: Claude Code.

Or install lean4, the plugin that ships this one along with the rest of its 1 skill, 12 commands, 4 agents, 3 hooks.

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/cameronfreer/lean4-skills/proof-repair/github.svg)](https://agentmods.dev/agents/cameronfreer/lean4-skills/proof-repair)
Your own site
<a href="https://agentmods.dev/agents/cameronfreer/lean4-skills/proof-repair"><img src="https://agentmods.dev/badge/agents/cameronfreer/lean4-skills/proof-repair/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 proof-repair

Your own site · 80×15
<a href="https://agentmods.dev/agents/cameronfreer/lean4-skills/proof-repair"><img src="https://agentmods.dev/badge/agents/cameronfreer/lean4-skills/proof-repair.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,634 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.00035 $0.01634
Opus 5.5 $0.00014 $0.00654
Sonnet 5.5 $0.00007 $0.00327
Haiku 4.5 $0.00003 $0.00163

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

Security

Grade A, and why

proof-repair 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

plugins/lean4/agents/proof-repair.md · 118 lines

How it starts

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

Inputs

Consume the run-contract/v1 dispatch record (record == "dispatch"): read target, the context envelope, and parameters.error (the structured error to repair). proof-repair is patch-only — it does not edit, so it takes no owned_files custody. It receives the parent's file_baseline non-custodially (it never checks or advances it) and echoes it back unchanged in its handoff; the parent applies and advances the returned diff.

parameters.error shape:

{
  "errorType": "type_mismatch|unsolved_goals|unknown_ident|synth_instance|timeout",
  "message": "...",
  "file": "Foo.lean",
  "line": 42,
  "goal": "⊢ Continuous f",
  "localContext": ["h1 : Measurable f"]
}

Actions

  1. Classify error — lean_goal(file, line) + lean_diagnostic_messages(file) first, then match errorType

    MCP canary: If lean_goal and lean_diagnostic_messages are both unavailable (tool-not-found, missing from context, or otherwise inaccessible), return no diff and let the caller escalate (same mechanism as the header-fence constraint).

    No-MCP hygiene (if canary fails): MCP tools are tool calls, not shell commands — never invoke them via Bash. Do not probe MCP availability via Bash (which, env, ls) — the canary is authoritative. Stop retrying MCP for this run. Use Read/Grep to inspect files (never write scripts or temp files just to view source). Start from pre-collected context in the parent prompt.

  2. Apply error-specific strategy (see table below)

  3. Search if needed (LSP-first; fall back to scripts only when LSP is unavailable, rate-limited, or inconclusive after bounded attempts):

    • lean_leanfinder("query") or lean_local_search("keyword") first
    • Script fallback: lean4-skills-search-mathlib only after LSP exhausted
  4. Generate minimal diff (1-5 lines)

  5. Return the diff in a run-contract/v1 handoff — the unified diff in artifacts (kind: unified-diff), no prose in the diff content (see Output)

Read the full file on GitHub · 118 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 Changed 5a725ebb1ee4
  2. 2mo ago Changed f561ce362ed7
  3. 3mo ago First seen · 118 lines · 35 tokens per session scan A 0b719b86da75

Subscribe to this mod's changes

proof-repair is an agent published in the GitHub repository cameronfreer/lean4-skills (509 stars, last pushed 23d ago), licensed MIT. It adds 35 tokens to every session and 1,634 once invoked, about $0.0001 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-30.

Related

proof-repair compared with agents from other repositories

proof-repair next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
proof-repaircameronfreer/lean4-skillsAgent50923d agoMITA35Claude Code
editorpedrohcgs/claude-code-my-workflowAgent1.7k23d agoMITA64Claude Code
research-scoutequinor/neqsimAgent177todayApache-2.0A61Claude Code
Geoprocessing SpecialistSHAdd0WTAka/Zen-Ai-PentestAgent53527d agoMITA45Claude Code, OpenCode
mathodology-problem-analystsweetcornna/mathodologyAgent3528d agoMITA20Claude Code
astronomical-instrumentation-scientistK-Dense-AI/scientific-agentsAgent2671mo agoMITA78Claude Code
bnlearn-researchererdogant/bnlearnAgent6498d agononeA47Claude Code