Skip to main content

A Scorecard per Category: Precision, Recall and What Got Worse

Why This Matters

One accuracy number hides the failures that matter. A prompt that gets better at “flaky” and worse at “product bug” can raise the average while making TestPilot more dangerous. You need a score per category, and a list of exactly what changed.

Build npm run eval

scripts/eval.ts runs every golden case, compares the verdict with the label and writes a table:

category      cases  precision  recall
product_bug       8      0.88     0.88
test_bug          6      1.00     0.83
flaky             6      0.71     0.83
environment       5      1.00     1.00
unknown           5      0.80     0.80
overall          30   accuracy 0.87

Save each run as JSON in eval-results/ with the date and the git commit, so you can compare runs later.

Precision and recall, in tester language

For the category product_bug:

  • Precision: of all failures TestPilot called a product bug, how many really were? Low precision means false alarms: developers chasing bugs that are not there.
  • Recall: of all failures that really were product bugs, how many did TestPilot catch? Low recall means missed bugs: real defects labelled as something harmless.

Which one matters more depends on the category. For product_bug, missed bugs are dangerous and false alarms erode trust. For flaky, false positives are the dangerous ones, because they hide real bugs.

The confusion table

Precision and recall tell you how bad; the confusion table tells you what goes wrong:

expected \ got   product  test  flaky  env  unknown
product_bug          7     0     1      0      0
flaky                0     0     5      1      0
...

Here one product bug was called flaky. That single cell is the most important number on the page.

Diff two runs

Before you accept any prompt change, list every case that changed:

golden-014  product_bug → flaky       (worse)
golden-021  unknown → environment     (better)

An overall score that goes up by 2% with one product bug turned into flaky is not an improvement. Review the diff, not just the total.

What the first real run found

The first run of solution/lesson-18-eval against Claude, 20 cases with three runs each:

npm run eval, first run: accuracy 0.95, product_bug recall 0.75; golden-008 not triaged twice because the JSON was cut off, and called test_bug once

One case, golden-008, failed in two different ways, and both were real problems:

  1. Two of three calls were “not triaged”: Unterminated string in JSON. The verdict hit max_tokens halfway through the JSON, so it could not be parsed. The eval recorded it as error instead of crashing, which is why you build it that way. Fix: a higher max_tokens for triage.
  2. The third call said test_bug, and it had a point. The test was called “rounds the VAT per line”, and the commit introduced per-line rounding. The case contradicted its own label. Fix: the golden case, not the prompt. The test now names the documented rule (round once on the total), and the evidence shows the one-cent difference.

After both fixes, the second run:

npm run eval, second run: accuracy 1.00 and the diff golden-008 error → product_bug (better)

Read the bottom line first: one case changed, and it changed for the better. That diff, not the 1.00, is what you review.

Do not celebrate the 1.00 either. Twenty cases is a small set, and they were written alongside the prompt, which is exactly the tuning-on-your-own-test trap from lesson 17. A perfect score means the set is too easy to tell prompts apart. Add the failures TestPilot gets wrong in real runs, and keep a holdout set for reporting.

Exercise

Implement npm run eval with the scorecard, the confusion table and a diff against the previous run. Score the current prompt and write down its weakest category. That is what lesson 19 will fix. Compare with solution/lesson-18-eval, and use that branch as your starting point for lessons 19–22.