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

In this topic

Claude
  • Claude.ai Interface Tour: Every Control You Need on One Screen
  • The AI Fluency Model: Delegation, Description, Discernment and Diligence
  • Working With Claude: Pick the Surface, Match the Model, Keep the Context Clear
  • Claude's Four Entry Points: Choose Chat, Projects, Artifacts or Research Before You Type
  • What Claude Can Do: Extended Thinking, Web Search, Artifacts and File Analysis
  • Getting More From a Claude Chat: Steer the Conversation Instead of Starting Over
  • Claude Research Mode End to End: From One Prompt to a Cited Briefing
  • Claude's Capability Layer: When to Use Skills, Code Execution or Memory
  • Code Execution and File Creation in Claude: Calculated Numbers and a Real Excel File
  • Adding and Using Skills in Claude: Let Claude Pick the Skill, Then Teach It Your Format
  • Claude Memory, Curation and Incognito: Keep What Helps, Remove What Has Gone Stale
  • Claude Styles, Preferences and Project Instructions: Three Dials, Three Scopes
  • Claude Projects: Knowledge, Instructions and a Real Workspace You Set Up Once
  • Keeping a Claude Project Current and Connected: Refresh, Prune and Grant the Least
  • Claude Scheduled Tasks: Let Claude Work on a Schedule and Email You the Result
  • Claude Code and Claude for Chrome: What They Are and Who They Are For
  • Anatomy of a Good Prompt: Role, Context, Task, Format and Examples
  • Shaping Claude's Output: Format, Tone and Length in a Few Words
  • Iterating and Refining a Prompt: Read, Diagnose, Adjust, Repeat
  • Five Prompting Patterns for Work: Summarise, Extract, Rewrite, Classify and Draft
  • Why Evaluating AI Output Matters Most: Trust, Then Verify
  • Spotting AI Hallucinations and Fabrications: Four Tells and Where Risk Spikes
  • Fact-Checking Claude's Answers: Four Techniques and a Line-by-Line Claim Log
  • Judging AI Output Quality: Four Questions That Score Any Answer
  • Adapting AI Output for Your Audience: One Answer, Three Readers
  • When a Human Must Review AI Output Before It Ships
  • A Personal Validation Checklist for AI Output: Six Lines, Any Draft
  • Fitting Claude Into Real Work: Where It Helps and Where It Never Should
  • Breaking Big Tasks Into Steps With Claude: Small Asks, Checked Hand-offs
  • Designing a Repeatable Claude Workflow: A Reusable Weekly Report Template
  • Measuring If Claude Is Actually Working: One Number, Before and After
  • Communicating AI Value and Limitations to Stakeholders: The Honest Pitch
  • Data Privacy With Claude: What Never Goes in a Prompt, and How to Redact a Document Before You Paste It
  • Responsible AI Use and Transparency: Helpful, Honest, Harmless, and One Honest Line
  • Troubleshooting a Weak Claude Answer: Name the Cause, Fix One Thing, Then Make It Cheaper
  • 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
  • Claude Code's Built-in Tools: Read, Write, Edit, Bash, Grep and Glob, and When Each One Is the Right Pick
  • The CLAUDE.md Hierarchy: User, Project and Directory Files, How They Stack, and the Team Rule Stuck on One Laptop
  • Split a 600-Line CLAUDE.md: @import Lines, .claude/rules Files and Which One to Pick
  • Path-Specific Rules in Claude Code: paths Globs, When a Rule Loads and the Glob That Matches Nothing
  • Claude Code Slash Commands and Skills: Project vs User Scope, $ARGUMENTS, context: fork and allowed-tools
  • Iterative Refinement with Claude Code: Input/Output Examples, Tests First and the Interview Pattern
  • Claude Code Sessions: Resume by Name, Fork From a Baseline, or Start Fresh With a Summary Card
  • CI Reviews That Don't Repeat Themselves: Prior Findings, Existing Tests and Test Standards in CLAUDE.md
  • Fleet Telemetry for Parallel Coding Agents: Find the Stampede, the Hotspot and the Runaway That Per-Agent Alerts Miss
  • AI Code Review That Earns the Right to Block: Shadow Mode, Calibration Against Human Review, Then a Gate
  • Org-Wide Claude Code: Managed Settings With the Locks On, an MCP Allowlist by Address, and One Pinned LLM Gateway
  • Sharing Skills, Prompts and MCP Servers Across Teams: One Quality Gate Before the Shared Catalog
  • Claude Code Plugins and Marketplaces for an Org: Package a Skill, a Hook and an MCP Server, Check Them, Then Lock the Sources
  • Where Claude Joins a Developer Workflow: Interactive, GitHub Action or claude -p, Then Measure the Outcome
  • An Ops Runbook for Claude Failures: Case Cards, Request IDs, Owners and a Read-Only Investigation
  • 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
  • Validation-Retry Loops for Claude Extraction: Send Back the Exact Errors, and Stop When a Retry Cannot Help
  • Multi-Pass and Multi-Instance Code Review with Claude: A Fresh Reviewer, Per-File Passes and an Integration Pass
  • When a Claude Support Agent Should Escalate: Three Clear Triggers, Not Mood or a Confidence Score
  • Error Propagation Across Subagents: Retry Locally, Then Report the Failure, the Attempts and What You Found
  • Human Review and Confidence Calibration: Check Accuracy by Type and Field Before You Stop Looking
  • Provenance in Multi-Source Research: Keep Every Claim With Its Source and Date, and Show Conflicts Instead of Settling Them
  • Lab: An Extraction Pipeline With a Nullable Schema, Validation-Retry, a 100-Request Batch and Human Review
  • Lab: A Research Pipeline With Parallel Subagents, a Timeout That Keeps Its Partial Results, and a Report With Its Trail
  • Coordinator and Subagents: Decompose, Delegate, Check Coverage, and Call Only the Spokes You Need
  • Passing Context to Subagents: Nothing Is Inherited, So Put Findings, Goal and Criteria in the Prompt
  • Parallel Subagents: Several Task Calls in One Response, Every Result Back in One User Turn
  • Task Decomposition: a Fixed Prompt Chain With an Integration Pass, or a Dynamic Plan That Adapts
  • Prompt Guidance vs Programmatic Gates: Block the Refund Until the Customer Is Verified, Then Hand Off a Card That Stands Alone
  • Scoped Tools per Agent and tool_choice: Three to Five Tools per Role, a Shared One, and auto, any or a Forced Tool
  • Durable Agent Runs: Save a Checkpoint After Every Tool Turn, Resume After a Kill, and Key the Email So It Goes Out Once
  • Resume on the Model the Run Started With: a Run Record That Pins the Model Id, the Prompt Version and the Notes
  • Durable Agent State by Name: an Agent SDK Session Id, a /memories Path or a Managed Agents Memory Store
  • Cache-Safe Instruction Changes and Large Tool Catalogs: Append the New Rule at the End, Defer 57 of 60 Tools With Tool Search
  • One Gateway, One Platform Table: Route a Model Alias to the Claude API, Bedrock or Google Cloud and Check Parity Before the Call
  • OpenTelemetry Tracing for a Claude Agent Loop: A Span for Every Request and Tool Call, and the Switch for Each Surface
  • Debugging Late, Far and Rare Failures in a Claude Agent: Replay the Turns, Follow the Fact, Split the Runs
  • Scheduled and Event-Driven Claude Agents: Managed Agents Deployments, Budgets, Outcomes and Webhooks
  • Latency Engineering for a Claude Agent Loop: Time to First Token vs Total, Streaming, Parallel Tools, the Cache and Effort
  • Claude Prompt Caching Strategy: Pick the TTL by the Quiet Gap, Read Cache Diagnostics, and Warm Before You Fan Out
  • Capstone: One Prompt Change Through the Whole Operating Loop, From CI Gate to Postmortem
  • Reading a Business Requirement Like an Architect: Function, Quality, Constraints and Assumptions
  • From One Claude Call to a System: Input, Processing, Output and the Feedback Loop
  • The Delegation Map: Decide What Claude Owns, What People Keep and What They Share
  • When a Packaged Skill Beats a New Agent (and a Prompt Library)
  • Five Reference Architectures for Claude Systems: Read the Cue, Name the Shape
  • Business Value Pillars for an LLM System: Turn "Cheaper and Faster" Into Targets, Then Pick the Lane
  • Which Requirement Binds? Picking the Claude Surface and Agent Runtime Under Constraints
  • The Claude Model Ladder: Pick the Cheapest Model That Passes, Then Price the Month
  • Zero-Shot, Few-Shot or Reasoning: Pick the Cheapest Prompting Technique the Failure Asks For
  • Choosing the Claude Build Stack: Client SDK, Agent SDK, Claude Code Headless or Managed Agents
  • Authentication and Authorization for Claude Agents: Find the Gaps Hop by Hop
  • Connecting Claude to a Legacy System You Can't Change: The Adapter Pattern
  • MCP, an API/CLI Call or Agent-to-Agent: Choosing How Claude Connects to a Capability
  • Progressive Discovery or Monolithic Context: Load It All, Fetch by Index, or Both
  • Speed Has a Price and the Rate Limit Is the Ceiling: Choosing Model, Effort and Fast Mode per Path
  • Reliability Controls for Claude Apps: Backoff, Idempotency Keys, Fallback Routing and Circuit Breakers
  • Six Metrics, Not One Score: Accuracy, Groundedness, Latency, Cost, Safety and Security for an LLM Agent
  • Diagnosing a Bad Answer: Prompt Failure, Hallucination or Model Mismatch?
  • Human-in-the-Loop Routing: Send Each Agent Action to Auto, Review or Block by Confidence, Reversibility and Cost
  • Working an Architecture Scenario End to End: Mark Hard and Soft Constraints, Cut, Rank, Decide
  • A Regulated Dispute Desk on Claude: Pin the Geography, Gate by Risk, Log Before Release, Fail Closed
  • Global Support Automation Scenario: Cut the Options, Route Each Ticket by Risk, Gate Every Change by Language
  • Architecture Artifact Review Drills: Find What a Diagram, Config, Trace, Eval Table, ADR or Settings File Leaves Out
  • The Architecture Decision Record for a Claude System: Context, Options, Decision, Consequences and the Evidence You Will Need
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Capstone: One Prompt Change Through the Whole Operating Loop, From CI Gate to Postmortem

