Let's talk.

Whether it's a project, a role, or you just want to say hi, my inbox is open.

kadhar.mfn@gmail.com
AboutExperienceProjectsWritingResearchFree guidesFree ebookToolsGames

© 2026 Kadharmoideen Fadurudeen. Made with care.

kadhar.
AboutExperienceProjectsWritingResearchFree guides
Tools
Say hello
Back to Blog
AI Engineering
December 4, 2026
12 min read

Evals for LLM Features: How to Know Your Prompt Change Didn't Break Anything

Build a test set from real data, pick the right grader for each check, compare runs case by case instead of by average, run evals in CI and keep watching in production. With an interactive eval diff where the score goes up and the feature gets worse.

Changing a prompt is the easiest code change you'll ever make, and one of the riskiest.

You add one sentence to fix a complaint. You try it on three examples, it looks better, you ship. A week later someone notices that a completely different kind of request has been quietly getting worse since that change. Nothing errored. No test failed. There were no tests.

That “try a few examples and eyeball it” approach is usually called a vibe check, and every team starts there. Evals are what you replace it with: a repeatable way to answer “is this change better, and did it break anything?” This article goes deeper than the evals section in Shipping AI Features to Production, with the practical details of building one and running it on every change.

What an eval actually is

Three parts, and none of them need a special framework:

A test set

Realistic inputs, each with what a good answer must or must not contain.

Graders

Code, a model or a person that decides pass or fail for each criterion.

A comparison

This run against the last good run, case by case, not just the average.

It's close to a unit test suite, with one big difference: outputs vary, and “correct” is often a judgement. So instead of asserting exact text, you check properties of the answer.

Step 1: build the test set from real data

The best test cases come from what users actually send, not from what you imagine they send. Good sources:

  • Production logs. A random sample, so your set looks like real traffic. Remove personal data first.
  • Complaints and bug reports. Every failure someone took the time to report is a test case.
  • The awkward edges. Empty input, very long input, other languages, contradictory instructions.
  • Cases where doing nothing is correct. A meeting with no action items should produce none, not invented ones.

Twenty to fifty cases is enough to start, as long as they're varied. For each case, write down the criteria rather than a perfect answer: “lists these three action items”, “doesn't name an owner who isn't in the notes”. Then make a habit of it: every new bug becomes a new case before it's fixed.

Step 2: choose the right grader for each check

Code checks: use them wherever you can

Is it valid JSON? Does it match the schema? Is it under the length limit? Does the category equal the expected one? Does it mention all three expected items? These are fast, free, never disagree with themselves, and catch a surprising share of real problems. If a check can be written as code, write it as code.

LLM-as-judge: for what code can't see

Tone, faithfulness to the source, whether an answer actually addresses the question. Here you ask a model to grade. It works well if you keep it narrow:

  • One criterion per question. “Does the summary name any owner not mentioned in the notes? yes/no” beats “rate this summary 1 to 10”.
  • Yes or no, not scales. Judges are inconsistent on 1 to 10 scores. Binary questions are far more stable.
  • Ask for the reason first. Have the judge quote the evidence, then give its verdict. It's more accurate and much easier to debug.
  • Calibrate against people. Label 30 or so outputs yourself and check the judge agrees. If it doesn't, fix the rubric before trusting it.

Watch for known judge biases: favouring longer answers, favouring whichever answer is shown first when comparing two, and rating text in its own style more kindly.

Human review: the ground truth, in small doses

People are slow and expensive, so use them where they matter most: labelling the calibration set, reviewing a sample of each release, and deciding the hard cases the judge flags as unsure.

Step 3: compare case by case, not by average

This is the part most teams skip, and it's the most important. An overall score hides trade-offs. Here's a feature that turns meeting notes into a summary and a list of action items, with two candidate prompt changes.

Compare the live prompt with

Added one line asking for shorter summaries.

Overall score

88% → 94%

Checks fixed

4

Checks broken

2

Test caseValid JSONcode checkFinds every action itemcode checkNo invented ownersLLM judgeUnder 120 wordscode check
Weekly stand-up, five action items✓broke✓✓
Customer call with no action items✓✓✓✓
Planning meeting, owner never named✓✓fixed✓
Long design review, nine action items✓fixed✓fixed
Dates written two different ways✓✓✓✓
Notes in English and Spanish✓broke✓✓
Item cancelled later in the meeting✓fixed✓✓
One-line notes✓✓✓✓

Blocked. The score went up, but 2 critical checks that passed before now fail.

Illustrative results for a feature that turns meeting notes into a summary and action items.

Asking for shorter summaries raises the score from 88% to 94%, and it would look like a clear win on a dashboard. But it now drops action items in two meetings that worked before, and missing an action item is exactly the failure users care about. The worked-examples change fixes three things and breaks nothing.

So mark which checks are critical, and treat any case that went from pass to fail on a critical check as a blocker, whatever the average says.

Step 4: run it on every change

An eval you run by hand once a month won't catch much. Wire it into CI like any other test. The runner itself is small:

