agentleFS
r-irber-irbe/proof-skills/skills/lean-upstream-pr/SKILL.md

lean-upstream-pr

Skill3 starsChanged 13 days agoApache-2.0View on GitHub

USE FOR: porting lemmas to Mathlib/Stdlib and opening, labelling, or managing upstream Lean 4 PRs. DO NOT USE FOR: in-tree review (@lean-proof-review) or package vendoring (@lean-dependency-management). TRIGGERS: upstream PR, mathlib PR, port lemma, open a PR, bors, changelog label, AI disclosure.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Never push directly to main/master or open an external upstream PR without explicit human sign-off.

    line 48
  2. Very specific:

    If lean_search finds an existing Mathlib lemma up to argument order or ring morphism, abort the port and replace the local copy with the …

    line 49

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Lean 4 & Mathlib Upstream Porting and PR Lifecycle

Generalize reusable in-tree lemmas to Mathlib4/Stdlib conventions and manage the full upstream pull-request lifecycle cleanly and transparently.

Routing

  • USE FOR: generalizing project-local lemmas to Mathlib4 style, branch/commit hygiene, PR titles/labels (feat(Algebra/...): ...), AI-assistance disclosure, and bors review loops.
  • DO NOT USE FOR: shrinking upstream bug reproducers (@lean-mwe) or vendoring external repos into your project (@lean-dependency-management).

Workflow

  1. Deduplicate & Generalize -- Search lean_search(source: "loogle" | "code") to confirm the lemma is absent upstream; strip project-specific scaling/wrappers and generalize typeclasses to minimal Mathlib4 mixins.
  2. Enforce Mathlib4 Style -- Apply snake_case naming, set_option autoImplicit false compatibility, /-- ... -/ docstrings, explicit module imports, and #lint pass (references/protocols/mathlib4-conventions.md).
  3. Prepare PR & Disclosure -- Format conventional title, summary, dependency links (- [ ] depends on: #...), and mandatory AI-tooling disclosure per upstream repository policy.
  4. Human-in-the-Loop Gate -- Present the final diff, #lint output, and PR body for explicit human approval before executing gh pr create.

Recovery & STOP

  • Never push directly to main/master or open an external upstream PR without explicit human sign-off.
  • If lean_search finds an existing Mathlib lemma up to argument order or ring morphism, abort the port and replace the local copy with the Mathlib lemma.

Handoffs

  • Predecessors: lean-proof-review, lean-proof-refactor, lean-mwe.
  • Successors: lean-retro-methodology.

Detailed reference

  • Layer-1 Fast Lookup Card (read first): references/cards/lean-upstream-pr-tables.md
  • Full handbook: ../../references/handbooks/lean-upstream-pr-handbook.md
  • PR template: ../../templates/workflow/Template_PR.md

See also

  • ../../references/protocols/mathlib4-conventions.md -- Mathlib4 style & naming guide
  • ../lean-mwe/SKILL.md -- Minimal working examples for upstream bug reports

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.