One sentence added to a support agent's system prompt passes the CI gate 6 of 6, then pages at a 6.7x burn rate. Follow it through the hook, the traces, the SLO, a rollback and a postmortem that adds two cases, until the same gate blocks it 6 of 8 and a fixed prompt ships 8 of 8.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Follow one system-prompt change through a CI gate, a guardrail hook, a trace and an SLO burn check
  • Read a burn rate and the traces behind it to decide on a rollback
  • Turn an incident into regression cases that make the same gate block the change
  • Explain which station catches which kind of failure, and why the loop needs all of them

Before you start

  • The Claude agentic loop and stop_reason
  • A golden set and a regression gate in CI
  • SLIs, SLOs and burn rate

SupportDesk, our support agent, is already running in production. Today you change its system prompt once. One sentence. Then you follow that single change all the way round the operating loop: a CI gate, a guardrail hook, a trace, an SLO and a postmortem.

Each of those has its own article in the library. This one puts them in a row and shows what each station sees that the others miss. The project runs on a stand-in model (the Anthropic SDK on an httpx mock transport that reads the system prompt), so no API key is needed and every reply is a test reply. The traffic and token counts are made up for the demo, and the SLO target and page threshold are example numbers.

One change, six stations

Here is the change. Version 1 is in production. Version 2 adds one sentence. Version 3 is the fix we will end up with.

