Mathlib review
Review guidelines for Mathlib PRs. Use when reviewing pull requests, checking code quality, or assessing whether a PR is ready to merge.From its SKILL.md
npx -y skills add leanprover/skills --skill mathlib-reviewAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.5 KB, as published. Nobody here has run it
Mathlib PR Review
Attributes and API
- New definitions should come with associated lemmas and appropriate attributes (
@[simp],@[ext], etc.). - Watch for instance diamonds.
- Prefer bundled morphisms,
FunLikeAPI for morphism classes,SetLikeAPI for subobject classes.
Style Points Specific to Mathlib
- Simp squeezing: Terminal
simpcalls should NOT be squeezed (replaced withsimp only [...]) unless there's a measured performance problem. Unsqueezedsimpis more maintainable and doesn't break when lemmas are renamed. - Normal forms: Prefer
s.Nonemptyover alternatives. Usehne : x ≠ ⊥in hypotheses (easier to check),hlt : ⊥ < xin conclusions (more powerful). - Transparency: Needing
erw, orrflaftersimp/rwusually means the API is missing lemmas. - File size: Consider splitting files that exceed ~1000 lines or cover multiple topics.
Reference Guides
The full review guide and style references:
- Review guide: https://leanprover-community.github.io/contribute/pr-review.html
- Naming conventions: https://leanprover-community.github.io/contribute/naming.html
- Code style: https://leanprover-community.github.io/contribute/style.html
- Documentation style: https://leanprover-community.github.io/contribute/doc.html