agentleFS
stve099stve099/Grant-Data-Quality-Reporting-Assistant/.claude/skills/add-metric/SKILL.md

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.

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
  1. Distinctive:

    Every number this project shows is computed in Python and covered by a test.

    line 8
  2. Very specific:

    Small denominators: If the metric is a rate, respect SMALL_SAMPLE_N.

    line 34
  3. Distinctive:

    Do not let the model derive it: If you find yourself writing a prompt instruction like "add these two categories together", stop and add …

    line 38
  4. Distinctive:

    If the answer says the figure is unavailable, the metric is computed but not registered — go back to step 2.

    line 56

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Compute it in analytics/metrics.py, inside compute_analytics. Add the field to AnalyticsResult with a type and a comment saying what it means when it is None. A rate with a zero denominator is None, never 0.0.
  2. 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.
  3. Expose the breakdown through agents/tools.py only if the analyst needs detail the lookup cannot carry (a per-category mapping, say). Tool results must stay aggregated: no client-level rows, ever.
  4. Test the expected value in tests/test_analytics.py against 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_demographics exists 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.csv

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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.