contribute

A command that collects useful lessons from local mathlib-quality work and prepares them for contribution to the shared mathlib-quality repository. A pull request is a proposed set of changes for review before merging into a repository.

In plain words
What is it for?
Use it to review and deduplicate entries in .mathlib-quality/learnings.jsonl, preview the contribution, or create a GitHub pull request when the required learnings and authentication are available.
Why use it?
It helps turn locally discovered proof and style improvements into reusable knowledge for other users.

Command

Install

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.

agentmods
npx agentmods add commands/cbirkbeck/mathlib-quality/contribute
Clone the repo
git clone --depth 1 https://github.com/CBirkbeck/mathlib-quality
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,638 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.01638
Opus 5 $0.00009 $0.00819
Sonnet 5 $0.00003 $0.00328
Haiku 4.5 $0.00002 $0.00164

Measured 2d ago against content hash f97b72eca1ff, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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

commands/contribute.md · 246 lines

How it starts

The opening of the file, as written. The whole thing — 246 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/contribute - Contribute Learnings Back

Review local learnings and create a PR to contribute them to the mathlib-quality repository, so all users benefit.

Usage

/contribute
/contribute --dry-run   (preview without creating PR)

Prerequisites

  • .mathlib-quality/learnings.jsonl exists with at least one entry
  • gh CLI is authenticated (for creating PRs)
  • Network access to GitHub

Workflow

Step 1: Read Local Learnings

Read .mathlib-quality/learnings.jsonl and parse all entries.

If the file doesn't exist or is empty:

No learnings found in `.mathlib-quality/learnings.jsonl`.

Run some commands (/cleanup, /teach) first to accumulate learnings,
then come back to contribute them.

Step 2: Deduplicate

Remove duplicate entries:

  • Same before_code AND after_code = duplicate (keep the more recent one)
  • Same description with same type = likely duplicate
  • Entries with "accepted": false are kept separately (valuable negative data)

Step 3: Present Summary

Show the user what was found, grouped by type:

## Learnings Summary

Found N learnings in `.mathlib-quality/learnings.jsonl`:

### Golf Patterns (X entries)
1. [theorem_name] Inlined have + term mode: 3 lines → 1 line
2. [theorem_name] grind closed Finset.card goal
3. ...

### Style Corrections (Y entries)
1. Fixed by-placement pattern in 5 proofs
2. ...

### Mathlib Discoveries (Z entries)
1. Replaced custom `finite_of_discrete` with `IsCompact.finite`
2. ...

### User Teachings (W entries)
1. "Always try grind before omega for Fin goals"
2. ...

### Failed Patterns (V entries)
1. grind timed out on algebraic goals with ring structure
2. ...

---

Select which to contribute:
- [a] All accepted learnings (N entries) (Recommended)
- [s] Select individually
- [n] None (cancel)

Step 4: User Selection

Let the user choose which learnings to include. By default, include all entries where "accepted": true. Entries with "accepted": false are included only if the user explicitly selects them (they're valuable as negative examples).

Read the full file on GitHub · 246 lines

Changes

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.

  1. 2d ago First seen · 246 lines · 17 tokens per session scan A f97b72eca1ff

Subscribe to this mod's changes

contribute is a command published in the GitHub repository CBirkbeck/mathlib-quality (32 stars, last pushed 14d ago), licensed MIT. It adds 17 tokens to every session and 1,638 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.