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
In this repository43 other files it gives its agents.
- AGENTS.mdAGENTS.md
- counterexample-first-provingSkill
- hol-metamath-adapterSkill
- isabelle-isar-adapterSkill
- itp-cross-portingSkill
- lean-ai-formalizationSkill
- lean-asymptotic-algorithmsSkill
- lean-bisectSkill
- lean-blueprintSkill
- lean-buildSkill
- lean-computational-reflectionSkill
- lean-core-onlySkill
- lean-corpus-auditSkill
- lean-dependency-managementSkill
- lean-doc-syncSkill
- lean-egraph-cpsat-superoptSkill
- lean-gatewaySkill
- lean-kernel-optimizationSkill
- lean-knowledge-formalizationSkill
- lean-math-analysisSkill
- lean-math-discreteSkill
- lean-math-dynamicalSkill
- lean-math-foundationsSkill
- lean-math-optimizationSkill
- lean-math-stochasticSkill
- lean-mweSkill
- lean-pedagogical-expositionSkill
- lean-proof-refactorSkill
- lean-proof-repairSkill
- lean-proof-reviewSkill
- lean-proofSkill
- lean-researchSkill
- lean-retro-methodologySkill
- lean-review-councilSkill
- lean-security-formalizationSkill
- lean-setupSkill
- lean-specificationSkill
- lean-tautology-triageSkill
- lean-unboxed-limbs-swarSkill
- lean-verification-gateSkill
- lean-worker-wrapper-cpsSkill
- research-councilSkill
- rocq-proof-adapterSkill
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
- Distinctive: line 48
Never push directly to main/master or open an external upstream PR without explicit human sign-off.
- Very specific: line 49
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 …
≈ “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.
Files
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, andborsreview loops. - DO NOT USE FOR: shrinking upstream bug reproducers (
@lean-mwe) or vendoring external repos into your project (@lean-dependency-management).
Workflow
- 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. - Enforce Mathlib4 Style -- Apply
snake_casenaming,set_option autoImplicit falsecompatibility,/-- ... -/docstrings, explicit module imports, and#lintpass (references/protocols/mathlib4-conventions.md). - Prepare PR & Disclosure -- Format conventional title, summary, dependency links (
- [ ] depends on: #...), and mandatory AI-tooling disclosure per upstream repository policy. - Human-in-the-Loop Gate -- Present the final diff,
#lintoutput, and PR body for explicit human approval before executinggh pr create.
Recovery & STOP
- Never push directly to
main/masteror open an external upstream PR without explicit human sign-off. - If
lean_searchfinds 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
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.

