Token导航 LogoToken导航

Agent Skill · 研究检索

lean4(lean4 搜索)

lean4 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

lean4 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 35,589。

总安装 2,060周安装 85GitHub Stars 236下载 673核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:lean4(lean4 搜索)
来源仓库:https://github.com/cameronfreer/lean4-skills
仓库路径:skills/lean4
安装命令:
npx skills add https://github.com/cameronfreer/lean4-skills --skill lean4
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cameronfreer/lean4-skills --skill lean4

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息,支持基于关键词或任务场景定位结果。适用于快速获取候选信息,提升 Agent 在复杂查询中的效率。可通过来源仓库和 README 进一步核验具体用法和功能边界。安装前建议确认权限范围及是否触发联网或文件读写操作。lean4 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/lean4

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cameronfreer/lean4-skills --skill lean4;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

lean4 怎么安装?

在终端执行 npx skills add https://github.com/cameronfreer/lean4-skills --skill lean4。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

lean4 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

lean4 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

lean4 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

lean4 用的人多吗?

公开数据是累计安装 2,060 次,近一周安装 85 次,下载 673 次,GitHub 236 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

lean4 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
lean4

lean4 搜索 · 本页

2,060236调用外部服务未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Lean 4 Theorem Proving

Use this skill whenever you're editing Lean 4 proofs, debugging Lean builds, formalizing mathematics in Lean, or learning Lean 4 concepts. It prioritizes LSP-based inspection and mathlib search, with scripted primitives for sorry analysis, axiom checking, and error parsing.

Core Principles

Search before prove. Many mathematical facts already exist in mathlib. Search exhaustively before writing tactics.

Build incrementally. Lean's type checker is your test suite—if it compiles with no sorries and standard axioms only, the proof is sound.

Respect scope. Follow the user's preference: fill one sorry, its transitive dependencies, all sorries in a file, or everything. Ask if unclear.

Use 100-character line width for Lean files. Do not wrap lines at 80 characters — Lean and mathlib convention is 100. If a line fits within 100 characters, keep it on one line. See mathlib-style for breaking strategies when lines exceed 100.

