How to write success criteria for a Claude task

Day 1, 25 minutes · advanced

Goal of this lessonWrite four measurable success criteria for a Claude email sorter and run the sorter once on a made-up customer email.

Why it matters

You changed a word in your prompt and the answers look better. Or do they? Without a test, you only know what you saw in the three answers you happened to read. An eval gives you a number you can compare before and after a change, so you can stop guessing.

This course follows Tjalling, who runs a small made-up bike repair shop, Spokeworth Cycles. Every day he gets emails: repair bookings, questions about parts, complaints and bills. He wants Claude to sort them and to draft replies, and he wants to know that it does that well. Today you set up his project and write down what "well" means, in numbers. At the end you have a working email sorter and a short file of success criteria that the rest of the course tests against.

The words you need today

  • Eval (short for evaluation): a test for an AI system. You give it an input, then check its output with fixed grading rules to measure how well it did. Anthropic's engineering team defines it this way.
  • Success criteria: what good looks like for your task, written so you can measure it.
  • Prompt: the instructions and input you send to Claude.

This course builds on Claude API for Beginners. You need an API key in a .env file and you should be able to run a short Python script that calls the Messages API.

Start with the criteria, not the test

The Claude docs put it in this order: first define your success criteria, then design evaluations to measure performance against them. The page says good criteria are:

  • Specific: not "good performance" but, for example, "accurate sentiment classification".
  • Measurable: a number, or a scale that you apply the same way every time.
  • Achievable: based on earlier experiments, benchmarks or expert knowledge, not on hope.
  • Relevant: tied to what your app is for and what its users need.

The docs also list criteria you may need: task fidelity (does it do the task, also on rare or hard inputs), consistency, relevance and coherence, tone and style, privacy preservation, context utilization, latency (how long an answer takes) and price. Most tasks need several of these at once.

Tjalling's task

The sorter reads one email and answers with JSON (a plain text format for data), for example {"category": "complaint", "urgent": false}. There are five categories: repair_booking, parts_question, complaint, invoice and other. An email is urgent only when the customer cannot ride their bike today.

The script uses Claude Haiku 5.5 (claude-haiku-5-5). The models overview describes it as the model for high-volume, latency-sensitive tasks such as classification. The page on choosing a model suggests starting with a fast, low-cost model like this one, testing it well and moving up only when it falls short. That testing is what this course is about.

Bad and good criteria

A bad criterion: "The sorter should work well." You cannot test that.

A better set, for Tjalling:

  1. Category: at least 11 of every 12 test emails get the right category.
  2. Urgent: every email from a customer who cannot ride today is marked urgent. No misses, because a missed urgent email means an angry customer.
  3. Format: every answer is valid JSON with a known category, so the next program can read it.
  4. Speed and price: on average under 5 seconds and under 0.1 US cent per email.

These numbers are a starting point. After your first score in lesson 3, you can make them stricter or more realistic. Write them down anyway: a target you set before you see the results is harder to bend.

Why the answers can differ

Run the same email twice and the wording, or now and then even the answer, can change. You cannot switch that off: the current Claude models (Haiku 5.5, Sonnet 5.5 and Opus 5.5) reject non-default temperature, top_p and top_k settings, which older tutorials use to make answers more predictable. That is one more reason to measure over many emails instead of judging one answer.

The steps

  1. Set up a project folder with a virtual environment, the anthropic SDK and your .env file.
  2. Create the sorter: a file with the prompt and one function that calls Claude.
  3. Run it once on a made-up email and look at the answer, the token counts and the time.
  4. Write your success criteria in a text file.

Follow the steps below.

Deeper dive

Today's actions

Ticks are not saved without an account

Do it in Claude API

Claude API

  1. Make a new folder spokeworth-evals. Open a terminal in it and create a virtual environment with python -m venv .venv.
  2. 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. Then install the SDK and the .env loader.
    pip install anthropic python-dotenv
  3. Copy the .env file with your API key from your project of Claude API for Beginners into this folder. Never paste the key into a script or a chat.
  4. Create classifier.py with this code. It holds the prompt and one function that sends an email to Claude Haiku 5.5 and returns the answer, the token usage and the seconds it took.
    import time
    
    import anthropic
    from dotenv import load_dotenv
    
    load_dotenv()
    client = anthropic.Anthropic()
    
    CATEGORIES = ["repair_booking", "parts_question", "complaint", "invoice", "other"]
    
    PROMPT = """You sort emails for Spokeworth Cycles, a small bike repair shop.
    Pick exactly one category: repair_booking, parts_question, complaint, invoice or other.
    Set urgent to true only if the customer cannot ride their bike today.
    Answer with JSON only, like this: {"category": "complaint", "urgent": false}
    
    <email>
    {email}
    </email>"""
    
    
    def classify(email, model="claude-haiku-5-5", prompt=PROMPT):
        start = time.perf_counter()
        message = client.messages.create(
            model=model,
            max_tokens=1024,
            messages=[{"role": "user", "content": prompt.replace("{email}", email)}],
        )
        seconds = time.perf_counter() - start
        text = next((b.text for b in message.content if b.type == "text"), "")
        return text.strip(), message.usage, seconds
  5. Create try_one.py with this code and run python try_one.py. You see a line of JSON, two token counts and the seconds.
    from classifier import classify
    
    email = "Hi, my back tyre went flat on the way to work and I have no other bike. Can you fix it today?"
    output, usage, seconds = classify(email)
    
    print(output)
    print("input tokens:", usage.input_tokens)
    print("output tokens:", usage.output_tokens)
    print("seconds:", round(seconds, 1))
  6. Create criteria.txt and paste this example. Change the numbers so they fit your own task, then save it. You check against it from lesson 3 on.
    Task: sort Spokeworth Cycles emails into one of five categories and flag urgent ones.
    1. Category: at least 11 of every 12 test emails get the right category.
    2. Urgent: every email from a customer who cannot ride today is marked urgent. No misses.
    3. Format: every answer is valid JSON with a known category.
    4. Speed and price: on average under 5 seconds and under 0.1 US cent per email.

Note: Every run of every script in this course is a paid API request. With Claude Haiku 5.5 and a dozen short emails a run costs very little, but it is not free. If you get an error about temperature, you copied code from an older tutorial: the current Claude models reject non-default temperature, top_p and top_k.

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