add-metric
Skill0 starsChanged 4 months agoMITView on GitHub
Add a deterministic metric to the analytics layer and wire it everywhere it belongs — metric_lookup, the agent tools, the fact sheet, and the run history. Use when the user wants a new calculated figure, measure input, or headline number.
In this repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- add-audit-ruleSkill
- new-grant-profileSkill
- release-checkSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Every number this project shows is computed in Python and covered by a test.
- Very specific: line 34
Small denominators: If the metric is a rate, respect SMALL_SAMPLE_N.
- Distinctive: line 38
Do not let the model derive it: If you find yourself writing a prompt instruction like "add these two categories together", stop and add …
- Distinctive: line 56
If the answer says the figure is unavailable, the metric is computed but not registered — go back to step 2.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Adding a metric
Every number this project shows is computed in Python and covered by a test. A metric added in the wrong place either never reaches the analyst, or — worse — gets derived by the model instead, which the grounding contract forbids.
Where it goes
- Compute it in
analytics/metrics.py, insidecompute_analytics. Add the field toAnalyticsResultwith a type and a comment saying what it means when it isNone. A rate with a zero denominator isNone, never0.0. - Register it in
AnalyticsResult.metric_lookup(). This one call feeds three consumers at once — the AI fact sheet,get_metric/list_metrics, and the run history — so registering is what makes a metric real. A metric that exists on the model but not in the lookup is invisible to the analyst and to trending. - Expose the breakdown through
agents/tools.pyonly if the analyst needs detail the lookup cannot carry (a per-category mapping, say). Tool results must stay aggregated: no client-level rows, ever. - Test the expected value in
tests/test_analytics.pyagainst the controlled fixture, not the generated sample. Assert the number, not that it is non-null.
Guardrails
- Small denominators. If the metric is a rate, respect
SMALL_SAMPLE_N; a rate over 4 exits is noise and must be flagged as such downstream. - Suppression before publication. Anything disaggregated by demographic needs a suppression rule before it reaches a report.
- Do not let the model derive it. If you find yourself writing a prompt
instruction like "add these two categories together", stop and add the metric
instead.
unreported_demographicsexists precisely because the model was summing category counts and calling the result data.
Verify
uv run pytest && uv run ruff check . && uv run ruff format --check . && uv run mypy
uv run grant-assistant analyze sample_data/housing_program_flawed.csvThen confirm the analyst can actually reach it:
uv run grant-assistant ask sample_data/housing_program_flawed.csv "What is <metric>?"If the answer says the figure is unavailable, the metric is computed but not registered — go back to step 2.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

