agentleFS
VeryMathVeryMath/AI4Math-Lean-Agents/skills/lean-setup/SKILL.md

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

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    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.

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
  1. Very specific:

    Use this setup-only entrypoint when the user only wants a Lean 4 environment, elan/lake readiness, or a reusable mathlib workspace.

    line 8
  2. Very specific:

    If elan, lean, or lake is missing, explain the required Lean installation step first.

    line 16
  3. Distinctive:

    Prefer an existing Lake project when the user points to one.

    line 17
  4. Distinctive:

    When creating an isolated test directory or workspace, suggest a safe default name and let the user confirm or rename it.

    line 18
  5. Distinctive:

    Create the workspace only after explaining that Lean/mathlib artifacts may be downloaded or built.

    line 20
  6. Distinctive:

    Run the bundled smoke test after setup.

    line 21
  7. Very specific:

    If Lean toolchain and pure Lean smoke tests pass but lake update, lake exe cache get, lake build, or import Mathlib is blocked by …

    line 23
  8. Distinctive:

    After successful setup or smoke-test validation, do not end passively.

    line 24
  9. Very specific:

    If the user next wants formalization, proof repair, theorem transcription, sorry completion, patch review, or Numina proof search, hand off …

    line 26
  10. Very specific:

    If git ls-remote fails, diagnose Git proxy/network inheritance before rerunning Lake.

    line 47
  11. Distinctive:

    run or explain the built-in smoke theorem result.

    line 54
  12. Distinctive:

    If only partial readiness is available, limit the default menu to Git/mathlib recovery, pure Lean smoke validation, or IDE frontend …

    line 60
  13. Very specific:

    Use --dry-run before setup when the user wants to review commands.

    line 75
  14. Distinctive:

    Do not create a second setup implementation.

    line 79
  15. Very specific:

    Do not change a user project's lean-toolchain or mathlib revision without approval.

    line 80
  16. Very specific:

    Do not overwrite the canonical managed workspace for a different Lean/mathlib revision.

    line 81
  17. Distinctive:

    Do not require API keys for Lean/mathlib workspace setup.

    line 82
  18. Distinctive:

    Do not require VS Code, Lean InfoView, or any IDE frontend for headless setup validation.

    line 83
  19. Distinctive:

    Do not configure or call official Numina unless the user explicitly asks for that optional backend.

    line 84
  20. Distinctive:

    Do not commit machine-specific paths, downloaded runtime state, or secrets.

    line 85
  21. Very specific:

    Read ../lean-runtime/references/lean_runtime_configuration.md for shared workspace layout, local configuration, and version policy.

    line 89
  22. Very specific:

    Read ../lean-runtime/references/numina_runtime.md only when the user asks for optional official Numina setup.

    line 90
  23. Very specific:

    Use ../lean-runtime/scripts/ai4m_lean.py verify-delivery --cwd .

    line 91

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Match the user's language by default; if ambiguous, default to Chinese.
  2. Inspect tool and workspace readiness with doctor or env.
  3. If elan, lean, or lake is missing, explain the required Lean installation step first. Install Lean through the official elan channel appropriate for the user's OS after approval; lean and lake should come from the elan toolchain rather than a repository-local copy.
  4. Prefer an existing Lake project when the user points to one.
  5. 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.
  6. For standalone future Lean work, create or reuse the canonical managed workspace ${AI4MATH_HOME:-~/.ai4math}/lean-workspace with the AI4Math managed baseline toolchain leanprover/lean4:v4.28.0.
  7. 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.
  8. Run the bundled smoke test after setup.
  9. 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.
  10. If Lean toolchain and pure Lean smoke tests pass but lake update, lake exe cache get, lake build, or import Mathlib is blocked by GitHub/network/cache failure, report partial readiness instead of total failure or full success.
  11. After successful setup or smoke-test validation, do not end passively. Offer a short next-step menu and recommend one default next action.
  12. 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 .lean file, and confirm Lean InfoView is connected to the same toolchain that passed local validation.
  13. If the user next wants formalization, proof repair, theorem transcription, sorry completion, patch review, or Numina proof search, hand off to lean-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 with import 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 build

If 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-toolchain or 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.md for shared workspace layout, local configuration, and version policy.
  • Read ../lean-runtime/references/numina_runtime.md only when the user asks for optional official Numina setup.
  • Use ../lean-runtime/scripts/ai4m_lean.py verify-delivery --cwd . --run-tests for package validation.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.