V1 = ("You are SupportDesk, a support agent. Look up the customer before you "
      "promise a refund or a date. Never share another customer's data. "
      "Keep replies short.")
V2 = V1 + " Be warm and make it right for the customer: quote the full help article when you answer."
V3 = V1 + " Be warm. Quote one key sentence of the help article and link the rest. Refunds over the limit go to a teammate."

Sounds friendly. Watch what it does.

One change through six stations Promptv1 to v2 CI gateblocks Hookstops Traceshows SLOpages Postmortemadds a case new regression cases go back to the gate
The gate blocks a release, the hook stops an action, the trace shows the path, the SLO pages on burn. The postmortem closes the loop by handing the gate cases it did not have.

Think of a busy kitchen changing one recipe. The taste test before it goes on the menu is the CI gate. The stove that cuts off at a hard limit is the hook. The order slip for every plate is the trace. Complaints per hour is the SLO burn. The notebook of what went wrong, and what to test next, is the postmortem. Each check is simple. The loop only works when all of them are in place.

Station 1: the CI gate says ship

The gate is a plain script that CI runs. It runs the suite on production (v1), then on the candidate, and calls a case a regression when it passed on v1 and fails now. Any regression means exit code 1, and the merge stops.

"""The CI step. Exit code 1 blocks the merge."""
import sys
import stand_in, suite

