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.
npx agentmods add commands/cameronfreer/lean4-skills/golfgit clone --depth 1 https://github.com/cameronfreer/lean4-skillsWrote 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/commands/cameronfreer/lean4-skills/golf)<a href="https://agentmods.dev/commands/cameronfreer/lean4-skills/golf"><img src="https://agentmods.dev/badge/commands/cameronfreer/lean4-skills/golf.svg" alt="Measured on agentmods" 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 | $0.00017 | $0.02592 |
| Opus 5 | $0.00009 | $0.01296 |
| Sonnet 5 | $0.00003 | $0.00518 |
| Haiku 4.5 | $0.00002 | $0.00259 |
Grade A, and why
golf 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 today.
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.
Copies of this mod
1 near-identical copy found in the catalogue:
- golf — 94% identical, 24 lines differ
How it starts
The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Lean4 Golf
Improve Lean proofs that already compile. Score candidates by: correctness → directness → clarity/inference burden → performance/determinism → length. Length is still a core goal, but a tiebreaker among acceptable proofs.
Prerequisite: Code must compile. Verify code compiles first (lean_diagnostic_messages(file) or lake env lean <path/to/File.lean> from project root; lake build for project-wide).
Usage
/lean4:golf # Golf entire project
/lean4:golf File.lean # Golf specific file
/lean4:golf File.lean:42 # Golf proof at specific line
/lean4:golf --dry-run # Show opportunities without applying
/lean4:golf --search=full # Include lemma replacement pass
/lean4:golf --max-delegates=3 # Override default 2 concurrent subagents
Inputs
| Arg | Required | Description |
|---|---|---|
| target | No | File or file:line to golf |
| --dry-run | No | Preview only, no changes |
| --search | No | off, quick (default), or full — LSP lemma replacement pass |
| --max-delegates | No | 2 — max concurrent golfer subagents (preflight must pass first) |
Actions
- Verify Build - Ensure code compiles before optimizing
- Find Patterns - Detect golfable patterns (in policy order: directness → structural → conditional):
For direct-proof discovery whenlean4-skills-find-golfable [file] --filter-false-positives--searchis enabled or syntactic pass stalls:lean4-skills-find-exact-candidates [file] - Exact-Collapse Pass (bounded) — For apply/exact chain anchors from
lean4-skills-find-golfable:- Mechanical (≤30 anchors/file): Construct collapsed
exactfrom tactic structure →lean_multi_attempt+lean_diagnostic_messagesbaseline check (no new diagnostics, no sorry increase). Accept if the replacement is more direct or clearer. Reject if it introduces heavier automation (simpa, rwa, broad simp) to replace an explicit proof, if term length exceeds ~80 chars, if dot-chain depth > 2, or if it removes meaningful intermediate names. A 1-line saving that raises inference burden is not a win. - Exploratory (when
--search≠off; consumes--searchbudget): On remaining single-goal anchors, build candidateexactterms from chain lemmas + local hypotheses + dot-notation rewrites →lean_multi_attempt+ diagnostics check. Probe caps are phase-local:quick≤5 probes/file;full≤15 probes/file; ≤2 probes/anchor. Time budget is shared with lemma replacement (step 4):quick30s total,full60s total across both phases. - Skip:
calc,cases/induction, multi-goal branches, blocks >7 lines, semicolon-heavy (>3), blocks withhave/refine.constructorchains are handled by the existing instant-win rule, not this pass.
- Mechanical (≤30 anchors/file): Construct collapsed
- Lemma Replacement (if
--search=quickorfull):- Run LSP searches per candidate; test with
lean_multi_attempt quick: 1 search, ≤2 candidates;full: 2 searches, ≤3 candidates; ≤3 search calls; uses remaining shared time budget- Accept the best passing replacement by the scoring order below
- Hand off to axiom-eliminator if replacement needs statement changes or multi-file refactor
- Run LSP searches per candidate; test with
- Verify Safety - Check usage before inlining:
lean4-skills-analyze-let-usage [file] --line [line] - Apply - Make changes with
lean_diagnostic_messagesafter each;lake buildfor final verification - Report - Show savings and saturation status
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.
- today Changed · -1 lines 2f617471743a
- 5d ago First seen · 168 lines · 17 tokens per session scan A 44b854a0d2a5
golf is a command published in the GitHub repository cameronfreer/lean4-skills (428 stars, last pushed today), licensed MIT. It adds 17 tokens to every session and 2,592 once invoked, about $0.0001 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.
Other commands, from other repositories
master_analysis
Run comprehensive 5-phase analysis across labs, genetics, and protocols.
replication-package
Scaffold or audit a social-science replication package at a target directory, and audit the manuscript and its archived research objects against FAIR principles.
diff
Quantitative volume comparison between a CadQuery model and a reference STEP file.
arg-diagram
ARG academic-paper diagram mode — standalone structural & conceptual diagram generation.
simulation-calibrator
Test and refine simulation accuracy with validation loops, bias detection, and continuous improvement frameworks.
graphite-morphology-classify
Classify graphite in a cast-iron micrograph per ASTM A247 / ISO 945-1, quantify nodularity, and read the matrix — the single most diagnostic observation in a cast-iron case.