Lean Beam logo

Lean Beam

Organization
leanprover
lean-beam

Work on external Lean projects through the installed `lean-beam` wrapper, using speculative checks and zero-build module checkpoints instead of repeated inner-loop builds.

Overview

Publisherleanprover
Repositorylean-beam
Skill namelean-beam
Stars
48
Forks
6
Bundled files
9
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 9 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by leanprover on GitHub. Read the source before you install it.

Installation

Install the Lean Beam AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/leanprover/lean-beam/tree/main/skills/lean-beam
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/leanprover/lean-beam.git /tmp/lean-beam
mkdir -p .claude/skills
cp -r /tmp/lean-beam/skills/lean-beam .claude/skills/lean-beam
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Lean Beam in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Lean Beam on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Lean Beam is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Lean Beam

Beam provides speculative Lean probes in the real module environment and zero-build module checkpoints. This skill is Lean-only.

Use the lean-beam wrapper, not raw JSON or raw LSP. If your client exposes the lean-beam-mcp tools (lean_run_at, lean_sync, ...), the same rules apply; MCP owns its session automatically, so do not start lean-beam serve for MCP calls.

Session

bash
# keep one foreground owner running for the project (separate terminal or background process)
lean-beam serve
# when finished: interrupt it, or
lean-beam --root ROOT stop
  • Document commands attach to a live serve owner and never start one implicitly. doctor, help, and version inspection can run without an owner.
  • In a read-only or sandboxed tree, set BEAM_SESSION_ROOT to a writable directory.
  • After editing a lakefile, manifest, Lean options, plugins, or other Lake configuration, run lean-beam --root ROOT stop and start a new serve; refresh does not restart the server.
  • If startup, toolchain selection, or session state looks wrong, run lean-beam doctor before guessing. See setup and recovery.

The Edit Loop

Beam reads only the on-disk file and never edits .lean sources; you edit files with your own tools.

  1. Edit and save the file.
  2. lean-beam update Foo.lean and take result.version from its JSON.
  3. Probe with that version (run-at, goals, hover, ...).
  4. lean-beam sync Foo.lean when you need diagnostics and readiness (result.readiness.save_ready; MCP: structuredContent.readiness.save_ready).
  5. Optionally lean-beam save MyPkg/Sub/Module.lean to checkpoint a synced workspace module.
bash
version="$(lean-beam update Foo.lean | python3 -c 'import json,sys; print(json.load(sys.stdin)["result"]["version"])')"
lean-beam goals before Foo.lean "$version" 10 2
lean-beam run-at Foo.lean "$version" 10 2 "omega"
printf 'first | omega | simp\n' | lean-beam run-at Foo.lean "$version" 10 2 --stdin
lean-beam sync Foo.lean            # errors stream on stderr; add +all-diagnostics for warnings
lean-beam save MyPkg/Sub/Module.lean
  • Every version-bound command needs the version from the latest update or sync. On contentModified with error.data.reason = "documentVersionMismatch", retry with error.data.accepted_version or run update again; never guess a version.

  • Cancellation is soft: interrupting the client does not prove backend work has stopped. Active preparation may finish before cleanup; cancellation does not undo committed effects. Do not remove temporary files solely because the client exited.

  • Use refresh for fresh diagnostics after an upstream dependency changed; it reads before reopening.

  • save checkpoints only that module. It does not validate importers, and it records the Lean server's environment, which can differ from batch elaboration. Modules with batch-only moreLeanArgs fail with saveUnsupportedSetup; move shared -D settings to leanOptions, or stop Beam, then lake build, when the arguments are intentionally batch-only.

  • If close-save fails with error.data.reason = "savedDocumentChanged", error.data.saved is an already committed checkpoint of the earlier version; run update or sync and save again if needed.

  • close-save reserves the accepted document. On contentModified with reason documentClosing, coordinate with its caller before issuing a new command; do not run an update/sync retry loop. During claimed canonical publication, same-workspace changes wait for settlement.

  • documentAdmissionExpired means closure or backend replacement invalidated this request. After coordination, issue a new request and reacquire handles if the backend was replaced.

  • Other postcommit failures also retain error.data.saved, with prior data under error.data.original_data. An uncertain close does not assert closed = false; cancellation does not undo a committed checkpoint.

Choosing A Command

