Back to Writing

Evals

LLM Evals with Anthropic: Gate Deploys with Claude as Grader

Build an eval test set from real traffic, use Claude as a calibrated grader, and run the suite in GitHub Actions so score regressions block the deploy.

9 min read

Key takeaways

  • Build your eval test set from 50-200 real production traces, weighted toward cases where a human edited the output or the user retried.
  • Use Claude as grader with a JSON-output rubric prompt, and calibrate it against 50-100 human-labeled outputs before trusting its scores.
  • Run evals on every pull request in GitHub Actions, failing the build only when a case drops below a per-case floor or the suite mean falls past a tolerance band.
  • Measure your noise floor by running the same suite twice on an unchanged build, and only treat score changes beyond that band as real.
  • Refresh the test set monthly from real traffic and re-check grader agreement whenever the rubric or product output distribution changes.

You ship LLM evals with Anthropic by building a test set from real traffic, writing rubric prompts that let Claude grade your outputs, and running the suite in CI so a score regression blocks the deploy. This guide walks through each step with working code, a sample rubric, and a GitHub Actions pipeline you can copy.

What are LLM evals and why does Anthropic's approach matter?

LLM evals are repeatable tests that score your model's outputs against a fixed test set, so you can measure quality changes instead of eyeballing them. A demo passes because you fed it five curated prompts. Real traffic contains ambiguous inputs, edge cases, and prompt-injection attempts that break retrieval and agent flows in ways no demo run predicts. Without evals, every prompt tweak or model upgrade is a guess.

Anthropic's tooling gives you two things: a structured way to build test cases and run them against Claude models, and Claude-as-grader, where a Claude instance scores outputs against a written rubric. That grading approach matters because most quality dimensions (tone, correctness of a RAG answer, agent step choices) have no deterministic check. Anthropic documents the workflow in its evals documentation.

How do you design a test set for Anthropic Claude models?

Pulling cases from production traces

Start from your tracing data, not from examples you invent at your desk. Export 100-200 recent traces covering real users, then sample deliberately: a slice of typical requests, plus every case where a human edited the output or the user retried. Those edits and retries are your ground truth for "the model got it wrong."

How many cases you actually need

You can gate deploys with as few as 50 well-chosen cases; 200 gives you stable enough numbers to compare two prompt versions. Below 50, one borderline grade swings your pass rate by several points and the eval stops being a signal. Prefer 50 real, messy cases over 500 synthetic ones.

Covering failure modes, not happy paths

List the ways your product actually breaks: retrieval misses, hallucinated fields, runaway agent loops, refusals on edge inputs. Write 5-10 cases per failure mode and label each with the expected behavior. A test set that only contains happy paths will pass every run and tell you nothing when real traffic breaks your product.

How do you use Claude as an LLM grader for your own outputs?

Writing a rubric prompt that returns JSON

Give the grader three things: the rubric, the output under test, and (for RAG products) the retrieved context it was grounded in. The rubric should be a short numbered list of criteria, each scored independently, plus one overall verdict. Force a specific response format: a JSON object with a score field per criterion, a pass/fail field, and a one-line reason. Reasons matter more than scores because they let you spot-check the grader cheaply. Anthropic documents this pattern, including chain-of-thought rubric scoring and structured output, in its evals documentation.

Calibrating the grader against human labels

A grader you have not validated is just a second opinion. Pull 50-100 outputs from real traffic, label them yourself (or with a second engineer), then run Claude over the same set and measure agreement. If the grader disagrees with you on more than a small fraction, the fix is usually the rubric: ambiguous criteria, missing edge-case definitions, or a scale that is too fine. Iterate on the rubric, not the model. Re-run this calibration whenever you change the rubric or the product's output distribution shifts, and keep the labeled set in your repo as a regression test for the grader itself.

How do you run evals continuously in CI before deployment?

An eval suite only protects you if it runs on every pull request. Here is a workflow that fails the build when scores regress.

Eval script structure

Keep the runner dumb: it loads the test set, calls your pipeline for each case, sends outputs to Claude-as-grader with your rubric, and writes a JSON file of scores. One case per line, one grader call per output, no hidden state. Store the previous run's scores in the repo or as a CI artifact so the workflow can diff against the last commit that passed.

GitHub Actions workflow, step by step

The workflow runs on pull_request. Step one checks out the code and installs dependencies. Step two runs your eval script with the Anthropic API key pulled from Actions secrets. Step three compares the new scores against the stored baseline and exits non-zero on any regression. Step four posts a comment on the PR with the per-case score diff, so the reviewer sees which cases got worse without opening logs. If the build passes, a final job uploads the new scores as the baseline for the next run.

The comparison step is where teams get tripped up. A regression is not "score went down by any amount"; graders are noisy, and a case scoring 0.85 last week and 0.83 today is usually variance, not a bug. Compare against the baseline per case, treat anything inside a tolerance band as a pass, and only fail the build when a case drops below tolerance or the mean score across the suite falls more than your threshold. Write that tolerance into the config file next to the rubric, not into someone's head.