type Case = { id: string; input: string; expected: { actionItems: string[] } }
type Check = { name: string; critical: boolean; grade: (output: string, c: Case) => Promise<boolean> }

export async function runEval(prompt: string, cases: Case[], checks: Check[]) {
  const results: Record<string, Record<string, boolean>> = {}
  for (const c of cases) {
    const output = await callModel(prompt, c.input)
    results[c.id] = {}
    for (const check of checks) results[c.id][check.name] = await check.grade(output, c)
  }
  return results
}

// In CI: compare with the saved baseline and fail on critical regressions.
const broken = diff(baseline, candidate).filter((r) => r.wasPassing && !r.isPassing && r.critical)
if (broken.length) {
  console.error("Critical regressions:", broken)
  process.exit(1)
}
  • Trigger on the right files. Prompts, model names, tool definitions, retrieval settings. Keep prompts in version control so this works.
  • Two tiers. A fast core set on every pull request, the full set nightly or before a release.
  • Save the baseline. Store the last good run's results so every new run is a diff, not a fresh number.
  • Run flaky cases more than once. If it passes three times out of five, your users will see the other two.

Evals also make model upgrades boring, in a good way. When a new model comes out, run the set against it and you know in minutes whether it's better for your feature. That's a much better basis for the decision than benchmarks, as covered in how to choose the right AI model.

Step 5: keep watching in production

Your test set will never cover everything users do. In production, the same graders keep working:

  • Run code checks on every response. They're free. Log failures and alert on spikes.
  • Judge a sample. Grade a small percentage of live traffic with the LLM judge and track the pass rate over time.
  • Use behaviour as a signal. Thumbs down, users rewriting the output, retrying the same question. Each one points at a case to review.
  • Close the loop. Interesting failures go back into the test set, so the next change is tested against them.

For features built on retrieval, evaluate the search step separately too. The RAG guide covers measuring whether the right document is found, which is where most wrong answers start.

Mistakes that make evals useless

Only happy paths

If every case is easy, everything passes and the eval tells you nothing.

Grading exact text

Correct answers phrased differently fail. Check properties instead.

One vague judge question

“Is this good?” produces noise. Split it into specific yes/no checks.

Trusting the average

A higher score can hide broken cases. Always look at the diff.

A set that never grows

Production keeps finding new failures. The set should keep growing with them.

Never checking the judge

An uncalibrated judge is a random number generator with good grammar.

Frequently Asked Questions

What is an LLM eval?

A set of realistic inputs, a way to grade each output, and a score. You run it whenever you change a prompt, model or retrieval setup, so you can see what got better and what got worse before anything reaches users.

How many test cases do I need?

Fewer than you think to start. Twenty to fifty real, varied cases catch most obvious regressions. Grow the set over time by adding every bug and every surprising production failure as a new case.

Is LLM-as-a-judge reliable?

Reliable enough when the question is narrow and checked against people. Ask one yes-or-no question per criterion, give the judge a clear rubric, and compare its verdicts with human labels on a sample before trusting it. Judges are known to favour longer answers and answers in a particular position.

Should evals run in CI?

Yes, for any change to prompts, models, tools or retrieval. Run a fast core set on every pull request and the full set nightly or before release, and block merges on regressions in the checks that matter most.

How do I handle non-deterministic outputs in evals?

Grade criteria instead of exact text, and run important cases more than once. If a case passes three times out of five, that's a flaky behaviour your users will see too, so treat it as a failure to fix.

The short version

Collect 20 to 50 real cases, including the awkward ones. Grade with code wherever you can, use narrow yes/no LLM judges for the rest, and check the judge against your own labels. Compare every run with the last good one case by case, block on critical regressions, and run it in CI on every prompt or model change. Then keep feeding production failures back into the set. It's not glamorous, and it's the difference between hoping a change is better and knowing.

PreviousRAG from Scratch: Chunking, Embeddings, Retrieval and Why It FailsNextStructured Output and Tool Calling: Getting Reliable JSON from LLMs

Continue Reading

Explore more articles on software engineering and technology

AI Engineering

Making AI Features Feel Fast: Streaming, Latency and UX

Time to first token vs output speed, streaming from the model to the browser in Next.js, the UX details that make streaming feel polished, and the changes that genuinely cut latency. With an interactive race between waiting and streaming.

11 min read
Read
AI Engineering

Prompt Injection and AI Security: A Practical Guide for App Developers

Why LLMs can't reliably tell instructions from data, how indirect injection hides in emails and web pages, the lethal trifecta, and the layered defences that hold: fewer capabilities, real confirmation, output control, quarantine and testing. With an interactive attack demo.

13 min read
Read
AI Engineering

Structured Output and Tool Calling: Getting Reliable JSON from LLMs

Prompt-only vs JSON mode vs structured outputs, how Claude, OpenAI and Gemini do it, schema design that helps the model, the validation you still need, and how tool calling works under the hood. With an interactive demo of what each layer catches.

12 min read
Read