Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Claude
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate

A maintenance triage classifier runs on a Haiku-tier model and a newer tier is out. Replay a frozen 12-case golden set, calibrate the judge against people, find a format drift, and let a small gate decide hold or stage.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Build a small golden set that is independent of the prompt and frozen as a version
  • Trust an LLM judge only after it agrees with people above a bar you set
  • Tell a format drift in the integration layer from a real model error
  • Write a release gate that holds on the binding constraint and stages a canary when it passes

Before you start

  • Building a golden dataset for LLM evals
  • LLM-as-judge basics
  • Basic Python

A block of flats has a maintenance desk. A tenant writes: The heating has been off since last night and it is freezing. A classifier reads that and puts it in one of three queues:

  • urgent: send someone now,
  • schedule: a routine repair,
  • redirect: not a repair, the office handles it.

Today the classifier runs on a Haiku-tier model, in service. A newer tier is out, and the obvious question is whether it can take over. One rule matters more than any other: no urgent request may be missed. A higher overall score is not proof of that. The proof has to come first.

Pinning the model ID and staging the rollout are covered in pinning Claude model IDs and upgrading safely. This walk-through is about the proof itself.

Five steps before a switch

Five steps before a model switch 1 Golden set 12 cases frozen, not in prompt 2 Replay same cases on each model 3 Judge checked against people first 4 Gate a missed urgent case holds 5 Canary small share first, old pin ready Each step answers one way a switch can go wrong.
A model switch is a decision with evidence, not a guess.

The example project runs against a stand-in: the real Anthropic SDK talks to a mock transport that answers like the Messages API. Every reply is scripted test data, not a measurement of a real model. The point is the process, not the scores.

Step 1: a golden set that is fair

Here's a tempting mistake. The team wrote the triage prompt using last week's requests as examples, then built the golden set from those same requests. The prompt scores well. Of course it does: it has seen the answers.

A golden set only measures something if it is independent of the prompt and frozen. This one has 12 cases, covers every label, includes one edge case (a smoke alarm that only chirps), and changes only as a new version.

"""Golden set golden-v1 for maintenance triage. Frozen: it changes only as golden-v2."""

VERSION = "golden-v1"

CASES = [
    {"id": "g01", "expect": "urgent",
     "text": "There is a strong smell of gas in the stairwell."},
    {"id": "g03", "expect": "urgent",
     "text": "The heating has been off since last night and it is freezing."},
    {"id": "g09", "expect": "redirect",
     "text": "Please move my parking permit to my new car."},
    {"id": "g11", "expect": "redirect",
     "text": "My neighbour plays loud music at night."},
    {"id": "g12", "expect": "schedule",
     "text": "The smoke alarm chirps once a minute, probably the battery."},
    # ... 12 cases in all: urgent 4, schedule 5, redirect 3
]

EXPECT = {c["id"]: c["expect"] for c in CASES}

Three ways this goes wrong: padding the set with near copies of the same requests (no new coverage), letting the classifier propose its own labels (the set then measures the model against itself), and editing cases whenever the prompt changes (the target moves and hides a regression). More on writing cases in building a golden dataset.

Step 2: replay, and look at the misses

The same 12 cases go to each model, and each answer is compared with the expected label. Notice the replay keeps two kinds of miss apart: a real wrong label, and a label that is right after normalising.

def run(client, model):
    exact, wrong, drift = 0, {}, {}
    for case in golden.CASES:
        raw = classify.ask(client, model, case["text"])["label"]
        if raw == case["expect"]:
            exact += 1
        elif classify.normalize(raw) == case["expect"]:
            drift[case["id"]] = raw
        else:
            wrong[case["id"]] = raw
    return Result(model, exact, wrong, drift)


def normalize(label):
    return label.strip().lower()
golden-v1  12 cases  urgent 4  schedule 5  redirect 3

claude-haiku-5-5 (in service)
  exact match   9/12
    g03 expected 'urgent', got 'schedule'
    g09 expected 'redirect', got 'Redirect'
    g12 expected 'schedule', got 'urgent'
  g09 is format drift: the label is right, the spelling is not
  after normalizing   10/12   urgent 3/4

Look at g09, the parking permit. The model said Redirect with a capital R. An exact comparison marks it wrong and accuracy reads 75 percent. But the model's answer was right. The failure sits in the integration layer, in the check, not in the model. The fix is to compare normalised labels, or to constrain the label with structured outputs. Moving to a bigger tier or adding more redirect examples would aim at the wrong layer. Writing it down as an accepted exception would hide the symptom until the next spelling drift.