Setting pass/fail thresholds

Set two numbers: a per-case floor (a case below it fails the build regardless of variance) and a suite-level drop limit (the mean cannot fall more than, say, 2 points). Start loose, tighten once you have seen a few weeks of run-to-run noise. The right threshold is one that fails real regressions and almost never fails on noise; if your builds flap, widen the band rather than teaching the team to ignore red Xs.

What metrics and rubrics work best for Claude-based evals?

Match the metric to the failure mode you're testing for. Binary checks (valid JSON, citation present, refusal on a banned query) are cheap, deterministic, and catch structural breakage. Likert rubrics scored by Claude as grader catch quality drift: tone, correctness of reasoning, retrieval relevance. Pairwise comparison works when you're choosing between two prompts or models and relative ranking matters more than absolute scores. Task-specific assertions (did the agent actually call the right tool, did the RAG answer cite the retrieved chunk) verify behavior, not vibes.

Failure modeMetric typeGrader
Broken format, missing fieldsBinary checkCode
Quality drift, vague answers1-5 Likert rubricClaude
Prompt/model comparisonPairwiseClaude
Wrong tool call, bad retrievalTask assertionCode

Rubric-based graders cost tokens per run, so price them before scaling: Claude pricing is per model and per token (Anthropic pricing).

How do you interpret eval results and decide when to ship?

Separating signal from run-to-run noise

LLM outputs vary between runs, so a single eval score is an estimate, not a fact. Run the same suite twice on an unchanged build and record the delta: that spread is your noise floor. A change is only real if the score moves beyond that band. For Claude-as-grader rubrics, grading variance adds a second layer, so spot-check a sample of judgments by hand before trusting a 2-point jump.

A simple ship/no-ship rule

Write the rule down before the run: ship if mean score improves or holds within noise on every rubric dimension, and no single high-traffic category drops more than your noise floor. No-ship if any safety or retrieval category regresses, regardless of the mean. When results are ambiguous, rerun once; two ambiguous runs count as no-ship. The exact thresholds matter less than the team agreeing on them before results exist.

What does running evals in CI actually cost?

Every push pays twice: your test set runs against the model, and Claude-as-grader scores each output. A 50-case suite with a 2,000-token prompt and a 500-token response, plus a grader call of similar size, is roughly 250,000 tokens per run. Run that on every push to a busy repo and the bill compounds fast.

Three levers keep it proportionate. Run the full suite only on PRs targeting main, and a 10-case smoke set on feature branches. Cache static parts of your grading prompt, since Anthropic's prompt caching documentation shows cached input tokens cost a fraction of uncached ones. And grade on a smaller Claude model where your rubric allows it, reserving the larger model for borderline cases.

Budget it like infra: if a full run costs a dollar, 20 merged PRs a week is roughly $80 a month. That is cheap compared with shipping a regression to real users.

What are common mistakes teams make with Anthropic evals?

Four failure patterns show up repeatedly.

First, grading with the same model that generated the output. Claude grading its own outputs shares blind spots with itself, so scores drift upward. Swap in a different grader model, or at minimum spot-check grader agreement against human labels.

Second, static test sets that rot. A set built from last quarter's traffic stops covering what users now ask. Refresh it monthly from real traces, not from what the team remembers.

Third, thresholds set once and forgotten. A pass rate that gated deploys at v1 quietly blocks good releases at v5, or worse, stops blocking bad ones. Revisit thresholds whenever the rubric or product changes.

Fourth, evals that never see real traffic. Synthetic cases pass while production fails. Sample actual user inputs into the test set, including the ones that broke.

FAQ

Can I use Claude to grade Claude's own outputs reliably?

You can, but self-grading shares blind spots, so scores tend to drift upward. The safer setup is a different Claude model as grader, or the same model with spot-checks against human labels. Pull 50-100 real outputs, label them yourself, and measure agreement. If the grader disagrees often, fix the rubric before blaming the model.

How many test cases do I need before my evals mean anything?

Fifty well-chosen cases are enough to gate deploys; 200 gives you stable numbers for comparing two prompt versions. Below 50, one borderline grade swings your pass rate by several points and the run stops being a signal. Composition matters more than volume: 50 messy real cases beat 500 synthetic ones.

Do I need Anthropic's evals if I already do manual spot checks in staging?

Manual spot checks miss what real traffic breaks: ambiguous inputs, edge cases, and injection attempts that demos never surface. They also do not block a deploy, so every prompt tweak or model upgrade stays a guess. An eval suite in CI turns quality into a number that fails the build on regression.

How often should I refresh my eval test set?

Monthly, sampled from real traces. A set built from last quarter's traffic stops covering what users ask now, and synthetic cases keep passing while production fails. Refresh from exports of actual user inputs, weighted toward cases where a human edited the output or the user retried, and label each with expected behavior.

Got an AI system that works in the demo but not in production?

Book a call