Never change statements or add axioms without explicit permission. Theorem/lemma statements, type signatures, and docstrings are off-limits unless the user requests changes. Inline comments may be adjusted; docstrings may not (they're part of the API). Custom axioms require explicit approval—if a proof seems to need one, stop and discuss. Exception: within synthesis wrappers (/lean4:formalize, /lean4:autoformalize), session-generated declarations may be redrafted under the outer-loop statement-safety rules; see cycle-engine.md.

Commands

CommandPurpose
/lean4:draftDraft Lean declaration skeletons from informal claims
/lean4:formalizeInteractive formalization — drafting plus guided proving
/lean4:autoformalizeAutonomous end-to-end formalization from informal sources
/lean4:proveGuided cycle-by-cycle theorem proving with explicit checkpoints
/lean4:autoproveAutonomous multi-cycle theorem proving with explicit stop budgets
/lean4:checkpointSave progress with a safe commit checkpoint
/lean4:reviewRead-only code review of Lean proofs
/lean4:refactorLeverage mathlib, extract helpers, simplify proof strategies
/lean4:golfImprove Lean proofs for directness, clarity, performance, and brevity
/lean4:learnInteractive teaching and mathlib exploration
/lean4:doctorDiagnostics, cleanup, and migration help

This plugin ships a host-agnostic parser (lib/command_args/) that covers the parser-decidable startup rules of the six parameter-heavy commands (draft, learn, formalize, autoformalize, prove, autoprove). A small set of documented startup rules in these commands depend on runtime context (repo- level search, interactive prompting) and are applied by the command after reading the parser's output. The other commands (checkpoint, review, refactor, golf, doctor) remain model-parsed. When a host adapter installs the UserPromptSubmit hook, the parser runs before the model sees a /lean4:* prompt matching one of the six covered commands, injects a validated-invocation block into context, and rejects invalid invocations at the hook level; invocations of the other commands pass through unchanged. Hosts without the hook fall back to model-parsed startup via the shared command-invocation.md contract. Commands always announce resolved inputs, reject invalid startup configs before doing work, and treat wall-clock budgets like --max-total-runtime as best-effort.

Which Command?

SituationCommand
Draft a Lean skeleton (skeleton by default)/lean4:draft
Draft + prove interactively/lean4:formalize
Filling sorries (interactive)/lean4:prove
Filling sorries (unattended)/lean4:autoprove
Save point (per-file + project build, best-effort axiom scan, commit)/lean4:checkpoint
Quality check (read-only)/lean4:review
Simplify proof strategies (mathlib leverage, helpers)/lean4:refactor
Optimizing compiled proofs/lean4:golf
New to this project / exploring/lean4:learn --mode=repo
Navigating mathlib for a topic/lean4:learn --mode=mathlib
Something not working/lean4:doctor
Formalize + prove end-to-end (unattended)/lean4:autoformalize --source=... --claim-select=first --out=...

Contributing (lean4-contribute plugin)

If the lean4-contribute plugin is installed, you may suggest these commands at natural stopping points. Rules:

  • Suggest first, never invoke unprompted. Offer a one-line question; do not start the command flow.
  • Only invoke after explicit user opt-in in the current conversation. Silence, topic change, or implicit frustration do not count as consent.
  • At most once per topic per session unless the user engages.
  • Never mid-proof. Wait for a natural stopping point.
SituationSuggest
Problem appears to be in lean4-skills itself (wrong command behavior, contradictory docs, broken lint, bad guardrail, confusing plugin UX) — not ordinary Lean/mathlib/user-proof problems"This looks like a lean4-skills bug. Want me to draft a bug report?" → /lean4-contribute:bug-report
User wants a workflow the plugin doesn't support, says a command should behave differently, or you must recommend awkward manual steps due to a missing feature"This looks like a plugin workflow gap. Want me to draft a feature request?" → /lean4-contribute:feature-request
Result seems reusable beyond the current task: tactic-selection heuristic, mathlib search pattern, anti-pattern, documentation gap with a clear lesson — not one-off theorem facts or private repo details"That seems reusable beyond this task. Want me to draft a shareable insight?" → /lean4-contribute:share-insight

If the plugin is not installed and the user clearly hit a lean4-skills bug, workflow gap, or reusable insight (same criteria as above — not ordinary Lean/mathlib issues), you may offer the install hint once:

  • At most once per session. Do not repeat if the user declined, ignored it, or moved on.
  • Never mid-proof or during an active debugging loop.
  • One short line, not a pitch: "If you want, install the lean4-contribute plugin and I can draft that report for you here." See the lean4-contribute README for setup.

Typical Workflow

┌─ Entry points (pick one) ──────────────────────────────────────────────────────────┐
│ /lean4:draft              Skeleton by default (--mode=attempt for shallow proof)   │
│ /lean4:formalize          Interactive: draft + guided proving                      │
│ /lean4:autoformalize      Autonomous: draft + autonomous proving                   │
└────────────────────────────────────────────────────────────────────────────────────┘
        ↓ (if sorries remain)
/lean4:prove / autoprove    Proof engines (sorry filling, no header edits)
        ↓
/lean4:refactor            Leverage mathlib, extract helpers (optional)
        ↓
/lean4:golf                Improve proofs (optional)
        ↓
/lean4:checkpoint          Save point (per-file + project build)

Use /lean4:learn at any point to explore repo structure or navigate mathlib. Three entry points: /lean4:draft for skeletons, /lean4:formalize for interactive synthesis (draft + guided proving), /lean4:autoformalize for unattended source-to-proof.

Notes:

  • /lean4:prove asks before each cycle; /lean4:autoprove loops autonomously with explicit stop budgets
  • Both trigger /lean4:review at configured intervals (--review-every)
  • When reviews run (via --review-every), they act as gates: review → replan → continue. In prove, replan requires user approval; in autoprove, replan auto-continues
  • Review supports --mode=batch (default) or --mode=stuck (triage); review is always read-only
  • /lean4:autoformalize wraps draft+autoprove in a single command (source → claims → skeletons → proofs); replaces autoprove --formalize=auto
  • Proof engines (prove/autoprove) never modify declaration headers (header fence)
  • If you hit environment issues, run /lean4:doctor to diagnose

LSP Tools (Preferred)

Sub-second feedback and search tools (LeanSearch, Loogle, LeanFinder) via Lean LSP MCP:

lean_goal(file, line)                           # See exact goal
lean_hover_info(file, line, col)                # Understand types
lean_local_search("keyword")                    # Fast local + mathlib (unlimited)
lean_leanfinder("goal or query")                # Semantic, goal-aware (10/30s)
lean_leansearch("natural language")             # Semantic search (3/30s)
lean_loogle("?a → ?b → _")                      # Type-pattern (unlimited if local mode)
lean_hammer_premise(file, line, col)            # Premise suggestions for simp/aesop/grind (3/30s)
lean_state_search(file, line, col)              # Goal-conditioned lemma search (3/30s)
lean_multi_attempt(file, line, snippets=[...])  # Test multiple tactics
lean_diagnostic_messages(file)                  # Per-file error/warning check
lean_code_actions(file, line)                   # Resolve "Try this" suggestions to edits

lean_run_code is for isolated scratch experiments, not a substitute for live proof-state inspection via lean_goal/lean_multi_attempt/lean_diagnostic_messages. Prefer live-file tools when the question depends on actual file context.

Capabilities

CapabilityRequiredCheckFallback
Lean / Lakeyeslean --version, lake --versionnone — run /lean4:doctor
Python 3yes (scripts)$LEAN4_PYTHON_BIN set by bootstrapnone for script-dependent operations
$LEAN4_SCRIPTSyes (set by bootstrap)echo "$LEAN4_SCRIPTS"run /lean4:doctor
Lean LSP MCPnotry lean_goal on any .lean filescripts + lake env lean (file-level only)
lean_run_codenotry calling itlake env lean on temp file
lean_code_actionsnotry calling itmanual "Try this" application
Subagent dispatchnohost-dependentrun work in main thread
Slash commandsnohost-dependentfollow skill instructions directly

Operating Profiles

The skill adapts to what's available. Determine your profile by checking capabilities above, then follow the corresponding guidance.

full (all capabilities)

MCP + subagents + commands. Full workflow with live goal inspection, tactic testing, and parallel subagent dispatch (requires disjoint owned-file sets per agent, or separate worktrees). Subagents get pre-collected MCP context per cycle-engine.md § Pre-flight Context. If lean_run_code is unavailable, use /tmp scratch files with lake env lean for isolated experiments.

mcp_main_only (MCP available, no subagent dispatch)

MCP works in the main thread. Run all proof work directly — do not delegate to subagents. All cycle-engine phases execute in-thread. If lean_run_code is unavailable, use /tmp scratch files with lake env lean for isolated experiments.

scripts_only (no MCP, no subagents)

Use $LEAN4_SCRIPTS for search and lake env lean / lake build for validation. Key limitations in this mode:

  • No live goal inspection — lean_goal is unavailable; you can read the file and check compilation output, but cannot see proof state at a specific line
  • No tactic testing — lean_multi_attempt is unavailable; edits must be validated by compiling the file (lake env lean)
  • No real-time diagnostics — lean_diagnostic_messages is unavailable; use lake env lean <file> (from project root) for compilation errors, but feedback is file-level, not line-level
  • Search is script-based — $LEAN4_SCRIPTS/smart_search.sh replaces LSP search tools

This mode is functional for straightforward proofs but significantly slower and less precise than MCP-backed workflows.

review_only (read-only, no edits)

Read proof state and assess quality. No edits, no commits, no subagent dispatch.

File Handling Rules

Scratch-work ladder (in preference order):

  1. Live file + MCP tools (lean_goal, lean_multi_attempt, lean_diagnostic_messages)
  2. lean_run_code for isolated experiments
  3. /tmp scratch files only when lean_run_code is unavailable and the experiment must not touch the live file
  4. Never create scratch files in the repo root

File inspection: Use Read and Grep to view source files. Never write Python scripts, temp files, or use cat pipelines just to read lines from a file you already have access to.

Staging: Stage only files touched during the current session. Never use git add -A or broad glob patterns. Print the exact staged set before committing.

See sorry-filling.md for the full scratch-work preference order.

Core Primitives

ScriptPurposeOutput
sorry_analyzer.pyFind sorries with contexttext (default), json, markdown, summary
check_axioms_inline.shBest-effort axiom scan (top-level declarations)text
smart_search.shMulti-source mathlib searchtext
find_golfable.pyDetect optimization patternsJSON
find_usages.shFind declaration usagestext

Usage: Invoked by commands automatically. See references/ for details.

Invocation contract: Never run bare script names. Always use:

  • Python: ${LEAN4_PYTHON_BIN:-python3} "$LEAN4_SCRIPTS/script.py"...
  • Shell: bash "$LEAN4_SCRIPTS/script.sh"...
  • Report-only calls: add --report-only to sorry_analyzer.py, check_axioms_inline.sh, unused_declarations.sh — suppresses exit 1 on findings; real errors still exit 1. Do not use in gate commands like /lean4:checkpoint.
  • Keep stderr visible for Lean scripts (no /dev/null redirection), so real errors are not hidden.

If $LEAN4_SCRIPTS is unset or missing, run /lean4:doctor and stay LSP-only until resolved.

Automation

/lean4:prove and /lean4:autoprove handle most tasks:

  • prove — guided, asks before each cycle. Ideal for interactive sessions.
  • autoprove — autonomous, loops with explicit stop budgets. Ideal for unattended runs.

Both share the same cycle engine (plan → work → checkpoint → review → replan → continue/stop) and follow the LSP-first protocol: LSP tools are normative for discovery and search; script fallback only when LSP is unavailable or exhausted. Compiler-guided repair is escalation-only — not the first response to build errors. For complex proofs, they may delegate to internal workflows for deep sorry-filling (with snapshot, rollback, and scope budgets), proof repair, or axiom elimination. You don't invoke these directly.

Skill-Only Behavior

When editing .lean files without invoking a command, the skill runs one bounded pass:

  • Read the goal or error via lean_goal/lean_diagnostic_messages
  • Search mathlib with up to 2 LSP tools (e.g. lean_local_search + lean_leanfinder/lean_leansearch/lean_loogle)
  • Try the Automation Tactics cascade
  • Validate with lean_diagnostic_messages (no project-gate lake build in this mode)
  • No looping, no deep escalation, no multi-cycle behavior, no commits
  • End with suggestions: Use /lean4:prove for guided cycle-by-cycle help. Use /lean4:autoprove for autonomous cycles with stop safeguards.

Quality Gate

A proof is complete when:

  • lake build passes
  • Zero sorries in agreed scope
  • Only standard axioms (propext, Classical.choice, Quot.sound)
  • No statement changes without permission

Verification ladder: lean_diagnostic_messages(file) per-edit → lake env lean <path/to/File.lean> file gate (run from project root) → lake build project gate only. See cycle-engine: Build Target Policy.

Common Fixes

See compilation-errors for error-by-error guidance (type mismatch, unknown identifier, failed to synthesize, timeout, etc.).

Type Class Patterns

-- Local instance for this proof block
haveI : MeasurableSpace Ω := inferInstance
letI : Fintype α := ⟨...⟩

-- Scoped instances (affects current section)
open scoped Topology MeasureTheory

Order matters: provide outer structures before inner ones.

Automation Tactics

Try in order (stop on first success): rfl → simp → ring → linarith → nlinarith → omega → exact? → apply? → grind → aesop

Note: exact?/apply? query mathlib (slow). grind and aesop are powerful but may timeout. See grind-tactic for interactive workflows, annotation strategy, and simproc escalation.

Troubleshooting

If LSP tools aren't responding, check your operating profile above. In scripts_only mode, $LEAN4_SCRIPTS provides search and lake env lean provides file-level compilation feedback, but live goal inspection, tactic testing, and line-level diagnostics are unavailable. If environment variables (LEAN4_SCRIPTS, LEAN4_REFS) are missing, run /lean4:doctor to diagnose.

Script environment check:

echo "$LEAN4_SCRIPTS"
ls -l "$LEAN4_SCRIPTS/sorry_analyzer.py"
# One-pass discovery for troubleshooting (human-readable default text):
${LEAN4_PYTHON_BIN:-python3} "$LEAN4_SCRIPTS/sorry_analyzer.py" . --report-only
# Structured output (optional): --format=json
# Counts only (optional): --format=summary

Cold start / fresh worktree:

  • Fresh worktree or after lake clean? Prime the cache in that worktree before the first real build.
  • Use the project's cache command: lake cache get on newer Lake, or lake exe cache get where the project still uses the mathlib cache executable.
  • If Lean LSP is cold or timing out on first use, run one lake build to bootstrap the workspace.
  • After bootstrap, return to the normal verification ladder: lean_diagnostic_messages(file) → lake env lean <path/to/File.lean> (from project root) → lake build only at checkpoint/final gate.
  • Do not symlink another worktree's .lake/build; use Lake cache/artifact mechanisms instead.

References

Cycle Engine: cycle-engine — shared prove/autoprove logic (stuck, deep mode, falsification, safety)

LSP Tools: lean-lsp-server (quick start), lean-lsp-tools-api (full API — grep ^## for tool names)

Search: mathlib-guide (read when searching for existing lemmas), lean-phrasebook (math→Lean translations)

Errors: compilation-errors (read first for any build error), instance-pollution (typeclass conflicts — grep ## Sub- for patterns), compiler-guided-repair (escalation-only repair — not first-pass)

Tactics: tactics-reference (tactic lookup — grep ^### TacticName), grind-tactic (SMT-style automation — when simp can't close), simp-reference (simp hygiene + custom simprocs), tactic-patterns, calc-patterns

Proof Development: proof-templates, proof-refactoring (28K — grep by topic), proof-simplification (strategy-level: mathlib search, congr lemmas, helper extraction), sorry-filling

Optimization: proof-golfing (includes safety rules, bounded LSP lemma replacement, bulk rewrites, anti-patterns; escalates to axiom-eliminator), proof-golfing-patterns, performance-optimization (grep by symptom), profiling-workflows (diagnose slow builds/proofs)

Domain: domain-patterns (25K — grep ## Area), measure-theory (28K), axiom-elimination

Style: mathlib-style, verso-docs (Verso doc comment roles and fixups)

Custom Syntax: lean4-custom-syntax (read when building notations, macros, elaborators, or DSLs), metaprogramming-patterns (MetaM/TacticM API — composable blocks, elaborators), scaffold-dsl (copy-paste DSL template), json-patterns (json% syntax + ToJson)

Quality: linter-authoring (project-specific linter rules), ffi-interop (FFI, @&, init, symbol linkage)

Workflows: agent-workflows, subagent-workflows, command-examples, learn-pathways (intent taxonomy, game tracks, source handling)

Internals: review-hook-schema, compiler-internals (attributes, specialization, pipeline)

平台分布

Codex

33.47%
按下载量换算225

Claude

30.59%
按下载量换算206

Cursor

19.64%
按下载量换算132

Gemini CLI

9.99%
按下载量换算67

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills