How to grade open answers with a Claude judge and a rubric

Day 4, 30 minutes · advanced

Goal of this lessonGrade Claude's draft replies with a contains check and a Claude judge that uses one rubric per quality, then check the judge.

Why it matters

Sorting has one right answer. A reply to a customer does not: there are many good ways to say "bring your bike in on Friday". Code cannot tell a friendly reply from a rude one, and you do not want to read every reply yourself.

The answer is to let a second Claude call grade the reply against clear written rules. This is called model-based grading, or an LLM judge. It is powerful and easy to get wrong. Today Tjalling's sorter also drafts replies, and you build a judge for them, with one rubric per quality. Then you check the judge against your own verdicts. At the end you know how far you can trust it.

The words you need today

  • Rubric: the written rule a grader applies, for example "the reply does not promise a price; any amount of money makes it incorrect".
  • LLM judge: a language model used as a grader. Here it is a Claude call that reads the email, the reply and one rubric, and answers correct, incorrect or unknown.
  • Calibration: checking a judge against a person and adjusting it until they agree.

Tjalling's rules for a reply

The reply prompt asks Claude Haiku 5.5 for at most four friendly sentences, no promised prices, discounts or refunds, and the sign-off "Spokeworth Cycles". Then every reply gets four grades:

  • signed: a code check. Does the reply contain "Spokeworth Cycles"? This is a string match, the cheap kind from lesson 3. Use code wherever code can do the job.
  • answers: does it respond to what the customer asked or reported?
  • no_price: does it avoid promising a price, a discount, a refund or free work?
  • tone: is it friendly and calm, also when the customer is angry?

The last three need judgment, so they go to the judge.

How to write a good judge

The Claude docs give three tips for LLM-based grading:

  1. Detailed, clear rubrics. Say exactly what makes an answer pass or fail. A use case may need several rubrics.
  2. Be empirical or specific. Ask for only "correct" or "incorrect", or a score from 1 to 5. Free-form opinions are hard to count.
  3. Encourage reasoning. Use a grader model with thinking on, so it reasons before it gives its verdict. The judge here uses Claude Opus 5.5, as the example on that page does; its thinking is on by default.

Anthropic's engineering post adds two more:

  1. Give the judge a way out. Tell it to answer "unknown" when it does not have enough information, so it does not make something up. The script also returns "unknown" when the judge's answer has no result tags.
  2. One judge per quality. Grade each part of a structured rubric with its own judge call instead of one call that grades everything. That is why judge.py holds three rubrics and the script calls the judge three times per reply.

The pitfalls

The same post lists the weak points of model graders: they are non-deterministic (the same reply can get a different grade on another run), they cost more than code, and they need calibration with human graders to be accurate. The docs page puts it briefly: test that it is reliable first, then scale.

So do not trust the judge's grades yet. Grade the replies yourself first, then compare. Where you disagree, read the rubric again. Often the rubric is the problem: it left room for two readings. Make it stricter and run the judge again. Course advice: once the judge and you agree on almost every case, you can let it grade on its own and check a sample now and then.

Keep in mind what the judge does not check. A rubric about tone will not notice that a reply invents a fact, such as "we have that part in stock" when nobody told Claude so. If that matters to you, it needs its own rubric.

The steps

  1. Create the judge: three rubrics and one function that asks Claude to grade one reply against one rubric.
  2. Create the reply script: it drafts a reply to five test emails, runs the code check and the three judge calls, and saves everything.
  3. Run it and read the replies. The script keeps the grades in a file, so they do not sway you.
  4. Grade the replies yourself, before you open the file with the judge's grades.
  5. Compare your verdicts with the judge's and count how often you agree.

Follow the steps below.

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 judge.py with this code. It holds three rubrics, one per quality, and a function that asks Claude Opus 5.5 to grade one reply against one rubric and return correct, incorrect or unknown.
    import re
    
    import anthropic
    from dotenv import load_dotenv
    
    load_dotenv()
    client = anthropic.Anthropic()
    
    RUBRICS = {
        "answers": "The reply responds to what the customer asked or reported. If it ignores the request or answers something else, it is incorrect.",
        "no_price": "The reply does not promise a price, a discount, a refund or a free repair. Any amount of money or any promise of free work makes it incorrect.",
        "tone": "The reply is friendly and calm, also when the customer is angry. Cold, rude or defensive wording makes it incorrect.",
    }
    
    
    def judge(email, reply, rubric, model="claude-opus-5-5"):
        prompt = f"""Grade this reply from Spokeworth Cycles to a customer email, based on the rubric.
    <rubric>{rubric}</rubric>
    <email>{email}</email>
    <reply>{reply}</reply>
    Output 'correct' or 'incorrect' in <result> tags.
    If the email and reply do not give you enough to decide, output 'unknown' in <result> tags."""
        message = client.messages.create(
            model=model,
            max_tokens=2048,
            messages=[{"role": "user", "content": prompt}],
        )
        text = next((b.text for b in message.content if b.type == "text"), "")
        match = re.search(r"<result>\s*(\w+)\s*</result>", text)
        return match.group(1).lower() if match else "unknown"
  3. Create grade_replies.py with this code. It lets Claude Haiku 5.5 draft a reply to the first five emails, checks with code that each reply is signed, asks the judge about each rubric and saves replies.json.
    import json
    
    from classifier import client
    from judge import RUBRICS, judge
    
    REPLY_PROMPT = """You write short email replies for Spokeworth Cycles, a small bike repair shop.
    Be friendly and calm. Use at most four sentences. Never promise a price, a discount or a refund.
    End with: Spokeworth Cycles
    
    <email>
    {email}
    </email>"""
    
    cases = [json.loads(line) for line in open("test_set.jsonl", encoding="utf-8") if line.strip()]
    
    rows = []
    for case in cases[:5]:
        message = client.messages.create(
            model="claude-haiku-5-5",
            max_tokens=1024,
            messages=[{"role": "user", "content": REPLY_PROMPT.replace("{email}", case["email"])}],
        )
        reply = next((b.text for b in message.content if b.type == "text"), "").strip()
        grades = {"signed": "correct" if "Spokeworth Cycles" in reply else "incorrect"}
        for name, rubric in RUBRICS.items():
            grades[name] = judge(case["email"], reply, rubric)
        rows.append({"id": case["id"], "reply": reply, "grades": grades})
        print(case["id"])
        print(reply, "\n")
    
    with open("replies.json", "w", encoding="utf-8") as f:
        json.dump(rows, f, indent=2)
    print("Grades saved in replies.json. Grade the replies yourself before you open it.")
  4. Run python grade_replies.py. It makes 20 API requests, so it takes a little while. It prints only the replies and saves the grades in replies.json.
  5. Before you open replies.json, judge each printed reply yourself on the three rubrics in judge.py: correct or incorrect. Write your verdicts down.
  6. Now open replies.json and create calibration.txt. Per case, write your three verdicts next to the judge's and count how many of the 15 you agree on. Read the rubric again for every case where you disagree.

Note: The judge uses Claude Opus 5.5, as in the example on the docs page. It thinks before it answers by default, which the page advises for a grader. Opus costs more per token than Haiku, so keep the judged set small until you trust it.

Paid planPay as you go: buy prepaid credits in the Claude Console (minimum 5 US dollars). There is no free tier. Max, Ultra and Team plans include monthly API credits.

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