NeedCommand
Proof state at a tacticgoals before FILE VERSION LINE CHAR (or goals after)
Try Lean text without editingrun-at FILE VERSION LINE CHAR TEXT (or --stdin, --text-file)
Profiling--profile on run-at/run-with probes (including handle variants; see details)
Continue from an exact speculative staterun-at-handle, then run-with / run-with-linear, release
Type and docs at a positionhover, signature-help
Navigation and symbolsdefinition, references, document-symbols FILE VERSION, workspace-symbols QUERY
Sorries, holes, errors, open goals, code actionstodo FILE VERSION [SL SC EL EC]
Fresh diagnostics after a real editsync (or refresh)
Checkpoint one synced modulesave, close-save
Daemon or tracked-file troubleopen-files, doctor, stats
Shell search loops over handleslean-beam-search
Bug report cardfeedback-report (see feedback)

Handles are pre-stable: use them only when exact continuation matters. They are invalidated by edits to the same document, close, worker restart, or daemon restart.

Code actions need a range: Lean runs them on the one command at the range end, so query a point (todo FILE VERSION L C L C --kind code_action). An empty result is not a file-wide verdict.

run-at Rules

run-at means "try this Lean text here", not "edit the file here".

  • Positions are LSP coordinates: line and character are zero-based, characters count UTF-16 code units, and on an empty line only character 0 is valid.
  • To replace a tactic, probe at its first character after indentation (its before-state).
  • Each probe is isolated and starts from the version it names, so independent probes can run in parallel. This isolates elaboration state, not external effects: Lean code may perform IO.
  • Command positions accept one command; for several, use handles or edit the file and sync.
  • Pass the exact text Lean should parse, including indentation and newlines; prefer --stdin for multiline text. Beam does not re-indent.
  • At a tactic position, the text may be a tactic sequence: start each tactic at the same column, or separate them with ;. Do not start it with by; the probe already runs inside the proof.
  • At an unfilled sorry, _, or ?x term, run-at starts from its goal; text is still tactics. At a todo item's run_at_position, it starts from the item's proof_state; without one, edit.
  • run-at returns no file diagnostics; use sync after a real edit for those.
  • Tactic probes reject new local let rec definitions, even valid ones. Save the enclosing declaration and sync instead, or probe one complete declaration at a command position.

Prefer small probes at the real source position. Scratch files reload imports and lose context; use them only for context-free syntax checks.

Output Contract

  • Check the exit status first. Completed broker operations print one JSON object on stdout.
  • A successful transport does not mean a successful Lean probe: inspect result.success for wrapper probes. For MCP probes, require isError to be absent or false and structuredContent.success true.
  • stderr is for humans: progress and streamed diagnostics. Never parse it. Selector, setup, or transport failures may print only to stderr.
  • sync failures carry structured error.data; save failures with document errors put the blocking verdict in error.data.sync.

When To Stop Probing

Before lake build, stop the CLI owner or drop the MCP workspace and wait for cleanup; recreate the session afterward.

  • The probe result should become real source: edit, save, update/sync.
  • Probes stop clarifying the problem: change approach rather than repeating variants.
  • save fails with saveImportsChanged: refresh, then save.
  • On syncBarrierIncomplete, follow error.data.recovery_plan in order; stop on failure. Inspect diagnostics/readiness after refresh succeeds. If blocked or save is unsupported, stop retries and inspect upstream diagnostics/configuration.
  • You edited a dependency and need trustworthy importers: save is not enough; rebuild.
  • contentModified, stale state, or rebuild trouble keeps appearing unexpectedly: inspect open-files and doctor, then stop and report it rather than working around it.

For batch evidence, prefer clean CI lake build. The local fallback requires confirmation of cleanup from the original owner or supervisor before cleaning/building; otherwise stop and coordinate. Do not repeat after every checkpoint.

Beam is a non-adversarial development tool. Checkpoint readiness can include sorry warnings; it is not proof acceptance. For independent confirmation, use the separate trust and proof confirmation workflow, including a trusted challenge and external checkers. Do not add it to every inner-loop operation.

References

Open as needed:

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Lean Beam AI skill do?

Work on external Lean projects through the installed `lean-beam` wrapper, using speculative checks and zero-build module checkpoints instead of repeated inner-loop builds.

Why use Lean Beam on TypingMind?

Because you install it once and use it with any model. Lean Beam is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Lean Beam in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/leanprover/lean-beam/tree/main/skills/lean-beam. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Lean Beam?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Lean Beam?

As many as you like. As long as a model supports skills, you can use Lean Beam with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Lean Beam AI skill free?

Yes. It is published on GitHub by leanprover under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