How to build a small test set for a Claude eval

Day 2, 25 minutes · advanced

Goal of this lessonBuild a test set of twelve labelled emails with edge cases and check that every case has a valid right answer.

Why it matters

An eval is only as good as the examples it runs on. If you test the sorter only on easy emails, it will score well and still fail on the strange one that arrives on Monday morning. A small, honest test set catches that before a customer does.

Today you build Tjalling's test set: twelve short emails, each with the answer the sorter should give, including a few awkward ones. You do not need hundreds to start. At the end you have a file of test cases that a small script has checked, ready to run tomorrow.

The words you need today

  • Test case: one example in your eval. Here it is one email plus the answer you expect.
  • Ground truth: the right answer for a test case, decided by a person in advance. The docs also call it the golden answer. Here it is the category and true or false for urgent.
  • Edge case: an input that is rare, odd or hard, where a system is most likely to go wrong.
  • Test set: all your test cases together.

What the docs advise

The page on building evaluations gives three design principles:

  1. Be task-specific: the test set should look like the real mix of inputs, and it should include edge cases. The page names examples: irrelevant or nonexistent input, very long input, poor or harmful user input, and ambiguous cases where even people would disagree.
  2. Automate when possible: shape the task so a script can grade it. A fixed list of categories can be checked with code; lesson 3 does that.
  3. Prioritize volume over quality: more questions with slightly lower-signal automated grading beat a few questions graded by hand.

Anthropic's engineering post on evals adds practical advice. Start early: 20 to 50 simple tasks drawn from real failures is a good start. Write tasks so that two experts would reach the same pass or fail verdict on their own. And test both sides: cases where a behaviour should happen and cases where it should not. For Tjalling that means urgent emails and emails that only sound urgent.

Tjalling's twelve emails

The test set is a JSONL file: one JSON object per line, so each line is one test case. Every case has an id, the email, the ground truth (category and urgent) and, for edge cases, an edge note that says why it is hard.

The twelve cases cover all five categories, two urgent emails and four edge cases:

  • e08, "you charged me twice": it sounds like a complaint, but it is about a bill. Tjalling decided bills go to invoice.
  • e10, "Hello?": almost no text.
  • e11, a service booking plus a question about child seats: two requests in one email. Tjalling's rule is that the first request decides.
  • e12, an advertiser: not a customer at all.

Look at e08 and e11 again. The right answer depends on a rule Tjalling chose. Without that rule two people could label them differently, and then your score measures the label, not the sorter. When you hit a case like that, write the rule down. Lesson 5 shows what happens when you also give the rule to Claude.

Where test cases come from

  • Your own data: real emails are the best source, because they show the real mix. Use them only if they hold no personal data you may not process. Remove names, addresses and order numbers, or write a made-up email that looks like the real one. The emails in this course are made up.
  • Mistakes you have seen: every time the sorter gets something wrong, that email is a new test case. Lesson 6 makes this a habit.
  • Claude: the docs suggest asking Claude to generate more test cases from a small baseline set. Check every ground truth yourself before you add a case.

The steps

  1. Create the test set file and paste the twelve cases.
  2. Create a check script that reads the file and stops when a case is broken: a duplicate id, an unknown category, or urgent that is not true or false.
  3. Run the check and read the counts per category and the list of edge cases.
  4. Add one edge case of your own and run the check again.

Follow the steps below.

Common mistakes

  • One email over two lines. JSONL needs one case per line. If the check script fails to read the file, look for a line break inside an email.
  • Fixing the ground truth to match Claude. Decide the right answer before you run the eval, not after.
  • Only easy cases. If every case is obvious, a perfect score tells you little.

Today's actions

Ticks are not saved without an account

Do it in Claude API

Claude API

  1. Open a terminal in your spokeworth-evals folder and turn on the virtual environment: source .venv/bin/activate on macOS or Linux, .venv\Scripts\Activate.ps1 on Windows.
  2. Create a file test_set.jsonl and paste the first six test cases. Each line is one test case: an id, the email and the right answer.
    {"id": "e01", "email": "Hi, my back tyre went flat on the way to work and I have no other bike. Can you fix it today?", "category": "repair_booking", "urgent": true}
    {"id": "e02", "email": "Could I book my e-bike in for its yearly service some time next week?", "category": "repair_booking", "urgent": false}
    {"id": "e03", "email": "Do you have 28 inch inner tubes in stock?", "category": "parts_question", "urgent": false}
    {"id": "e04", "email": "Which brake pads fit a city bike with rim brakes?", "category": "parts_question", "urgent": false}
    {"id": "e05", "email": "I picked up my bike yesterday and the gears still slip. Not happy.", "category": "complaint", "urgent": false}
    {"id": "e06", "email": "You replaced my chain on Monday and today it snapped. I cannot ride to school now.", "category": "complaint", "urgent": true}
  3. Paste the next six lines under the first six, in the same file, and save it. Make sure every case sits on its own line.
    {"id": "e07", "email": "Can you send me the invoice for last week's repair again? I need it for work.", "category": "invoice", "urgent": false}
    {"id": "e08", "email": "I think you charged me twice for the same service. Please check.", "category": "invoice", "urgent": false, "edge": "sounds like a complaint, but it is about a bill"}
    {"id": "e09", "email": "Are you open on Easter Monday?", "category": "other", "urgent": false}
    {"id": "e10", "email": "Hello?", "category": "other", "urgent": false, "edge": "almost no text"}
    {"id": "e11", "email": "Can you service my bike on Friday? Also, do you sell child seats?", "category": "repair_booking", "urgent": false, "edge": "two requests, the first one decides"}
    {"id": "e12", "email": "Please forward this to your marketing team: we sell cheap online ads.", "category": "other", "urgent": false, "edge": "not a customer at all"}
  4. Create check_set.py with this code. It reads the file and stops with a message when an id is used twice, a category is unknown or urgent is not true or false.
    import json
    from collections import Counter
    
    from classifier import CATEGORIES
    
    cases = [json.loads(line) for line in open("test_set.jsonl", encoding="utf-8") if line.strip()]
    
    ids = [case["id"] for case in cases]
    assert len(ids) == len(set(ids)), "Two cases have the same id"
    for case in cases:
        assert case["category"] in CATEGORIES, f"{case['id']}: unknown category"
        assert isinstance(case["urgent"], bool), f"{case['id']}: urgent must be true or false"
    
    print("cases:", len(cases))
    print("per category:", dict(Counter(case["category"] for case in cases)))
    print("urgent:", sum(case["urgent"] for case in cases), "of", len(cases))
    print("edge cases:", [case["id"] for case in cases if "edge" in case])
  5. Run python check_set.py. You see 12 cases, the count per category, 2 urgent cases and the ids of the four edge cases.
  6. Add one case of your own on a new line, with the id e20, a short made-up email, the right category, true or false for urgent and an edge note that says why it is hard. Run python check_set.py again.

Note: Use emails from your own work only if they hold no personal data you may not process. Remove names, addresses and order numbers, or make up an email that looks like the real one. To get more cases quickly, you can ask Claude to draft new ones from these twelve; check every right answer yourself before you add it.

Checked on 4 December 2026 · Source: Claude API docs: Define success criteria and build evaluations (opens in a new tab)

Create a free account to save your progress. Sign in or sign up