Lean workflow
Use this as the general router for a Lean 4 repository built with Lake and Mathlib. Read the repository's own instructions first; they override generic commands and thresholds here. Select a more focused sibling skill when it applies:
lean-project-architecture for public declarations, abstractions, module boundaries, or imports;
lean-search-discovery before attempting a new proof;
lean-proof-patterns while translating or repairing a proof;
lean-naming-style for declarations, files, namespaces, and docstrings;
lean-elaboration for measured performance diagnosis or repair;
lean-elaboration-test for a repository-wide performance snapshot;
lean-statement-audit for exact source-to-declaration correspondence;
lean-orchestrator for an explicitly authorized multi-agent formalization effort.
Use build-proof-dependency-graph for a source-level proof dependency database. It records source topology; it does not determine Lean proof status.
Build and dependency hygiene
- Treat pinned dependencies and their compiled artifacts as read-only during routine project work.
- Never delete dependency
.olean, .ilean, trace, hash, IR, or object files as an invalidation shortcut.
- Follow repository-provided build wrappers and cache guards. Otherwise validate the narrowest project target that covers the edit, for example
lake build Project.Foo.Bar.
- Do not run
lake clean, update the toolchain or dependency pins, or trigger a full dependency rebuild without explicit authorization.
- Before a destructive project-artifact invalidation, resolve the exact project-owned path and confirm that no dependency tree can match it.
- Distinguish project compilation from dependency compilation in build and performance reports.
Workflow
- Read
AGENTS.md or CLAUDE.md, the Lake configuration, toolchain file, target module, and nearby imports.
- Identify the authoritative mathematical source when a declaration represents an external claim. Preserve its binders, carriers, quantifiers, hypotheses, constants, and endpoint conditions.
- Search Mathlib and the project before adding a declaration or inventing a proof route.
- Do not move proof obligations into hypotheses, introduce custom axioms, or disguise unfinished proofs. Keep any explicitly authorized draft theorem quarantined and visibly marked under the repository's draft policy.
- Make the smallest coherent edit and validate it with the repository's guarded command or the narrowest appropriate Lake/Lean command.
- Audit affected public declarations for
sorry, custom axioms, hidden stronger hypotheses, quantifier drift, and constant-dependence drift. Run #print axioms from an untracked probe or other repository-approved audit path, not from a compiled source file.
- Report exact commands and targets, skipped validation, remaining placeholders, and source mismatches.
If work is delegated, obey the repository's agent policy and give each worker a bounded, disjoint task. Do not infer a model requirement, concurrency policy, or permission to spawn agents from this skill.
1---2name: lean-workflow3description: Route Lean 4 work through a repository's Mathlib/Lake conventions. Use when editing Lean files, checking source fidelity or axioms, searching dependencies, validating focused targets, or protecting dependency build artifacts.4metadata:5 source: https://skillmd.com/skills/stanfish06/lean-workflow6---78# Lean workflow910Use this as the general router for a Lean 4 repository built with Lake and Mathlib. Read the repository's own instructions first; they override generic commands and thresholds here. Select a more focused sibling skill when it applies:1112- `lean-project-architecture` for public declarations, abstractions, module boundaries, or imports;13- `lean-search-discovery` before attempting a new proof;14- `lean-proof-patterns` while translating or repairing a proof;15- `lean-naming-style` for declarations, files, namespaces, and docstrings;16- `lean-elaboration` for measured performance diagnosis or repair;17- `lean-elaboration-test` for a repository-wide performance snapshot;18- `lean-statement-audit` for exact source-to-declaration correspondence;19- `lean-orchestrator` for an explicitly authorized multi-agent formalization effort.2021Use `build-proof-dependency-graph` for a source-level proof dependency database. It records source topology; it does not determine Lean proof status.2223## Build and dependency hygiene2425- Treat pinned dependencies and their compiled artifacts as read-only during routine project work.26- Never delete dependency `.olean`, `.ilean`, trace, hash, IR, or object files as an invalidation shortcut.27- Follow repository-provided build wrappers and cache guards. Otherwise validate the narrowest project target that covers the edit, for example `lake build Project.Foo.Bar`.28- Do not run `lake clean`, update the toolchain or dependency pins, or trigger a full dependency rebuild without explicit authorization.29- Before a destructive project-artifact invalidation, resolve the exact project-owned path and confirm that no dependency tree can match it.30- Distinguish project compilation from dependency compilation in build and performance reports.3132## Workflow33341. Read `AGENTS.md` or `CLAUDE.md`, the Lake configuration, toolchain file, target module, and nearby imports.352. Identify the authoritative mathematical source when a declaration represents an external claim. Preserve its binders, carriers, quantifiers, hypotheses, constants, and endpoint conditions.363. Search Mathlib and the project before adding a declaration or inventing a proof route.374. Do not move proof obligations into hypotheses, introduce custom axioms, or disguise unfinished proofs. Keep any explicitly authorized draft theorem quarantined and visibly marked under the repository's draft policy.385. Make the smallest coherent edit and validate it with the repository's guarded command or the narrowest appropriate Lake/Lean command.396. Audit affected public declarations for `sorry`, custom axioms, hidden stronger hypotheses, quantifier drift, and constant-dependence drift. Run `#print axioms` from an untracked probe or other repository-approved audit path, not from a compiled source file.407. Report exact commands and targets, skipped validation, remaining placeholders, and source mismatches.4142If work is delegated, obey the repository's agent policy and give each worker a bounded, disjoint task. Do not infer a model requirement, concurrency policy, or permission to spawn agents from this skill.