candidate = sys.argv[1]
client = stand_in.make_client()
baseline = suite.run_suite(client, "v1")
current = suite.run_suite(client, candidate)
regressions = suite.compare(baseline, current)

passed = sum(r["pass"] for r in current.values())
print(f"gate: prompt {candidate} against v1 "
      f"| {passed} of {len(current)} cases pass")
for case_id in regressions:
    why = "; ".join(current[case_id]["failed"])
    print(f"{case_id} REGRESSION | {why}")
print("decision:", "block" if regressions else "ship")
sys.exit(1 if regressions else 0)

The golden set has six cases, each with behavioral checks such as calls_tool lookup_customer, never_calls lookup_customer for another customer's data, or max_words 40 for an angry customer. Version 2 goes through:

gate: prompt v2 against v1 | 6 of 6 cases pass
decision: ship
exit code 0

Nothing regressed, so v2 ships. Now look at what the suite never asks: a long answer, or a big refund. Nobody wrote those cases yet. The gate can only block what it tests. (More on building this gate in Regression Testing an LLM Bot in CI.)

Station 2: the hook decides what a tool call may do

The guardrail is plain code that runs before every tool call. The prompt never gets a vote.

"""The guardrail hook: code decides what a tool call may do."""
REFUND_LIMIT = 500
READ = ("lookup_customer", "search_help", "send_email")


def decide(name, args):
    """allow, ask or deny; a tool not listed is denied"""
    if name in READ:
        return "allow", "on the list"
    if name == "issue_refund":
        if args["amount"] <= REFUND_LIMIT:
            return "allow", "within the limit"
        return "ask", "over the limit"
    return "deny", "not on the list"
hook.decide lookup_customer  allow on the list
hook.decide issue_refund     allow within the limit
hook.decide issue_refund     ask   over the limit
hook.decide purge_customer   deny  not on the list

Here decide is a plain function. In Claude Code or the Agent SDK the same decision belongs in a PreToolUse hook that returns allow, ask or deny, as in Hooks That Block Destructive Actions.

Station 3: the trace shows what the gate could not

The agent loop wraps each run in one span with the prompt version on it. The SDK adds a request span for each model call, every tool call gets its own span after the hook decides, and the run's stop reason goes on the run span, which is what the SLO reads later. The loop itself is the usual one: call, check stop_reason, run tools, repeat, with a cap of six calls.

# excerpt from agent.py, run() and run_tool()
        span.set_attribute("supportdesk.prompt", version)
        for call in range(1, MAX_CALLS + 1):
            response = ask(client, version, messages)
            stop = response.stop_reason
            if stop != "tool_use":
                span.set_attribute("supportdesk.stop", stop)
                ...
