Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/cbirkbeck/mathlib-quality/cleanupgit clone --depth 1 https://github.com/CBirkbeck/mathlib-qualityWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00021 | $0.24292 |
| Opus 5 | $0.00010 | $0.12146 |
| Sonnet 5 | $0.00004 | $0.04858 |
| Haiku 4.5 | $0.00002 | $0.02429 |
Grade A, and why
cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 1,848 lines — stays where its author put it; the contents beside it link to each section on GitHub.
/cleanup — Style Audit + Cleanup + Golf
Run a full mathlib-quality pass on a Lean file. Absorbs what used to be /check-style:
the audit phase first, then methodical fixes, then per-declaration deep golf.
This command is slow on purpose. Workers must take as long as they need. Nothing is skipped. Every rule is checked, every declaration is processed, every golfing technique is tried. "I'll come back to this" is forbidden — every audit item gets a concrete action or a documented "n/a: ".
Usage
/cleanup [file_path] -- whole file (the standard mode)
/cleanup [file_path] [decl_name] -- single declaration only
Mode A: Single Declaration
Skip the file-wide phases. Run Phase 4 (per-declaration deep cleanup) on just decl_name.
- Read the file, find the declaration.
- Run
lean_diagnostic_messagesand capture warnings on those lines. - Dispatch the worker agent for that declaration (Phase 4 worker prompt below). The worker
MUST read
golfing-rules.mdandproof-patterns.mdin full as its first step. - Verify compilation.
- Run the buzz pass on the declaration —
Skill(skill="mathlib-quality:buzz", args="<file_path> <decl_name>")— the same hand-off as Phase 6.6 below, scoped to one decl. The declaration must come out under the elaboration budget or carry an explicit buzz deferral (→/decompose-proofflag). - Print before/after report (including the buzz-pass status block from 6.6b).
Mode B: Whole File (the standard mode)
Eleven phases. Do them in order. Do not skip phases.
PHASE 0 DOCTOR pre-flight: baseline must be green
PHASE 1 PREPARE collect context
PHASE 2 STYLE AUDIT full punch-list, no fixes yet
PHASE 3 FILE-LEVEL FIXES work the file-level items from the punch-list
PHASE 4 PER-DECLARATION GOLF one worker per declaration, full audit + full golf + diff gates
PHASE 5a NON-RENAME REFACTORING mathlib replacements, junk-def inlining, big-change escalations
PHASE 5b RENAME PASS consume .mathlib-quality/renames.jsonl queue, apply sequentially
PHASE 6 FINAL VERIFICATION file-level gates + cumulative checks
PHASE 6.5 SIMPLIFY hand off to the built-in /simplify skill for a holistic review pass
PHASE 6.6 BUZZ hand off to /buzz for a performance pass — every decl under budget
PHASE 7 REPORT one consolidated report
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 1,848 lines · 21 tokens per session scan A f5ae4484b812
cleanup is a command published in the GitHub repository CBirkbeck/mathlib-quality (32 stars, last pushed 14d ago), licensed MIT. It adds 21 tokens to every session and 24,292 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
git
Git operations with intelligent commit messages and workflow optimization.
checklist
Generate a custom checklist for the current feature based on user requirements.
clarify
Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec.
specify
Create or update the feature specification from a natural language feature description.
analyze
Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation.
converge
Assess the current codebase against the feature's spec, plan, and tasks, then append any remaining unbuilt work as new tasks to tasks.md so implement can complete it.