lean-setup
Skill9 starsChanged 4 months agoMITView on GitHub
Use when a coding agent needs to install or verify Lean 4, elan, lake, create or reuse a mathlib workspace, configure a shared Lean environment, or run Lean readiness checks before formalization.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- r-irbe/proof-skillstheir own version, first seen Oct 20, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- r-irbe/proof-skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/lean-formalization.mdcCursor rule
- lean-formalizationSkill
- lean-formalizationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 12 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this setup-only entrypoint when the user only wants a Lean 4 environment, elan/lake readiness, or a reusable mathlib workspace.
- Very specific: line 16
If elan, lean, or lake is missing, explain the required Lean installation step first.
- Distinctive: line 17
Prefer an existing Lake project when the user points to one.
- Distinctive: line 18
When creating an isolated test directory or workspace, suggest a safe default name and let the user confirm or rename it.
- Distinctive: line 20
Create the workspace only after explaining that Lean/mathlib artifacts may be downloaded or built.
- Distinctive: line 21
Run the bundled smoke test after setup.
- Very specific: line 23
If Lean toolchain and pure Lean smoke tests pass but lake update, lake exe cache get, lake build, or import Mathlib is blocked by …
- Distinctive: line 24
After successful setup or smoke-test validation, do not end passively.
- Very specific: line 26
If the user next wants formalization, proof repair, theorem transcription, sorry completion, patch review, or Numina proof search, hand off …
- Very specific: line 47
If git ls-remote fails, diagnose Git proxy/network inheritance before rerunning Lake.
- Distinctive: line 54
run or explain the built-in smoke theorem result.
- Distinctive: line 60
If only partial readiness is available, limit the default menu to Git/mathlib recovery, pure Lean smoke validation, or IDE frontend …
- Very specific: line 75
Use --dry-run before setup when the user wants to review commands.
- Distinctive: line 79
Do not create a second setup implementation.
- Very specific: line 80
Do not change a user project's lean-toolchain or mathlib revision without approval.
- Very specific: line 81
Do not overwrite the canonical managed workspace for a different Lean/mathlib revision.
- Distinctive: line 82
Do not require API keys for Lean/mathlib workspace setup.
- Distinctive: line 83
Do not require VS Code, Lean InfoView, or any IDE frontend for headless setup validation.
- Distinctive: line 84
Do not configure or call official Numina unless the user explicitly asks for that optional backend.
- Distinctive: line 85
Do not commit machine-specific paths, downloaded runtime state, or secrets.
- Very specific: line 89
Read ../lean-runtime/references/lean_runtime_configuration.md for shared workspace layout, local configuration, and version policy.
- Very specific: line 90
Read ../lean-runtime/references/numina_runtime.md only when the user asks for optional official Numina setup.
- Very specific: line 91
Use ../lean-runtime/scripts/ai4m_lean.py verify-delivery --cwd .
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Lean Setup
Use this setup-only entrypoint when the user only wants a Lean 4 environment, elan/lake readiness, or a reusable mathlib workspace. Do not ask for a theorem target in setup-only mode.
The shared implementation lives in ../lean-runtime/. This skill must reuse the same helper CLI, configuration rules, and runtime references rather than duplicating setup logic or depending on the formalization entrypoint.
Setup-Only Flow
- Match the user's language by default; if ambiguous, default to Chinese.
- Inspect tool and workspace readiness with
doctororenv. - If
elan,lean, orlakeis missing, explain the required Lean installation step first. Install Lean through the officialelanchannel appropriate for the user's OS after approval;leanandlakeshould come from theelantoolchain rather than a repository-local copy. - Prefer an existing Lake project when the user points to one.
- When creating an isolated test directory or workspace, suggest a safe default name and let the user confirm or rename it; use the default if the user has no naming preference.
- For standalone future Lean work, create or reuse the canonical managed workspace
${AI4MATH_HOME:-~/.ai4math}/lean-workspacewith the AI4Math managed baseline toolchainleanprover/lean4:v4.28.0. - Create the workspace only after explaining that Lean/mathlib artifacts may be downloaded or built. If the canonical workspace already exists and is complete, reuse it instead of rebuilding or downloading again.
- Run the bundled smoke test after setup.
- Report the installed tools, workspace path, Lean toolchain, mathlib revision when available, smoke-test result, and any remaining action. Distinguish Lean core ready from mathlib ready.
- If Lean toolchain and pure Lean smoke tests pass but
lake update,lake exe cache get,lake build, orimport Mathlibis blocked by GitHub/network/cache failure, report partial readiness instead of total failure or full success. - After successful setup or smoke-test validation, do not end passively. Offer a short next-step menu and recommend one default next action.
- Include an optional cross-platform IDE frontend path in that menu: identify the user's OS when needed, then guide them to install or verify VS Code with the Lean 4 extension on macOS, Windows, or Linux, open the verified Lake project or shared workspace, open a known passing
.leanfile, and confirm Lean InfoView is connected to the same toolchain that passed local validation. - If the user next wants formalization, proof repair, theorem transcription,
sorrycompletion, patch review, or Numina proof search, hand off tolean-formalization.
Readiness Levels
Report setup status in two layers:
- Lean core ready:
lean --version,lake --version, and a pure Lean smoke theorem pass. - mathlib ready: the workspace can run
lake update,lake exe cache get,lake build, and a file withimport Mathlib.
If Lean core ready passes but mathlib ready fails because GitHub, proxy, or cache download is unavailable, call it partial readiness. import Mathlib tasks are blocked, but pure .lean files and basic Lean compilation can still be verified. Do not present this as full mathlib workspace readiness. Do not recommend formalization, sorry completion, or Numina as the default next step while mathlib is missing. The default next step should be to diagnose Git/mathlib access or continue only with pure Lean smoke validation.
For Windows mathlib clone/cache failures, use copyable recovery commands such as:
git ls-remote https://github.com/leanprover-community/mathlib4.git HEAD
Remove-Item -Recurse -Force .lake\packages\mathlib
lake update
lake exe cache get
lake buildIf git ls-remote fails, diagnose Git proxy/network inheritance before rerunning Lake. If it succeeds but Lake reports that .lake\packages\mathlib cannot resolve HEAD, remove that corrupted package directory and rerun lake update.
Post-Setup Guidance
Offer a short next-step menu after setup succeeds:
- inspect an existing Lean/Lake project;
- run or explain the built-in smoke theorem result;
- configure the VS Code / Lean 4 extension frontend for the verified project on macOS, Windows, or Linux, and confirm Lean InfoView works;
- repair a Lean file or complete
sorry; - formalize a natural-language or LaTeX theorem;
- continue setup-only validation if the user only wants environment readiness.
If only partial readiness is available, limit the default menu to Git/mathlib recovery, pure Lean smoke validation, or IDE frontend verification for the same pure Lean file. Do not offer Mathlib-dependent proof work as ready.
As a rule, mention optional Numina only when the user explicitly asks for the official Lean Agent, batch proof search, or an external backend adapter; do not make Numina or API keys part of the default next step.
Commands
Resolve the helper from the shared runtime path ../lean-runtime/scripts/ai4m_lean.py, then run it with --cwd <target-project-or-workspace>. In a source checkout this is the same helper under skills/lean-runtime/scripts/ai4m_lean.py.
python ../lean-runtime/scripts/ai4m_lean.py doctor --cwd <target-project-or-workspace>
python ../lean-runtime/scripts/ai4m_lean.py env --cwd <target-project-or-workspace>
python ../lean-runtime/scripts/ai4m_lean.py configure --cwd <target-project-or-workspace> --create-workspace
python ../lean-runtime/scripts/ai4m_lean.py smoke-test --cwd <target-project-or-workspace>Use --dry-run before setup when the user wants to review commands.
Boundaries
- Do not create a second setup implementation.
- Do not change a user project's
lean-toolchainor mathlib revision without approval. - Do not overwrite the canonical managed workspace for a different Lean/mathlib revision. Use
${AI4MATH_HOME:-~/.ai4math}/lean-workspaces/<version-key>/only when the user explicitly needs a different standalone version. - Do not require API keys for Lean/mathlib workspace setup.
- Do not require VS Code, Lean InfoView, or any IDE frontend for headless setup validation; offer it as a recommended human-facing follow-up after Lean/Lake readiness is confirmed.
- Do not configure or call official Numina unless the user explicitly asks for that optional backend.
- Do not commit machine-specific paths, downloaded runtime state, or secrets.
References
- Read
../lean-runtime/references/lean_runtime_configuration.mdfor shared workspace layout, local configuration, and version policy. - Read
../lean-runtime/references/numina_runtime.mdonly when the user asks for optional official Numina setup. - Use
../lean-runtime/scripts/ai4m_lean.py verify-delivery --cwd . --run-testsfor package validation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

