Math First
Name the math. Then write the code.
A skill for math-first development: it makes your coding agent find the mathematical object a problem really is
before it writes code, then make the math the spec: named assumptions, a known bound, a measured baseline and null
case, the smallest build that meets the bound, and tests that prove it holds.
One skill, native installs on Claude Code, OpenAI Codex, Antigravity, Pi, Hermes, ZCode, OpenClaw, and anything else
that reads the Agent Skills SKILL.md standard. Built on the
omniplugin pattern: one portable core, thin per-platform glue.
Why
Agents write code fast and argue about it in sentences. A sentence cannot be tested. "Retries make it more reliable",
"the cache should help", "the alert is not too noisy", "the new version is faster": each hides a quantity, a model, a
bound and a null case that nobody wrote down. So the agent tunes a constant by feel, ships a threshold whose false
alarm rate is a guess, or optimizes a step that was never the bottleneck.
Most of these problems were solved long ago, often in another field. Caching is online paging, with a proven
competitive ratio. A rate limiter is an arrival curve. A flaky-test budget is a binomial bound. A canary is a
sequential test. An autoscaler is a feedback loop with delay. Math First makes the agent name that object first.
The known result then comes with the name, and so do the tests that check it.
The loop
Six questions, in order, written down:
- Frame: what quantity or decision matters to the user? A unit and a direction.
- Model: which mathematical object is this? Every assumption gets a name: A1, A2, …
- Bound: what does the math say is possible? Cite the result, and check its hypotheses.
- Measure: where are we now, including on the null case? A statistic never run on the null is a guess.
- Build: the smallest implementation that meets the bound. No magic numbers.
- Prove: tests that encode the math (property, differential, mutation, null simulation). Then re-measure.
Every claim gets one of four statuses: proved, measured, assumed or not claimed. The agent picks a
rigor rung from stakes × irreversibility, from R0 (a napkin) to R3 (a formal proof of the core), and says which one it
used.
What your agent gets
| Piece | What it does |
|---|
SKILL.md | the one line, four layers, six questions, ten principles, the rigor ladder, six lenses, a router by task type, the output contract |
references/lenses.md | physics, chemistry, biology, economics, information theory, control: the question each asks, known results, a worked example each, a transplant checklist |
references/structures.md | 18 common engineering problems mapped to their math object, known result, citation and code check (matching, caching, queues, hashing, ranking, quorums, lattices, estimation, sequential tests, scale laws, retries, clocks) |
references/statistics.md | traps and tools: exact tests at small n, peeking and group-sequential designs, recycling α on discrete looks, multiple comparisons, e-values and confidence sequences, power, null simulation, clustering, tails, proper scores, a pre-registration card |
references/verification.md | property, differential, metamorphic and mutation tests; calibrating a model against the system; dominance by enumeration; null simulations through the real code; R3 tools; receipts |
references/rigor-ladder.md | R0–R3: how to choose the rung, what each one produces, what each one can claim |
references/anti-patterns.md | 19 ways math-shaped work goes wrong while looking rigorous, and review smells |
references/templates/ | math-brief.md (the R1+ deliverable), foundations.md (a project's mathematical spec), receipt.json (what a measured claim records) |
scripts/mf.py | stdlib-only calculator, exact rational arithmetic where it can be: binom, needed, samplesize, multi, cs-bernoulli, spend, seq-binary. Every answer prints its assumptions and its source |
scripts/selftest.py | known values, exact coverage, brute-force differential checks and a null simulation; no network |
Install