agentleFS
FrankieeWFrankieeW/agent-skills/mathlib-workflow/SKILL.md

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

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
  1. Distinctive:

    New theories: if within mathlib's scope

    line 50
  2. Distinctive:

    Ask before contributing new theories:

    line 53
  3. Very specific:

    If unsure, ask on Zulip in #mathlib.

    line 58
  4. Distinctive:

    Consider creating a standalone repository with mathlib as a dependency if your work is outside scope.

    line 61
  5. Distinctive:

    Use Zulip to discuss before and during work

    line 65
  6. Distinctive:

    Add GitHub username to Zulip profile

    line 66
  7. Distinctive:

    Use imperative, present tense

    line 86
  8. Distinctive:

    Anyone can review: - not just maintainers

    line 133
  9. Distinctive:

    Leave room for alternative approaches

    line 147
  10. Distinctive:

    Check impact on compilation time

    line 163

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.git

Daily 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 --fill

What 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:

  1. Is this typically taught in a mathematics department?
  2. Does it align with maintainers' mathematical interests?
  3. 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 documentation

Description

  • Use imperative, present tense
  • Explain motivation and contrast with previous behavior
  • Include : for breaking changes

Dependencies

Depends on: #1234

Git Workflow

Setup Remotes

git remote -v
# Should show:
# origin    https://github.com/YOUR_USERNAME/mathlib4.git
# upstream  https://github.com/leanprover-community/mathlib4.git

Creating 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 --fill

Working 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-name

Review 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

  1. Style - follows naming, formatting
  2. Documentation - doc strings present
  3. Location - correct file/module
  4. Improvements - can be simplified
  5. 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 !bench on PR to trigger benchmarking
  • Significant changes need proactive benchmarking:
    • New classes/instances
    • New simp lemmas
    • Changed imports
    • New definitions

Avoiding Regressions

  • Profile before submitting
  • Check impact on compilation time

Resources

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.