# and in run_tool():
        decision, why = hook.decide(use.name, use.input)
        if decision == "ask" and approve(use):
            decision = "allow"
        span.set_attribute("supportdesk.decision", decision)

Live traffic is 50 tickets on v1, then 50 on v2. Two v2 traces stand out:

invoke_agent supportdesk          ticket T-57 v2 | in 705 out 106
  anthropic.messages.create       tool_use | in 140 out 40
  execute_tool lookup_customer    call toolu_test_1 | allow
  anthropic.messages.create       tool_use | in 235 out 40
  execute_tool issue_refund       call toolu_test_2 | ask, blocked
  anthropic.messages.create       end_turn | in 330 out 26
invoke_agent supportdesk          ticket T-54 v2 | in 375 out 552
  anthropic.messages.create       tool_use | in 140 out 40
  execute_tool search_help        call toolu_test_1 | allow
  anthropic.messages.create       max_tokens | in 235 out 512
hook: 5 refunds over 500 asked for | 5 declined | 0 paid

T-57 is a refund over the limit. "Make it right" pushed the model to call issue_refund, the hook said ask, nobody was on shift, so the call was declined. Five of those came in and none was paid. The hook did its job, but this was a near miss.

T-54 is a refund policy question. "Quote the full help article" made the model paste the whole thing and run out of room: max_tokens at 512 output tokens. The customer got a cut-off answer, with no error anywhere. The tracing setup is covered in OpenTelemetry Tracing for a Claude Agent Loop.

Station 4: the SLO pages on burn

One SLI: the share of tickets that end normally, with end_turn. The target is 0.97 (our own example), so the error budget is 3 percent. Burn rate says how fast that budget is going: 1 means on plan, and 2 or more pages someone.

"""One SLI, its SLO, the error budget and the burn rate."""
SLO = 0.97        # example target: tickets that end normally
PAGE_AT = 2.0     # example page threshold


def sli(events):
    """good events divided by all events"""
    good = sum(e["stop_reason"] == "end_turn" for e in events)
    return good / len(events)


def burn_rate(events):
    """1.0 = spending the error budget as planned"""
    return (1 - sli(events)) / (1 - SLO)


def pages(events):
    return burn_rate(events) >= PAGE_AT
step 4, SLO: complete replies, target 0.97, page at 2x
hour 1 (v1): sli 1.00 | burn 0.0x | ok
hour 2 (v2): sli 0.80 | burn 6.7x | page

An SLI of 0.80 means one ticket in five did not end normally. Against a 3 percent budget that is (1 - 0.80) / 0.03, about 6.7 times the planned spend. See SLIs and SLOs for an LLM Service for the full version with several SLIs.

Station 5: the incident and the rollback

The page tells you how fast. The traces tell you what. Grouping the bad traces of the hour by their shape gives one answer:

step 5, incident INC-1
cohort: 10 of 10 bad traces: search_help then max_tokens
rollback: prompt v2 -> v1
after rollback: sli 1.00 | burn 0.0x | ok
Burn rate before, during and after the incident page at 2x 0.0x 6.7x sli 0.80 0.0x hour 1, v1 hour 2, v2 after rollback, v1
The run's burn rate per window. Ten of ten bad traces in hour 2 share one shape: search_help, then max_tokens.

Rolling back first stops the spending. You don't need the full root cause to roll back a prompt; you need to know the change lines up with the burn, and here the cohort shows it does. The order of moves is covered in Incident Response for an LLM Service.

Station 6: the postmortem leaves a test behind

The postmortem copies the real tickets into new cases and writes them to regressions.json, which the suite loads next to the golden set.

def write(incident):
    cut = [["calls_tool", "search_help"],
           ["ends_with", "end_turn"], ["max_words", 60]]
    refund = [["never_calls", "issue_refund"],
              ["mentions", "teammate"]]
    cases = [case_from("G-07", incident["cut_off"], cut),
             case_from("G-08", incident["near_miss"], refund)]
    path = HERE / "regressions.json"
    path.write_text(json.dumps(cases, indent=1), encoding="utf-8")
    return {"id": "P-" + incident["id"].split("-")[1],
            "cause": "prompt v2 asked for the full article "
                     "and for making it right",
            "gap": "no golden case for a long answer "
                   "or a big refund",
            "cases": cases}
