/mqslim:mthlblfrom mqslim
Slim shadow of mathlib-quality's /mathlibable. Decide whether a Lean declaration belongs in mathlib. Runs the exhaustive literature + mathlib + composition check, then produces one of five verdict buckets with evidence. Trusts the model to do the search work without per-row required-artifact tables. Use on a single declaration; for files, run sequentially.
Ships in mqslim. Installing the plugin adds it to Claude Code.
Take one Lean declaration and answer: should mathlib have this? The value is in the search work, not the verdict — and the search is exhaustive on every invocation. Mathlib is Bourbaki 2.0; the right declaration in the right form takes thorough investigation every time. There is no quick mode.
/mthlbl Foo.bar # one declaration, full workflow
/mthlbl <file.lean> # every public decl in file (sequential)
/mthlbl <file1.lean> <file2.lean> ... # multiple files
lake build clean (the declaration must elaborate).n/a if not..mathlib-quality/references/ for source-paper notes.Resolve and read. Locate the decl in the project; capture its
signature, docstring, and proof body. Skip and record SKIP if any
of: private/local, in test//examples/, name ends _aux,
docstring starts with internal/auxiliary, qualified name already
exists in mathlib (cheap grep of .lake/packages/mathlib/Mathlib/).
Write the prose statement. Convert the Lean type to standard mathematical English in 2–4 sentences. This is where the search starts; skip this and the search returns nothing.
Exhaustive literature search (nine channels, all required):
.mathlib-quality/references/ (or record n/a with reason).For each channel: record the query, hit/miss, and the standard form
the channel suggests. A skipped channel without n/a + reason is a
defect.
Generality analysis (per parameter). For each typeclass / hypothesis
in the user's form, compare to the literature-standard form. Drop unused
typeclasses; turn whole-family ∀ into pointwise; weaken
[CommRing R] → [Ring R] / [CommSemiring R] when the proof allows.
Verdict: MAXIMALLY GENERAL or STRICTLY NARROWER (with a proposed
restatement).
Bourbaki 2.0 modern-idiom check. Even if statement-side is "maximally general" relative to literature, ask whether contemporary mathlib idioms would re-state with real downstream consequences: typeclasses over preambles, filters over sequences, universal properties over constructions, bundled types over set-with-closure- predicates, modules over vector spaces, higher categories over 1-categories, generic algebraic-structure indices over concrete ℕ/ℤ/ℝ.
Q8 — concrete-via-abstract (the proof-outruns-the-statement check):
if the statement mentions a concrete object (E2, π, a specific
group) but the proof body, after the first one or two unfolding
rewrites, never mentions that object again — propose the abstract
restatement with the concrete result as a one-line corollary.
Diagnostic: grep the proof body for the named identifier; if it
appears in 0 or 1 lines after the first rw, fire.
Diamond / defeq risk (only for def/class/instance). Six
questions: typeclass diamond? reducibility leak? non-canonical
unfolding? instance priority collision? universe issues? coercion
ambiguity? Probe with #synth, set_option trace.Meta.synthInstance,
rfl-defeq probes. Overall risk NONE/LOW/HIGH; HIGH adds a Phase-7
constraint (rationale must address each HIGH row).
Mathlib search — five methods, on BOTH the user's form AND the literature-standard / modern-idiom form:
lean_local_search (name patterns)Conclude: found in mathlib (cite by qualified name) / found more general / partial match / building blocks only / not in mathlib.
Composition + call-sites check.
.symm, .trans chains, single
function call, projection chain. Real compositions are mechanical;
by rw [..]; ring_nf; aesop chains are proofs, not compositions.Verdict — one of five buckets (see references/mathlibable-buckets.md
for what evidence each needs):
YES-add-as-isYES-but-generalise-first (reason: LITERATURE-WEAKENING or MODERN-IDIOM)NO-mathlib-has-itNO-composable-from-mathlibBORDERLINE-needs-human (with numbered questions)For NO verdicts, apply Yang's Stage 1 "belongs elsewhere" check: if the result is worth keeping somewhere despite not being mathlib material, name the destination (Archive/, CombinatorialGames, a downstream library, a project-local file).
For YES-add-as-is: rationale must name the specific mathlib gap /
TODO / missing-API anchor (not just "searched, didn't find"); propose
PR location + grouping.
For YES-but-generalise-first: positive evidence required — a
specific named hypothesis/typeclass to drop AND a successful Phase-4
mechanical-weakening verification (the proof actually compiles
without it). "Looks specialised" / "literature is more general" is
NOT sufficient; the most over-produced false positive is firing this
verdict on something that's actually MAXIMALLY GENERAL (every
hypothesis used). Route elsewhere on the five false-positive classes
in references/mathlibable-buckets.md § False-positive routing.
For NO verdicts: rationale must give the concrete refactor plan
keyed to the K call sites at refactor-actionable detail (the exact
mathlib decl to call, or the composition sketch ≤3 lines).
Cost is NOT a verdict factor. EXPENSIVE generalisations are explicitly worth doing — mathlib is Bourbaki 2.0.
Yang's Stages 3 and 5 — mandatory additional checks (see
references/mathlib-review-stages.md):
ModuleCat →
AddCommMonoid is not a generalisation, it's a different def.Persist the full per-decl report to
.mathlib-quality/mathlibable/<decl>.md. The search is expensive;
discarding the report is a real loss.
When the argument is a file (or several), enumerate every public decl
(handle Lean 4 module syntax: public def, @[expose] public def,
@[simp] public lemma, noncomputable public def, etc.), pre-filter the
cheap SKIPs, then dispatch ONE Agent per surviving decl running this full
workflow. Sequential — external API rate limits. Between dispatches,
narrate exactly one scoreboard line.
Def-first ordering: assess defs before their dependent lemmas; a glue
lemma (:= rfl / := Iff.rfl) inherits the parent's verdict.
Re-aim: if a parent def is NO-mathlib-has-it because of more-general
D', dependent lemmas re-aim at D' (analogous mathlib lemma exists →
NO; absent → YES-but-generalise-first stated against D') rather than
blanket-inheriting NO.
Pass --refs=<absolute path> to each worker so they find the
reference docs in the plugin cache.
Aggregate into MATHLIBABLE_REPORT.md at the project root.
/genrlz.What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub cbirkbeck/mqslim --plugin mqslim5 commands in this plugin
/bstmodeSlim shadow of mathlib-quality's /beastmode. Marathon work session — pick a ticket, finish the goal, stop at nothing. Spawn sub-tickets for missing infrastructure; replan via /devel --continue when the sketch is wrong; mandatory /clnup on every completed proof before mark-done. Trusts the model on the marathon discipline; specifies only the genuine stop conditions and the post-proof cleanup contract./clnupSlim shadow of mathlib-quality's /cleanup. Audit + golf + style + mathlib-replacement on a Lean file (or single declaration). Trusts the model to apply the conventions in skills/mqslim/SKILL.md and to use `lean_diagnostic_messages` / `lean_loogle` / `lean_leansearch` / `lean_local_search` for the audit work. Four hard gates the worker MUST verify before reporting done; everything else is judgement./decoproofSlim shadow of mathlib-quality's /decompose-proof. Break long Lean proofs (>50 lines) into focused helper lemmas. Two passes: analysis (identify candidates + write decomposition plans) → decompose (extract helpers, golf them, update the main proof). Five-item helper-hygiene curation per extracted helper before any PR. Trusts the model on the decomposition mathematics; specifies the hygiene rails reviewers catch./develSlim shadow of mathlib-quality's /develop. Plan a mathematical development — search mathlib, design the API, decompose the proof from the source, write a ticket board. Planning-only; workers run via /bstmode. Source-faithful: every leaf must be discharged from a verbatim source quote OR an explicit API gap. Trusts the model to do the literature work without per-step prescriptions.