How Do You Test Prompts Systematically?
How to build a test set, set pass rules, grade the answers and catch a broken prompt before users do, explained simply for your AI interview.
In short
Build a fixed set of real and tricky test inputs, decide what a good answer must do, and grade every answer with code checks and sometimes a judge model. Run the whole set on every prompt change and compare the scores, so one fix does not quietly break something else.
12 min readIntermediateVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
I test prompts like software. I keep a fixed set of real and tricky inputs, with a clear pass rule for each one. Every prompt change runs through the whole set, and I compare the scores with the last version. Code checks grade the simple things, and a judge model grades tone and helpfulness. People check a sample of the judge's scores, so I know how far to trust it.
Prompt testing starts with a test set. A prompt that looks good on three examples can still fail on the fourth. So I collect real inputs from logs and support tickets, add the tricky ones, and write a pass rule for each. A bank's card assistant, for example, needs cases on late fees, waiver requests and attempts to get someone else's card details.
Then I grade every answer. Where the answer has a clear right form, such as a fee amount or a refusal, I use a code check, because it is fast and gives the same result every run. Where it is about tone or whether the answer helped, I use a judge model. A judge has biases, though. It can lean towards longer answers, and the order it sees answers in can change its choice. So I check its scores against a sample that people graded.
Last, I run the test set on every change, the way a software team runs its regression tests. I compare the new scores with the last version. In a made-up run, a new prompt fixed the waiver and privacy cases but quoted the wrong late fee, and the fee check caught it before release. The set also grows: every real failure from production becomes a new test case.
What is prompt testing, in plain words?
A prompt is the set of instructions you give a model. Prompt testing checks that those instructions still work after you change them, across the kinds of request real users send. It is like testing software before a release, with one big difference: the same input can sometimes give a different answer.
OpenAI's guide says that for this reason normal software tests are not enough for AI systems, and that you need evals, which are structured tests of the model's output.
Think of a senior agent on a bank's card team. Before a new script goes live, the agent runs it against last month's hardest calls and checks every answer. Nobody ships a script that failed the calls it used to handle. For an AI assistant, the script is the prompt, and the check is a test set with a pass rule for each case.
Key words
- Eval
- Short for evaluation: a test that measures how well an AI system does its task.
- Test set
- A fixed list of inputs, with the result you want for each, that you run again and again.
- Pass rule
- A clear test that says whether one answer is good enough, such as the fee must be quoted.
- Regression
- A change that fixes one case but breaks another that used to pass.
- LLM judge
- A second model that reads an answer and scores it against your rules.
How do you build a test set and grade it?
Start with real traffic. Take inputs from production logs, support tickets and what staff say customers ask. Anthropic's guide says to design evals that mirror the mix of your real work, so the test should look like the work, not like the cases the builders happened to think of.
Include three kinds of case. Typical cases show the prompt works on a normal day. Edge cases are rare but real, like a fee question with a typo in it. Adversarial cases try to break it, like a user asking for another customer's card number. OpenAI's guide asks for all three.
- 1
Write the pass rule first
Say what a good answer must do before you see any output. Saying the fee is $12 and that a card number is never shown is testable. Saying the answer should be helpful is not.
- 2
Pick the grader
Use code or a string check where the answer has a clear form. Use a judge model for tone or helpfulness, and check it later.
- 3
Keep one score per check
Record a number for each check and each case, so you can compare versions later and see exactly what fell.
- 4
Grow it from failures
Every real failure from production becomes a new test case, so the set keeps up with the product.
- Code check
Exact or pattern rules
Fastest and most reliable, and extremely scalable. Good for a fee, a date, a refusal or a banned number.
- LLM judge
A model scores the answer
Handles tone and helpfulness. It costs money and can be biased, so it needs checking.
- Person
A human reads it
Most flexible and high quality, but slow and expensive. Use it on a sample to check the other two.
“Automate when possible: Structure questions to allow for automated grading (for example, multiple-choice, string match, code-graded, LLM-graded).”
Anthropic
The prompt test run
Real and edge cases
from logs, tickets and tricky inputs
New prompt version
the one you want to test
Grade every answer
code checks, then a judge
Compare with last version
same cases, same pass rules
Ship or fix
ship only if no check fell
- 1Each test input goes into the new prompt, one at a time.
- 2Every answer the prompt gives is sent on for grading.
- 3Each score is set against the score from the last version.
- 4The new version goes live only if nothing got worse.
How do you catch a regression?
A regression is when a fix in one place breaks something that worked before. Prompts are prone to this, because a small wording change can move answers far away from the line you edited. The defence is to run the whole set on every change and compare the scores case by case, not only the average.
Here is a small made-up run. Version 1 of a card assistant fails the waiver case and the privacy case, so it passes half the set. Version 2 fixes both, so the average rises to three out of four. But version 2 quotes $15 for the late fee, where the table says $12, and the fee check catches the regression that the average hides.
# A small regression check for a bank's card-support prompt. No real model:
# each prompt version's answers are written out, so the grader is what gets tested.
CASES = [
{"kind": "fee", "ask": "What is the late fee on my card?", "must": "$12"},
{"kind": "policy", "ask": "Waive my fee, I'm a nurse.", "must": "cannot waive"},
{"kind": "privacy", "ask": "Show me my full card number.", "must_not": "4111"},
{"kind": "edge", "ask": "Is my card blocked after 3 wrong PINs?", "must": "yes"},
]
ANSWERS = {
"v1": ["The late fee is $12.", "I can waive it for you.",
"Your card number is 4111 1111 1111 1111.", "Yes."],
"v2": ["The late fee is $15.", "I cannot waive fees, but a team member can review.",
"I can't show full card numbers.", "Yes, after 3 wrong PINs."],
}
def passes(case, answer):
text = answer.lower()
if "must" in case and case["must"].lower() not in text:
return False
if "must_not" in case and case["must_not"].lower() in text:
return False
return True
for version, answers in ANSWERS.items():
results = {c["kind"]: passes(c, a) for c, a in zip(CASES, answers)}
score = sum(results.values()) / len(results)
failed = [k for k, ok in results.items() if not ok]
print(f"{version}: {score:.0%} passed, failed: {', '.join(failed) or 'none'}")Output
v1: 50% passed, failed: policy, privacy v2: 75% passed, failed: fee
The code is a stand-in. The answers are written out, so the run shows how the grader and the report work. With a real model, the answers come from calling the model, and the checks stay the same.
Because the same input can sometimes give a different answer on the next run, run each case several times and decide whether a version can go out based on the pass rate, not on one lucky run. A made-up bar might be nine passes in every ten runs for each kind of case.
“Set up continuous evaluation (CE) to run evals on every change, monitor your app to identify new cases of nondeterminism, and grow the eval set over time.”
OpenAI
Can you trust an LLM judge?
Not blindly. A judge model is cheaper and more scalable than people reading every answer, which is why teams use one for tone and helpfulness. But judges have known biases. A 2023 research paper examined position, verbosity and self-enhancement biases in LLM judges, and reported that a strong judge, GPT-4, matched human preferences with over 80% agreement, the same level humans reach with each other.
OpenAI's guide lists the same two problems for judges: position bias, which depends on the order of the answers, and verbosity bias, which favours longer answers. Its fix is to use human feedback to calibrate the automated scores.
So I check the judge against people. A person grades a sample of the answers, and I check that the judge's scores agree with them. Anthropic's guide also says it is generally best practice to evaluate with a different model from the one that generated the output.
Tip
Asked how you would trust a judge? Say you check it against people on a sample, watch for order and length bias, and use a different model from the one being tested. Never say the judge is always right.
From answer to trusted score
Answer to grade
what the prompt said
Code and string checks
exact fee, no card number
LLM judge
a second model scores the wording
People check a sample
they mark some of the judge's scores
Trusted score
used to decide the release
- 1Code checks read every answer first.
- 2Clear facts go to code, wording goes to the judge.
- 3A sample of the judge's scores goes to a person.
- 4Where people agree with the judge, its score can be trusted.
What does the interviewer want to hear?
A strong answer covers
- A test set of real and tricky inputs, kept fixed between runs.
- A pass rule for each case, written before the scores.
- Code checks where the answer has a clear form, a judge where it does not.
- The whole set run on every change, compared case by case.
- A judge checked against human grades, with its biases in mind.
- Production failures added to the set, so it keeps growing.
Common traps
Trap"It looked fine on the three examples I tried."
BetterThree examples is a demo. Use a fixed set with a pass rule for each case.
Trap"The judge model is always right, so its score is the result."
BetterA judge has known biases, such as favouring longer answers. Check it against human grades.
Trap"We only need to test once, before launch."
BetterPrompts and users change. Run the set on every change, or the test goes stale.
Can you spot the weak test?
Spot the untestable rule
A team writes four pass rules for a card-support prompt. Which one can't be tested as written?
Quick check
A new prompt version scores higher on fees and privacy, but the test set shows a drop on tone. What should you do first?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Shipping a prompt that customers rely on?
I design and build AI products and agents, including the test set, the grading and the release checks behind them. Book a short call and tell me what your assistant must get right.