lean4-proof-golfer

lean4-proof-golfer is an agent for Claude Code from frenzymath/Archon. It costs 47 tokens per session (1,939 once invoked), scanned A, original, Apache-2.0.

A Lean 4 proof-improvement agent for shortening and clarifying proofs that already compile. Lean 4 is a programming language and proof checker for formal mathematics.

In plain words
What is it for?
It helps inline safe local definitions, collapse chains of exact proof steps, and find shorter equivalent proofs.
Why use it?
It reduces repetitive proof code while checking that the result keeps the same meaning and still builds.

Agent for Claude Code

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

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

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.

agentmods
npx agentmods add agents/frenzymath/archon/lean4-proof-golfer
Clone the repo
git clone --depth 1 https://github.com/frenzymath/Archon

Made for: Claude Code.

Or install lean4, the plugin that ships this one along with the rest of its 1 skill, 11 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 lean4-proof-golfer

README.md
[![agentmods](https://agentmods.dev/badge/agents/frenzymath/archon/lean4-proof-golfer.svg)](https://agentmods.dev/agents/frenzymath/archon/lean4-proof-golfer)
Your own site
<a href="https://agentmods.dev/agents/frenzymath/archon/lean4-proof-golfer"><img src="https://agentmods.dev/badge/agents/frenzymath/archon/lean4-proof-golfer.svg" alt="Measured on agentmods" height="20"></a>
Per session 47 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,939 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00047 $0.01939
Opus 5 $0.00023 $0.00970
Sonnet 5 $0.00009 $0.00388
Haiku 4.5 $0.00005 $0.00194

Measured 6d ago against content hash 8786cbc4f468, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

lean4-proof-golfer 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 6d 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.

src/archon/.archon-src/skills/lean4/agents/lean4-proof-golfer.md · 152 lines

How it starts

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

Inputs

  • File path to optimize
  • Passing build required (will verify before starting)
  • Search mode: off, quick (default), or full

Actions

  1. Find patterns (in policy order: directness → structural → conditional) with false-positive filtering:

    ${LEAN4_PYTHON_BIN:-python3} "$LEAN4_SCRIPTS/find_golfable.py" FILE.lean --filter-false-positives
    

    For direct-proof discovery when search_mode ≠ off or syntactic pass stalls:

    ${LEAN4_PYTHON_BIN:-python3} "$LEAN4_SCRIPTS/find_exact_candidates.py" FILE.lean
    
  2. Verify safety before inlining any binding:

    ${LEAN4_PYTHON_BIN:-python3} "$LEAN4_SCRIPTS/analyze_let_usage.py" FILE.lean --line LINE
    
    • 1-2 uses: Safe to inline
    • 3-4 uses: Check carefully (40% worth optimizing)
    • 5+ uses: NEVER inline
  3. Exact-collapse pass (for apply-exact-chain anchors from step 1):

    • Mechanical (≤30 anchors/file): construct collapsed exactlean_multi_attempt + lean_diagnostic_messages baseline check; accept by scoring order (per golf.md: directness → inference burden → perf → length)
    • Exploratory (when search_mode ≠ off; shared budget): candidate exact from chain lemmas + local hyps + dot-notation rewrites → lean_multi_attempt; ≤2 probes/anchor, quick ≤5/file 30s, full ≤15/file 60s. Skip: calc, multi-goal, blocks >7 lines, semicolon-heavy, have/refine
  4. Lemma replacement search (if search_mode ≠ off):

    • lean_local_search first, then lean_leanfinder or lean_loogle
    • quick: 1 search, ≤2 candidates; full: 2 searches, ≤3 candidates
    • Test with lean_multi_attempt; accept the best passing replacement by scoring order (per golf.md: directness → inference burden → perf → length)
    • Budget: ≤3 search calls, max 3 candidates; uses remaining shared time budget (quick 30s, full 60s total across steps 3–4)
    • If replacement needs statement changes or multi-file refactor → stop, hand off to axiom-eliminator

Read the full file on GitHub · 152 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. 6d ago First seen · 152 lines · 47 tokens per session scan A 8786cbc4f468

Subscribe to this mod's changes

lean4-proof-golfer is an agent published in the GitHub repository frenzymath/Archon (214 stars, last pushed 19d ago), licensed Apache-2.0. It adds 47 tokens to every session and 1,939 once invoked, about $0.0002 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-30.

Related

Other agents, from other repositories

Geoprocessing Specialist

ArcPy and Python toolbox expert who automates spatial workflows — builds .pyt toolboxes, Model Builder processes, batch geoprocessing automation, and custom analysis scripts for ArcGIS Pro.

SHAdd0WTAka/Zen-Ai-Pentest · 45 tokens

ras-commander-api-expert

Expert in ras-commander API, dataframe structures, and integration patterns. Spawns explore subagents to search the large/sprawling library codebase. Knows RasPrj dataframe columns (plandf, geomdf, flowdf, etc.) and return formats from all functions. Use when integrating with ras-commander, understanding API patterns…

gpt-cmdr/ras-commander · 122 tokens

coder

Specialized sub-agent for the AI co-mathematician system. Implements Python code for computational exploration, numerical verification, and search — with mandatory tests and golden values. Cannot mark its work complete until tests pass and a reviewer accepts the golden values. Use when the project-coordinator…

morankor/theorist-toolbox · 78 tokens

proof-decomposer-prompt

You are a specialized agent for decomposing long Lean 4 proofs to mathlib quality standards.

CBirkbeck/mathlib-quality · 0 tokens

iris-hep-coder

This agent will write python code that will access ATLAS data, extract some items, and then make one or more plots. If the user's prompt doesn't fit that request, please complain. Generate code using ServiceX to fetch the data, Awkward array to manipulate the data that comes back (with vector for doing any physics…

iris-hep/marketplace · 0 tokens

SciTeXTranslatorAgent

Knows SciTeX usage with proper formats. Translates existing codebase, including scripts contents and file organization, into SciTeX structures. Not applicable to src or tests but to ./scripts and ./examples. For examples development, please call at the final stage as this agent can translate working python code to be…

scitex-ai/claude-code-telegrammer · 84 tokens