Step 3: trust the judge only after it agrees with people

The classifier also writes a one-line reason, and a judge model grades each reason. Before you believe the judge, people grade the same 12 reasons, and you measure how often the judge agrees with them. Picking a bigger judge model doesn't show agreement with your people. Asking the judge to explain itself gives you a confident paragraph, not a measurement. Running the judge twice and keeping matches only shows it is consistent, and a judge can be consistently lenient.

JUDGE_V1 = (
    "You grade the reason given for a triage label. "
    "Answer pass if the reason sounds sensible, otherwise fail."
)

JUDGE_V2 = (
    "You grade the reason given for a triage label. Answer pass only if the "
    "reason names the detail in the request that decides the label, and fits "
    "the label. A short or vague reason fails. Judge content, not length."
)
judge claude-opus-5-5 against people (12 reasons)
  judge-v1   agree 9/12 = 75%   bar 85%   not trusted
  judge-v2   agree 11/12 = 92%   bar 85%   trusted

The first prompt accepts anything that "sounds sensible", including a reason like Seems fine. It agrees with people 9 times out of 12, below the 85 percent bar. The revised prompt says what a passing reason must contain, and agrees 11 times out of 12. The bar is your own number. The full method is in LLM-as-judge: write a rubric and check every verdict.

Step 4: the gate

Now the candidate tier gets the same replay:

claude-sonnet-5-5 (candidate)
  after normalizing   11/12   urgent 4/4
  fixed   g03 g12
  broken  g11

It gets every urgent case right, fixes the heating case and the smoke alarm, and breaks one case: the noise complaint, which it now sends to scheduling. Is that good enough? The gate decides, in a few lines of plain code. It is your own release rule, not a platform feature.

"""Release gate: may a candidate model take over?"""
import golden

# The judge must agree with people this often.
BAR = 0.85


def gate(judge_rate, now, cand):
    if judge_rate < BAR:
        return "hold", "judge not trusted yet"
    urgent = [c for c in cand.wrong
              if golden.EXPECT[c] == "urgent"]
    if urgent:
        return "hold", "urgent missed: " + ", ".join(urgent)
    broken = sorted(set(cand.wrong) - set(now.wrong))
    note = ", ".join(broken)
    return "stage", "canary first, broken: " + note
  • If the judge is below the bar, nothing else is worth reading. Hold.
  • If the model misses any urgent case, hold. That is the binding constraint from the scene.
  • Cases the old model got right and the candidate gets wrong are listed, not hidden.
  • If all of that passes, the answer is stage, not "switch".
gate
  judge-v1, candidate     -> hold: judge not trusted yet
  judge-v2, today's model -> hold: urgent missed: g03
  judge-v2, candidate     -> stage: canary first, broken: g11

Note the middle line: today's model fails its own gate, because it misses the heating case. Staying put isn't the safe option either.

Step 5: stage it

Passing the golden set earns a staged rollout, not a full switch. Send a small share of requests to the candidate, watch urgent misses and the broken noise case, and keep the old model pin ready. A full switch now would skip the watch period and the way back. Jumping to the largest tier instead would be a guess, since it was never replayed on the golden set. For the rollout mechanics, see shadow, canary and rollback.

Recap

StepWhat it protects against
Frozen golden set, independent of the promptA score that only measures what the prompt has already seen
Replay with exact and normalised comparisonBlaming the model for a check that is too strict
Judge calibrated against peopleTrusting grades from a lenient grader
Gate on the binding constraintA higher average hiding a missed urgent case
Canary with the old pin readyFinding the broken case in production with no way back

Prove it, then stage it.

Try it yourself

Add a thirteenth case to a golden-v2, say "The front door lock is broken and won't close", and decide its label before you run anything. Then add a second rule to gate(): hold if more than one case breaks. Which result changes?

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Claude · 54 of 66

Previous
Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
Next post
From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Related posts

The Claude Messages API: Your First Call, Field by Field

One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.

Claude Tool Use: How tool_use and tool_result Work in the Messages API

Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.

Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared

Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.

Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move

Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.

On this page

  • Five steps before a switch
  • Step 1: a golden set that is fair
  • Step 2: replay, and look at the misses
  • Step 3: trust the judge only after it agrees with people
  • Step 4: the gate
  • Step 5: stage it
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Developer - Foundations (CCDV-F) Exam Prep

Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact usFAQs
Legal
Terms of ServicePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.