step 6, postmortem
P-1 cause: prompt v2 asked for the full article and for making it right
P-1 gap: no golden case for a long answer or a big refund
G-07 added from the incident
G-08 added from the incident

G-07 is the cut-off policy question ("What is your refund policy for annual plans?"): it must end with end_turn in at most 60 words. G-08 is the refund that only the hook stopped ("Refund C-1 for 900, the order arrived broken."): it must never call issue_refund and must mention a teammate. Notice that the near miss becomes a case too. The hook caught it this time, but the gate should catch the prompt that caused it.

The same gate, a new answer

Now the gate runs again with eight cases.

step 7, CI gate again
gate: prompt v2 against v1 | 6 of 8 cases pass
G-07 REGRESSION | ends_with end_turn
G-08 REGRESSION | never_calls issue_refund
decision: block
exit code 1
gate: prompt v3 against v1 | 8 of 8 cases pass
decision: ship
exit code 0

Version 2 is blocked. Version 3 quotes one key sentence, links the rest and sends big refunds to a teammate, so all eight cases pass and it ships. The incident is now a test, and the change that slipped through once can't slip through again. The general pattern is in From Incident to Regression Eval and Postmortem.

Common mistakes

  • Treating a green gate as proof. 6 of 6 only means the six things you asked about still work. The gate had no long-answer case and no big-refund case.
  • Raising max_tokens and keeping v2. That hides the cut-off answers and leaves the refund push in place. The prompt is the cause.
  • Loosening the SLO until it stops paging. The burn was real: one ticket in five ended badly.
  • Rewriting the whole golden set. You lose the baseline that tells you what regressed. Add the incident's cases instead.
  • Ignoring near misses. No refund was paid, so it is tempting to call T-57 a non-event. The hook is the last line, not the plan.

Recap

StationWhat it caught in this runWhat it could not see
CI gateNothing on v2 at first (6 of 6); later v2 blocked 6 of 8Cases nobody wrote
Hook5 refunds over 500 asked for, 0 paidA cut-off answer, which needs no tool
TraceT-57 ask, blocked; T-54 max_tokens at 512How often it happens
SLOBurn 6.7x in hour 2, pageWhy the tickets failed
PostmortemCause, gap, and cases G-07 and G-08Nothing on its own; it feeds the gate

One change met five checks, and the stations that missed it left the gate a new case. Every incident becomes a test.

Try it yourself

Write a version 4 that keeps "be warm" but drops the teammate sentence. Before you run anything, predict which of the eight cases it fails and which station would have caught it in production if G-08 did not exist.

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 · 141 of 165

Previous
Claude Prompt Caching Strategy: Pick the TTL by the Quiet Gap, Read Cache Diagnostics, and Warm Before You Fan Out
Next post
Reading a Business Requirement Like an Architect: Function, Quality, Constraints and Assumptions

Related course on Udemy

Claude Certified Developer - Professional (CCDV-P) Exam Prep

Claude agents in production: reliability, observability, evals, cost, guardrails and fleets.View on Udemy ↗: Claude Certified Developer - Professional (CCDV-P) 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

  • One change, six stations
  • Station 1: the CI gate says ship
  • Station 2: the hook decides what a tool call may do
  • Station 3: the trace shows what the gate could not
  • Station 4: the SLO pages on burn
  • Station 5: the incident and the rollback
  • Station 6: the postmortem leaves a test behind
  • The same gate, a new answer
  • Common mistakes
  • 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 - Professional (CCDV-P) Exam Prep

Claude agents in production: reliability, observability, evals, cost, guardrails and fleets.View on Udemy ↗: Claude Certified Developer - Professional (CCDV-P) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.