mathlib-workflow
Skill0 starsChanged 8 months agoMITView on GitHub
Complete workflow for contributing to mathlib (Lean 4), including repo setup, git workflow, PR creation, and review process.
- Commits and pushes
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ccswitchSkill
- code-rulesSkill
- leanmgr-cache-managerSkill
- learn-math-by-lean-notebookSkill
- lmfdb-cliSkill
- mathlib-styleSkill
- openclaw-rssSkill
- pre-initSkill
- pr-worktree-workflowSkill
- sshSkill
- tmuxSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
New theories: if within mathlib's scope
- Distinctive: line 53
Ask before contributing new theories:
- Very specific: line 58
If unsure, ask on Zulip in #mathlib.
- Distinctive: line 61
Consider creating a standalone repository with mathlib as a dependency if your work is outside scope.
- Distinctive: line 65
Use Zulip to discuss before and during work
- Distinctive: line 66
Add GitHub username to Zulip profile
- Distinctive: line 86
Use imperative, present tense
- Distinctive: line 133
Anyone can review: - not just maintainers
- Distinctive: line 147
Leave room for alternative approaches
- Distinctive: line 163
Check impact on compilation time
≈ “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.
Files
Contributing Workflow for mathlib
A guide for the contribution process to mathlib4, the standard library for Lean 4.
Quick Start
One-time Setup
# Fork and clone using GitHub CLI (recommended)
gh repo fork leanprover-community/mathlib4 --default-branch-only --clone
cd mathlib4
# Or manually:
# 1. Fork on GitHub
# 2. Clone your fork: git clone https://github.com/YOUR_USERNAME/mathlib4.git
# 3. Add upstream: git remote add upstream https://github.com/leanprover-community/mathlib4.gitDaily Workflow
# Update master
git switch master
git pull
# Create feature branch
git switch -c my-feature-branch
# Make changes, commit, push
git add .
git commit -m "feat: add theorem X"
git push
# Open PR on GitHub or via CLI
gh pr create --fillWhat to Contribute
Welcome Contributions
- Small fixes: docstring fixes, typo corrections
- Single lemma additions: to existing theories
- Extended theories: new theorems extending existing areas
- New theories: if within mathlib's scope
Scope Check
Ask before contributing new theories:
- Is this typically taught in a mathematics department?
- Does it align with maintainers' mathematical interests?
- Can you find a reviewer?
If unsure, ask on Zulip in #mathlib.
External Projects
Consider creating a standalone repository with mathlib as a dependency if your work is outside scope.
Communication
- Use Zulip to discuss before and during work
- Add GitHub username to Zulip profile
- Set display name to real name
PR Conventions
Title Format
<type>(<optional-scope>): <subject>Types: feat, fix, doc, style, refactor, test, chore, perf, ci
Examples:
feat(Data/Nat): add factorial function
fix(Algebra/Group): resolve instance synthesis issue
doc: improve module documentationDescription
- Use imperative, present tense
- Explain motivation and contrast with previous behavior
- Include
:for breaking changes
Dependencies
Depends on: #1234Git Workflow
Setup Remotes
git remote -v
# Should show:
# origin https://github.com/YOUR_USERNAME/mathlib4.git
# upstream https://github.com/leanprover-community/mathlib4.gitCreating PRs
# Keep master updated
git switch master
git pull
# Create branch
git switch -c my-feature
# Push and create PR
git push
gh pr create --fillWorking on Others' PRs
# Via GitHub CLI
gh pr checkout 1234
# Manually
git remote add contributor https://github.com/USERNAME/mathlib4.git
git fetch contributor
git checkout contributor/branch-nameReview Process
Finding Reviewers
- Anyone can review - not just maintainers
- Seek out reviewers yourself
- Partial reviews are helpful
- History of reviews → eligibility for reviewer/maintainer teams
What Reviewers Check
- Style - follows naming, formatting
- Documentation - doc strings present
- Location - correct file/module
- Improvements - can be simplified
- Library integration - fits with existing API
Being Reviewed
- Be respectful and encouraging
- Leave room for alternative approaches
- Recognize you may be wrong
- Helpful reviews criteria for maintainer eligibility
Performance
Benchmarking
- Comment
!benchon PR to trigger benchmarking - Significant changes need proactive benchmarking:
- New classes/instances
- New
simplemmas - Changed imports
- New definitions
Avoiding Regressions
- Profile before submitting
- Check impact on compilation time
Resources
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
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.

