Start here
New to excyst? Read what it is, in plain words first: what it checks, whether it fixes code and what it needs. After that, four commands cover almost everything. Run them in this order the first time.
curl -LsSf https://excyst.com/install.sh | sh # 1 install it
excyst tour # 2 watch it catch the bugs in a file an agent wrote
excyst prove metrics.py # 3 prove your own code
excyst connect --write # 4 let Claude Code, Cursor or Codex call it themselves
Lost at any point? excyst help lists every command, excyst help prove explains one, and excyst followed by any idea (excyst entropy) searches the 1,000+ formulas.
excyst help
excyst proves the math your coding agent writes: 1,000+ verified formulas, and a prover that runs your code against them. It also holds trained models to a written objective (calibration, coverage, robustness). start here: excyst tour watch excyst catch the bugs in a file an agent wrote (no setup) excyst prove metrics.py prove code against a verified formula excyst connect let Claude Code, Cursor or Codex call excyst themselves excyst check example_predictions.csv test whether a model can be trusted excyst find kl divergence search 1,000+ research formulas: entropy, adam, attention, p-value... more: excyst help <command> or just excyst <an idea> (it searches the formulas) all commands: tour, prove, connect, demo, example, check, explain, find, formulas, copy, export, verify, init, report, help
Install
The script installs with uv if you have it, otherwise pipx, otherwise pip --user. Read it first; it is twenty lines.
curl -LsSf https://excyst.com/install.sh | sh
Or directly from the wheel:
uv tool install https://excyst.com/dl/excyst-0.2.1-py3-none-any.whl
pipx install https://excyst.com/dl/excyst-0.2.1-py3-none-any.whl
pip install https://excyst.com/dl/excyst-0.2.1-py3-none-any.whl # into the current environment
It needs Python 3.11 or newer and numpy, nothing else: no account, no key, no network. excyst --version prints excyst 0.2.1 when it worked. If the command is not found, open a new terminal (with uv, run uv tool update-shell once). Running the install line again updates it; uv tool uninstall excyst, pipx uninstall excyst or pip uninstall excyst removes it.
Two ways to run it
The same commands work in two places: an interactive screen for you, and plain output for scripts, CI and agents.
| You type | What happens |
|---|---|
excyst | Opens the screen. Inside it you type commands without the word excyst: tour, prove metrics.py, entropy. |
excyst prove metrics.py | In a terminal, opens the screen with that result in it, so you can keep going. When you quit, the result stays in your scrollback. |
excyst prove metrics.py --plain | Prints the result as text and exits with a status code. Nothing interactive. |
excyst entropy | Anything that is not a command searches the formulas, the same as excyst find entropy. |
Output is always plain when it is piped or redirected, in CI, with --plain or EXCYST_PLAIN=1, and for connect, mcp, help and --json -. The screen needs macOS or Linux; on Windows every command prints plain text.
The screen
Run excyst on its own. Under the logo, the start panel offers four first steps: type 1 for the tour, 2 to prove a file, 3 to connect your agent, 4 to check a model. Or type any command, or any idea, and press enter.
While you type, the line at the bottom says what that command does and how to finish it. Type a command on its own (prove, check, find, copy, export, report) and it asks for what it needs, with numbered choices (the matching files in your folder, or popular formulas): type a number or your own answer, press enter for the default, esc to cancel.
| Key | What it does |
|---|---|
| enter | Run what you typed. |
| / | The command menu. ↑ ↓ choose, tab or enter fills it in. |
| tab | Complete a command or a file name: prove met tab gives prove metrics.py. |
| ↑ ↓ | Earlier lines, to run again after you change the code. |
| pgup pgdn, wheel | Scroll the results. A long result opens at its first line. |
? or help | After a command, its guide: prove ?. On its own, help lists every command. |
| esc | Close the menu, or cancel a question. |
| ctrl-c | Clear the line, or cancel a question. Press it twice to quit. |
ctrl-d, quit | Quit (ctrl-d on an empty line). |
clear, ctrl-l | Empty the screen; redraw it. |
| ctrl-a ctrl-e ctrl-u ctrl-k ctrl-w | Start and end of the line, delete to the start, to the end, the last word. |
The screen needs a terminal of at least 64 columns by 22 rows, and draws in 24-bit colour. If it looks wrong in yours, add --plain: the results are the same.
1 · tour
excyst tour writes the kind of metrics.py a coding agent produces in a hurry, where everything runs and the numbers look plausible, then proves each function against its verified formula. Nothing to set up, and it takes a second. This is all of it:
excyst tour
tour an agent was asked for “the usual evaluation helpers” and wrote metrics.py. Every function runs. Every number looks plausible. excyst matches each function to a verified formula and proves it. prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example p=[0.5, 0.5] q=[0.9, 0.1] (worked example) yours 0.736966 reference 0.510826 (also computed independently: 0.510826) 10 ms prove softmax ← metrics.py:softmax formula softmax(z)ₖ = exp(zₖ) / Σⱼ exp(zⱼ) chosen the function name matches the formula id softmax inputs z passed by name FAIL right on all 25 inputs, but not on large ones overflow with z at magnitude 1000 the answer is finite and this code gives nan: an overflow (subtract the max before exp, or work in log-space) 1 ms prove standard_error ← metrics.py:standard_error formula SE = σ / √n chosen the function name matches the formula id standard_error inputs s, n passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × √(n/(n−1)): n−1 where this formula has n, inside a square root (n is the input n) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example s=2 n=100 (worked example) yours 0.201008 reference 0.2 (also computed independently: 0.2) 1 ms prove cosine_similarity ← metrics.py:cosine_similarity formula cos θ = x·y / (‖x‖‖y‖) chosen the function name matches the formula id cosine_similarity inputs x, y passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is 1 − the formula's: the complement (distance vs similarity, p vs 1 − p) [likely bug] example x=[1, 0] y=[1, 1] (worked example) yours 0.292893 reference 0.707107 (also computed independently: 0.707107) 1 ms prove kl_gaussians ← metrics.py:kl_gaussians formula KL = ln(σ₂/σ₁) + (σ₁² + (μ₁−μ₂)²) / (2σ₂²) − ½ chosen the function name matches the formula id kl_gaussians inputs m1, s1, m2, s2 passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is the formula's + ½ on every input: a constant term is added or dropped [likely bug] example m1=0 s1=1 m2=1 s2=2 (worked example) yours 0.943147 reference 0.443147 (also computed independently: 0.443147) 1 ms prove entropy ← metrics.py:entropy formula H(X) = −Σₓ p(x) log p(x) chosen the function name matches the formula id entropy inputs p passed by name PASS agrees with the reference on all 25 inputs (the worked example ✓ and 24 random, seed 0) 1 ms metrics.py 1 of 6 proved 5 of 6 functions are wrong, and nothing crashed. In your own project: excyst prove metrics.py every function whose name matches a formula excyst prove metrics.py:kl kl_divergence one function, one formula excyst connect let Claude Code, Cursor or Codex call it themselves
Five of the six functions are wrong. The rest of this page is how to find the same mistakes in your own code.
2 · prove
excyst prove metrics.py # every public function whose name matches a formula
excyst prove metrics.py:kl # one function; formula matched from its name or docstring
excyst prove metrics.py:kl kl_divergence # one function, one formula (an id from excyst find)
excyst prove metrics.py:kl kl_divergence --args p,q --seed 3 --json run.json
A failure, and the fix
The tour's kl_divergence, proved on its own:
excyst prove metrics.py:kl_divergence
prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example p=[0.5, 0.5] q=[0.9, 0.1] (worked example) yours 0.736966 reference 0.510826 (also computed independently: 0.510826) 1 ms
The diagnosis is a convention: the code returns bits, and the formula is in nats. If nats is what you meant, change np.log2 to np.log and prove it again:
excyst prove metrics.py:kl_divergence
prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name PASS agrees with the reference on all 25 inputs (the worked example ✓ and 24 random, seed 0) 1 ms
How a function is matched
By its name (kl_divergence, klDivergence, standard_error), then by its docstring. To be explicit, put excyst: <id> in the docstring or pass the id. If the best name match takes different inputs (variance(x, p) for your variance(x)), the closest formula your arguments fit is used and the output says so (sample_variance). The chosen line always says why a formula was picked.
How inputs are passed
By name when your parameters use the formula's input names, otherwise in the formula's order. --args p,q gives the order explicitly. excyst formulas <id> shows the input names and the worked example.
What is run
- The worked example. Your result must match the reference and the independently computed expected value.
- 24 fresh inputs drawn from the formula's domain with the seed (default 0): scalars keep their sign and range, distributions stay on the simplex, symmetric positive-definite matrices stay so, sorted grids stay sorted, labels keep their values, whole-number sizes keep their order relations.
- If all agree, an overflow probe: inputs scaled to magnitude 1000 where the true answer is finite (a stable reference is used for softmax, sigmoid, softplus and softmax cross-entropy).
Reading a failure
why names the relation that explains every mismatch: a constant factor (, , , , , , , ), a size factor (, , , , ), a constant offset, square or root, complement, reciprocal, log or exp, transpose, reversed or reordered values, or a wrong shape. It is tagged convention when the code may be right under another convention, otherwise likely bug. blame lists the inputs that, varied alone, break agreement. example is a counterexample with your value and the reference.
A whole file
excyst prove metrics.py proves every public function whose name or docstring matches a formula, one after another, and ends with a count. Functions it cannot match are listed, not guessed.
The output for the tour's metrics.py
excyst prove metrics.py
prove kl_divergence ← metrics.py:kl_divergence formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) chosen the function name matches the formula id kl_divergence inputs p, q passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example p=[0.5, 0.5] q=[0.9, 0.1] (worked example) yours 0.736966 reference 0.510826 (also computed independently: 0.510826) 1 ms prove softmax ← metrics.py:softmax formula softmax(z)ₖ = exp(zₖ) / Σⱼ exp(zⱼ) chosen the function name matches the formula id softmax inputs z passed by name FAIL right on all 25 inputs, but not on large ones overflow with z at magnitude 1000 the answer is finite and this code gives nan: an overflow (subtract the max before exp, or work in log-space) 1 ms prove standard_error ← metrics.py:standard_error formula SE = σ / √n chosen the function name matches the formula id standard_error inputs s, n passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why × √(n/(n−1)): n−1 where this formula has n, inside a square root (n is the input n) [convention] if that convention is the one you want, the code is fine; otherwise it is the fix example s=2 n=100 (worked example) yours 0.201008 reference 0.2 (also computed independently: 0.2) 1 ms prove cosine_similarity ← metrics.py:cosine_similarity formula cos θ = x·y / (‖x‖‖y‖) chosen the function name matches the formula id cosine_similarity inputs x, y passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is 1 − the formula's: the complement (distance vs similarity, p vs 1 − p) [likely bug] example x=[1, 0] y=[1, 1] (worked example) yours 0.292893 reference 0.707107 (also computed independently: 0.707107) 1 ms prove kl_gaussians ← metrics.py:kl_gaussians formula KL = ln(σ₂/σ₁) + (σ₁² + (μ₁−μ₂)²) / (2σ₂²) − ½ chosen the function name matches the formula id kl_gaussians inputs m1, s1, m2, s2 passed by name FAIL agrees on 0 of 25 inputs worked example ✗ why the result is the formula's + ½ on every input: a constant term is added or dropped [likely bug] example m1=0 s1=1 m2=1 s2=2 (worked example) yours 0.943147 reference 0.443147 (also computed independently: 0.443147) 1 ms prove entropy ← metrics.py:entropy formula H(X) = −Σₓ p(x) log p(x) chosen the function name matches the formula id entropy inputs p passed by name PASS agrees with the reference on all 25 inputs (the worked example ✓ and 24 random, seed 0) 1 ms metrics.py 1 of 6 proved
Exit codes
0 every proof passed · 1 a proof failed · 2 nothing could be proved (no match, bad arguments, missing file).
JSON
--json run.json saves the result next to the text; --json - prints only the JSON:
excyst prove metrics.py:kl_divergence --json -
{
"formula": "kl_divergence",
"title": "Kullback–Leibler divergence",
"plain": "KL(p‖q) = Σₓ p(x) log( p(x)/q(x) )",
"latex": "D_{\\mathrm{KL}}(p\\,\\|\\,q)=\\sum_x p(x)\\log\\frac{p(x)}{q(x)}",
"target": "metrics.py:kl_divergence",
"passed": false,
"agreed": 0,
"cases": 25,
"seed": 0,
"binding": "by name",
"matched": "the function name matches the formula id kl_divergence",
"diagnosis": {
"what": "× 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats)",
"kind": "convention"
},
"sensitive_to": [],
"stable": null,
"stability_note": null,
"error": null,
"counterexample": {
"label": "worked example",
"inputs": {
"p": [
0.5,
0.5
],
"q": [
0.9,
0.1
]
},
"yours": 0.7369655941662061,
"error": null,
"reference": 0.5108256237659907
},
"seconds": 0.001
}A whole file gives {"file", "passed", "proofs": [...], "unmatched": [...]}.
3 · connect your agent
excyst connect # shows what it would change for each agent it finds
excyst connect --write # does it (Claude Code via claude mcp add; others get one config entry, with a .bak)
excyst connect --rules # a paragraph for AGENTS.md or CLAUDE.md
Nothing changes until you add --write. Name one agent to limit it: excyst connect cursor --write. By hand: Claude Code claude mcp add --scope user excyst -- excyst mcp; Cursor ~/.cursor/mcp.json under mcpServers; Codex ~/.codex/config.toml as [mcp_servers.excyst]; Windsurf ~/.codeium/windsurf/mcp_config.json; VS Code .vscode/mcp.json under servers. In each, the command is excyst with the argument mcp. Restart the agent afterwards so it loads the server.
The rule for AGENTS.md or CLAUDE.md
Agents use a tool more reliably when the project says when to. excyst connect --rules prints this; paste it in:
excyst connect --rules
## Math in code When you write or change code that computes a formula (a metric, loss, statistic, test, density, estimator or numerical method), use the excyst MCP tools: get_formula before writing it, prove after. A FAIL is a failing test. If the diagnosis is a convention (bits vs nats, n vs n-1), say which one the code uses on purpose.
The MCP server
excyst mcp speaks the Model Context Protocol over stdio (JSON-RPC 2.0, protocol versions 2024-11-05 to 2025-11-25). It sends instructions that tell the agent when to use it. Code under test runs in a separate process with a time limit. You never run it yourself; your agent starts it.
| Tool | Arguments | Returns |
|---|---|---|
| find_formula | query, limit | ids, titles, formulas, input names |
| get_formula | id | LaTeX, plain form, symbols, conventions, worked example, reference code |
| prove | code or path, function, formula, args, seed | the proof as text, and as structured JSON |
| prove_file | path, seed | every matching function in a file |
| check_model | model, data, objective | the reliability report under check |
What the agent gets back when it proves the tour's kl_divergence through prove: the same proof as the CLI's, as text.
prove({"code": "…", "function": "kl_divergence"})
prove kl_divergence ← code:kl_divergence
formula KL(p‖q) = Σₓ p(x) log( p(x)/q(x) )
chosen the function name matches the formula id kl_divergence
inputs p, q passed by name
FAIL agrees on 0 of 25 inputs worked example ✗
why × 1/ln 2: log base 2 where this formula uses the natural log (bits instead of nats) [convention]
if that convention is the one you want, the code is fine; otherwise it is the fix
example p=[0.5, 0.5] q=[0.9, 0.1] (worked example)
yours 0.736966
reference 0.510826 (also computed independently: 0.510826)
11 ms4 · check a model
excyst check predictions.csv # a CSV: true label, then a probability per class
excyst check model.joblib data.csv -o excyst.toml # a saved scikit-learn model and labelled data
excyst check model.py:predict_proba data.npz --math
excyst init # write excyst.toml: what good enough means
Calibration (accuracy, ECE, MCE, NLL, Brier), accuracy under feature noise, split-conformal coverage, local stability and a reproducibility fingerprint, each against the objective, with what to try when one fails. --math rebuilds every number from its formula with your values; --json run.json saves the report and excyst report run.json opens it again.
The easiest input is a CSV of predictions, which any model can export: one row per example, the true label first, then how sure the model was of each class.
y_true,p_0,p_1,p_2
1,0.10,0.80,0.10
No model to hand? excyst example writes three sample files, overconfident on purpose:
excyst example
wrote three files in this folder:
example_predictions.csv what a model predicted: the true answer, then how sure it was of each option
(the easiest thing to check: open it in a spreadsheet to see the format)
example_model.py the model itself, as Python code
example_data.npz the examples that model was run on, with the true answers
Now test it. Type check and pick "I have a CSV of predictions". (In a normal shell, run:)
excyst check example_predictions.csv
It is overconfident on purpose, so expect one failure, and a plain-English note on how to fix it.excyst check example_predictions.csv
checked 1000 predictions from example_predictions.csv excyst reliability check run 46af4675366e7c07 seed 0 n 1000 calibration accuracy 0.909 · confidence 0.968 · ECE 0.0591 · NLL 0.351 · Brier 0.147 coverage target 0.90 · clean 0.924 · sets 1.00 not checked noise robustness and stability need the model itself. Pass a model and data to include them. FAIL calibration (ECE) 0.0591 <= 0.05 confidence over-states accuracy PASS coverage @ 90% 0.9240 >= 0.880 mean set size 1.00 PASS reproducible identical same inputs, same report objective not met excyst 0.2.1 in plain English • The model is right 91% of the time and, on average, claims 97% confidence. • It is overconfident: it sounds surer than it has earned (gap 0.059, you allowed 0.05). Temperature scaling softens it without changing any answers. type: explain temperature
It exits 1 when the objective is not met, so it can gate CI too. excyst explain lists plain-English topics (calibration, coverage, temperature, …), and excyst demo runs the whole story in ten seconds: an overconfident classifier fails, temperature scaling fixes it, the check passes.
The formula library
excyst find kl divergence # search by name or idea; typos and abbreviations work
excyst formulas kl_divergence # one formula in full, with its worked example
excyst formulas information # a field
excyst latex adam # LaTeX only; copy adam puts it on the clipboard
excyst export entropy adam -o eq.tex # .tex, .md or .json
excyst verify # re-check excyst's own formulas against independent code
excyst find kl divergence
4 formulas for 'kl divergence' kl_divergence Kullback–Leibler divergence information theory KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) kl_mvn KL divergence between multivariate Gaussians information theory KL(N₀‖N₁) = ½[tr(Σ₁⁻¹Σ₀) + Δμᵀ Σ₁⁻¹ Δμ − k + ln(|Σ₁|/|Σ₀|)] kl_gaussians KL divergence between two Gaussians information theory KL = ln(σ₂/σ₁) + (σ₁² + (μ₁−μ₂)²) / (2σ₂²) − ½ vae_kl VAE KL term (diagonal Gaussian) deep learning KL = −½ Σⱼ (1 + log σⱼ² − μⱼ² − σⱼ²) type formulas <id> for the full formula, symbols and a worked example
excyst formulas kl_divergence
Kullback–Leibler divergence kl_divergence · information theory KL(p‖q) = Σₓ p(x) log( p(x)/q(x) ) latex D_{\mathrm{KL}}(p\,\|\,q)=\sum_x p(x)\log\frac{p(x)}{q(x)} note Not symmetric and not a metric. ≥ 0, and 0 only when p = q. see cross_entropy jensen_shannon kl_gaussians example p=[0.5, 0.5], q=[0.9, 0.1] → 0.510826 ✓ checked
Add your own as TOML in ./formulas/ or ~/.excyst/formulas/. The whole library is browsable at /formulas/ and downloadable as formulas.json.
Every command
| Command | What it does | Example |
|---|---|---|
| tour | Proves a file a coding agent wrote; no setup | excyst tour |
| prove | Proves code against a verified formula | excyst prove metrics.py |
| connect | Adds excyst to Claude Code, Cursor, Codex, Windsurf or VS Code | excyst connect --write |
| mcp | The MCP server on stdio; your agent runs it | excyst mcp |
| find | Searches the formulas by name or idea | excyst find p value |
| formulas | Lists the fields, one field, or one formula in full | excyst formulas entropy |
| latex | Prints a formula's LaTeX | excyst latex adam |
| copy | Copies a formula's LaTeX to the clipboard (--text for plain text) | excyst copy adam |
| export | Writes formulas to .tex, .md or .json | excyst export entropy adam -o eq.tex |
| verify | Re-checks every formula against independent code | excyst verify |
| check | Holds a trained model to an objective | excyst check preds.csv |
| demo | A model check that fails, is fixed, and passes | excyst demo |
| example | Writes sample files to try check on | excyst example |
| init | Writes excyst.toml, your limits for check | excyst init |
| report | Opens a saved check result | excyst report run.json |
| explain | What the results mean, in plain English | excyst explain calibration |
| help | The guide, or one command's guide | excyst help prove |
In the screen the same names work without excyst, and so do a few shortcuts: 1 to 4 for the first steps, search or math for find, clear and quit.
In CI
# GitHub Actions
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: pip install https://excyst.com/dl/excyst-0.2.1-py3-none-any.whl
- run: excyst prove src/metrics.py --json excyst.json
Any failed proof exits 1 and fails the job. The seed makes a failure reproducible locally. CI has no terminal, so the output is plain without --plain.
From Python
from excyst import library, prove
e = library.get("kl_divergence")
p = prove.prove(my_kl, e, seed=0)
assert p.passed, prove.render(p)
When something is confusing
It says nothing could be proved
No formula matched the function's name or docstring. Find the id with excyst find <idea>, then name it: excyst prove file.py:my_fn kl_divergence, or put excyst: kl_divergence in the docstring.
It picked the wrong formula
The chosen line says why it picked that one. Pass the id you meant as the second argument.
My function takes its inputs in another order
Pass the formula's input names in your order: --args q,p. excyst formulas <id> lists them.
It failed, but I think my code is right
Look at the tag. convention means your code may be right under another convention (bits instead of nats, instead of ): if that is the one you want, keep it, and say so in a comment. likely bug means no convention explains it.
I wanted text, not the screen
Add --plain, or set EXCYST_PLAIN=1 to make it the default.
How do I get out?
ctrl-c twice, ctrl-d on an empty line, or type quit.
Is a PASS a proof?
No. It means agreement with an independent reference on the worked example, 24 fresh inputs and an overflow probe: strong evidence from testing, not theorem proving. What excyst cannot do.