AI System Design

Design a Prompt A/B Platform

Step 1 / 9

Learn AI system design by building the platform that versions, evaluates, and safely A/B tests PROMPTS in a production LLM application — a much faster-moving artifact than model weights, often…

The numbers to beatprimary metricwhat the test aims to improveguardrail metricsmust never regressboth requiredfor promotion

In the interview room

How you’d open this design in an interview

Before any boxes: agree what it must do, pin the qualities that shape everything, then build — naming each trade-off as you make it. The walkthrough above is that exact order.

Functional requirements

What it must do — agree on these before drawing a single box.

  • Version prompts: externalize prompt text as versioned config so a non-engineer can edit it without a code deploy.
  • Gate before rollout: score each candidate against a fixed offline eval set before it touches real traffic.
  • A/B test live: split real traffic between the current prompt and a candidate, measuring real outcome metrics.
  • Guardrails hold: track cost/latency/safety that must never regress, blocking promotion even when the primary metric wins.
  • Rollback + review: instant version-pointer rollback, and a non-engineer-safe approval gate before an edit ships.

Non-functional requirements

The qualities that shape the whole design — each one names the mechanism that buys it.

Iterate without a code deploy
A Prompt Registry: prompts are versioned config the app fetches at runtime, so publishing a new version is a registry write, not a build/deploy cycle.
Nothing unvalidated reaches users
An Offline Eval Gate scores every candidate against a fixed evaluation set and fails closed — no unvalidated candidate advances while it’s unavailable.
Catch effects offline eval misses
A true A/B test on a slice of live traffic, measuring real outcomes (task success, satisfaction, conversion), not just the offline eval score.
A metric win can’t hide a hidden cost
Guardrail metrics — cost, latency, safety/refusal rate — tracked alongside the primary, with promotion blocked if any regresses meaningfully.
Recover from a bad prompt instantly
Immutable versioning makes rollback a repoint of the active-version reference to the previous version — a routine, low-friction operation.
A risky non-engineer edit is caught
A lightweight, prompt-specific Review/Approval gate before eval and rollout, catching removed safety instructions or broken output-format contracts.

The trade-offs you say out loud

Senior signal isn’t the boxes — it’s naming what you gave up and why it was the right price.

Externalized versioned configover prompts hardcoded in application code

Coupling a lightweight text change to a heavyweight build/deploy cycle slows iteration and locks out the PMs and prompt specialists who most directly understand prompt intent.

A Prompt Registryover a shared spreadsheet the app reads

A spreadsheet solves “no deploy” but reintroduces every quality and safety problem — no versioning discipline, no eval gate, no audit trail of who changed what and when.

An offline eval gate that fails closedover shipping a candidate straight to production

Skipping validation just means users are the first to discover a regression — a worse trade than a fast, automated pre-check against a known-good set.

A live A/B testover trusting the offline eval score alone

An eval set is a fixed historical snapshot; live traffic reveals distributional effects it never anticipated — the same reason a model gets shadow/canary rollout, not just an offline score.

Guardrail metrics that must not regressover promoting on the primary metric alone

A variant can improve task success while tripling cost per request or degrading safety — a “win” that’s a net loss, which the headline number in isolation would never reveal.

What this teaches

Learn AI system design by building the platform that versions, evaluates, and safely A/B tests PROMPTS in a production LLM application — a much faster-moving artifact than model weights, often edited by non-engineers. An interactive guide covering why hardcoded prompts force a full deploy for every tweak, externalizing prompts as versioned config, an offline eval gate before rollout, live A/B testing because offline eval alone can miss real distributional effects, guardrail metrics that must not regress even when the primary metric improves, routine one-click rollback, and a review gate that keeps prompt edits from non-engineers safe.

Key takeaways

  • Hardcoded prompts couple a lightweight text change to a heavyweight deploy cycle — externalizing them as versioned config decouples iteration speed from code deployment.
  • An offline Eval Gate, failing closed, validates every candidate against a fixed set before it's eligible for real traffic.
  • Live A/B testing catches real-world effects an offline evaluation set — a fixed historical snapshot — structurally can't reveal.
  • Guardrail metrics (cost, latency, safety) must never regress, even when a variant wins on the primary metric being optimized.
  • Rollback is a routine, instant version-pointer change, exercised far more often than for models given how frequently prompts iterate.
  • A dedicated, non-engineer-friendly review gate catches prompt-specific risks (like an accidentally-removed safety instruction) before rollout.
  • Security/injection-resistance needs its own explicit eval, separate from task-success metrics, since the two can diverge.

Concepts covered

  • Prompts change fast — the platform has to keep up
  • Prompts hardcoded in application code
  • Edit the prompt, not the code
  • Score it before anyone sees it
  • Offline eval alone can still miss real effects
  • A "win" on one metric can be a loss overall
  • Not an emergency procedure — a daily tool
  • Safe editing without requiring a code-review habit
  • Injection regressions and prompt sprawl

Design a Prompt Management & A/B Testing Platform — read the full walkthrough as text

the same steps, decisions & trade-offs, for reading, reference & search

The big idea

Prompts change fast — the platform has to keep up

A prompt gets tweaked far more often than a model gets retrained — sometimes many times a day, often by someone who isn't a software engineer. Treat every prompt change like an emergency code deploy and iteration grinds to a halt; treat it too casually and an unvalidated change reaches every user instantly.

We'll build the platform layer for prompts specifically: externalized, versioned config decoupled from deploys; offline eval before anything reaches users; live A/B testing because offline eval alone misses real effects; guardrail metrics that must never regress; and a review gate suited to non-engineer editors.

How to read this: Each step opens with a real design decision — make the call before I show you what ships. Watch the diagram grow, hover the boxes, and at the end kill the eval gate and blow up a guardrail metric to see the platform's safety nets actually engage. Hit Begin.

Step 1 · The baseline

Prompts hardcoded in application code

Simplest version: the prompt text lives directly in the application's source code. What happens when someone wants to test a wording change?

Design decision: Prompts are hardcoded in application source code. What's the cost of testing a wording change?

The call: Every prompt change requires a full code change and deploy cycle, which is slow for rapid iteration and effectively locks non-engineers (who often understand the prompt's intent best) out of testing changes themselves. — Coupling prompt text to code deployment means the iteration speed on prompts is bottlenecked by the SLOWEST part of the stack (code review, build, deploy) even though prompt wording is conceptually a much lighter-weight thing to change — and it puts prompt editing behind a skill barrier (writing and deploying code) that doesn't match who actually has the best judgment about prompt wording.

Hardcoded prompts couple a lightweight text change to a heavyweight code-deploy cycle, slowing iteration and locking out the people (often PMs or prompt specialists, not software engineers) who most directly understand prompt intent. Prompts need to be decoupled from code the way configuration typically is.

Match the artifact's change frequency to its deployment mechanism: Something that changes many times a day, edited by people without a code-deploy workflow, shouldn't be forced through the same heavyweight pipeline as infrastructure code — the mismatch itself is the design flaw.

Step 2 · Externalize as versioned config

Edit the prompt, not the code

Decouple prompt text from application code entirely.

Design decision: Prompts should be editable without a code deploy. What's the actual mechanism?

The call: Store prompts in a Prompt Registry as versioned, referenceable config — the application fetches "the currently assigned version for this use case" at runtime, and a new prompt version is a registry write, not a code change. — A registry gives prompts the same treatment as any other production configuration: versioned, auditable, and referenced by the application at runtime rather than baked into its source. Publishing a new prompt version becomes a fast, reviewable registry operation, completely independent of the application's own deploy cycle.

Introduce a Prompt Registry: every prompt is versioned config, and the application fetches the currently assigned version at runtime rather than having it compiled into its source. Publishing a new version is a registry operation — fast, auditable, and entirely decoupled from the application's own code-deploy cycle.

Configuration that changes fast shouldn't ride on a deploy pipeline built for code that changes slowly: This mirrors feature-flag and config-management patterns broadly: separate what changes FREQUENTLY and needs fast, low-risk iteration from what changes RARELY and needs the heavier guarantees of a full code deploy.

Step 3 · Offline evaluation before rollout

Score it before anyone sees it

A new prompt version is drafted. Should it go straight to real users, or be validated first?

Design decision: A new prompt version is ready. Should it go directly to production traffic?

The call: Run the candidate against a fixed offline Eval Gate — a held-out evaluation set with known-good expected behavior — and require it to pass before it's eligible for real traffic, the same principle as evaluating a candidate model before promotion. — An offline eval gate catches obvious regressions (broken output format, degraded task performance on known cases) cheaply and fast, before any real user is exposed to a bad candidate — the same "validate before it goes near production" principle used for model registry promotion, applied here to prompts.

Add an Offline Eval Gate: every candidate prompt version is scored against a fixed evaluation set before it's eligible for any real traffic, and the gate fails closed — no unvalidated candidate can be promoted while it's unavailable. This is the same eval-gate principle used for model promotion, applied to the much-higher-frequency artifact of prompts.

The same safety principle, a faster-moving artifact: Whether you're promoting a retrained model or a five-word prompt tweak, the underlying question is identical — "does this candidate perform at least as well as what's currently live, on a known evaluation set" — and deserves the same automated, default-blocked gate.

Step 4 · A/B testing on live traffic

Offline eval alone can still miss real effects

The candidate passed offline evaluation. Is that sufficient confidence to fully replace the current production prompt?

Design decision: A prompt candidate passed the offline eval set. Is that enough to fully roll it out to all users?

The call: No — run the candidate as a true A/B test on a percentage of real, live traffic against the current production prompt, and measure REAL outcome metrics (task success, user satisfaction, downstream conversion), not just the offline eval score. — A/B testing exposes the candidate to actual live user inputs and measures actual outcomes, catching real-world effects — including ones the offline eval set never anticipated — before the candidate earns full rollout. This is the exact same principle as shadow/canary validation for models, reapplied here because the underlying reason (offline metrics aren't the whole story) is the same regardless of what's being tested.

Run genuine A/B tests on live traffic via the A/B Traffic Split engine: split a percentage of real requests between the current production prompt and the candidate, and measure real outcome metrics — not just the offline eval score — before considering full rollout.

The same "offline isn't enough" lesson, in a new context: This is the identical reasoning behind shadow/canary deployment for model registry promotions — a fixed evaluation set, however good, is still a snapshot; only live traffic reveals how a candidate behaves against the real, current distribution of what users actually do.

Step 5 · Guardrail metrics, not just the headline number

A "win" on one metric can be a loss overall

An A/B test shows Variant B has a meaningfully better task-success rate than the current prompt. Should it be promoted based on that result alone?

Design decision: A variant wins on the primary metric (task success). Is that alone sufficient to promote it?

The call: No — track GUARDRAIL metrics (cost, latency, safety/refusal rate) alongside the primary metric, and require that none of them regress meaningfully, even when the primary metric improves. — Guardrail metrics catch exactly the failure mode where a prompt genuinely improves on what it's being optimized for while quietly regressing something equally important that wasn't the explicit target — cost, latency, and safety are common candidates for guardrails specifically because they're easy to overlook when focused on one headline number.

Track guardrail metrics — cost, latency, safety/refusal rate — in the Outcome + Guardrail Metrics store alongside the primary metric being optimized. A variant is only eligible for promotion if it improves (or holds) the primary metric AND doesn't meaningfully regress any guardrail, regardless of how good the primary result looks in isolation.

Optimize for one metric, and you can silently break another: Any single-metric optimization risks trading away something you weren't explicitly measuring. Guardrails are the deliberate practice of naming the things that must never regress up front, so a genuinely good-looking primary result can't hide an unacceptable side effect.

Step 6 · Routine, instant rollback

Not an emergency procedure — a daily tool

A promoted prompt version turns out to underperform in ways the test window didn't catch. How fast can you revert?

Because every prompt version in the Registry is immutable and versioned, rollback is repointing the "currently active" reference back to the previous version — the same version-pointer mechanism as model registry rollback, but exercised far more routinely given how often prompts change. This isn't a rare emergency procedure here; it's treated as a normal, low-friction operation a prompt engineer might use several times in a week.

The same rollback mechanism, a much higher-frequency use case: Immutable versioning pays off proportionally to how often you need to use it — for an artifact that changes multiple times a day, fast, routine rollback isn't a nice-to-have, it's essential to making rapid iteration safe at all.

Step 7 · A review gate built for non-engineers

Safe editing without requiring a code-review habit

Prompt engineers are often not software engineers, and may not have the instinct to flag "this edit accidentally removed the safety instruction" the way a code reviewer would catch a risky diff. What keeps an accidental unsafe edit from reaching real users?

Require every prompt version to pass through a Review / Approval Gate before it can be eligible for eval and rollout — a lightweight, prompt-specific review step (not a full code review) that a peer or an automated check can use to catch obviously risky changes (removed safety instructions, changed output-format contracts other systems depend on) before they even reach the Eval Gate.

Match the safety net to who's actually editing: A code-review culture assumes the editor is a software engineer with that instinct already. Prompt editing often isn't — so the platform needs its OWN lightweight review step tailored to prompt-specific risks, rather than assuming engineering review habits transfer automatically.

Step 8 · The sharp edges

Injection regressions and prompt sprawl

Two subtler risks: a seemingly-innocuous prompt edit that inadvertently makes the model MORE susceptible to prompt injection, and, after months of active testing, genuine confusion about what prompt version is actually live for a given use case.

Include a dedicated security/injection-resistance eval suite in the Eval Gate, distinct from task-success metrics — a prompt edit can pass every functional check while quietly weakening resistance to adversarial input, so security needs its own explicit test, not an assumption that functional correctness implies it. For prompt sprawl, the Registry maintains one clear, queryable single source of truth for "what's the currently active prompt version for this use case," regardless of how many draft versions or past experiments exist alongside it.

Design for the unhappy path: Eval gate down → fail closed, nothing unvalidated ships. A variant that wins on one metric → guardrails catch the hidden cost. A non-engineer's risky edit → a dedicated review gate. Prompt sprawl → one unambiguous "what's live" answer. A prompt platform that only works when every edit is well-intentioned and every test is clean is a demo; one that stays safe under real editing patterns is a product.

You did it

You just designed a prompt management platform.

  • Hardcoded prompts couple a lightweight text change to a heavyweight deploy cycle — externalizing them as versioned config decouples iteration speed from code deployment.
  • An offline Eval Gate, failing closed, validates every candidate against a fixed set before it's eligible for real traffic.
  • Live A/B testing catches real-world effects an offline evaluation set — a fixed historical snapshot — structurally can't reveal.
  • Guardrail metrics (cost, latency, safety) must never regress, even when a variant wins on the primary metric being optimized.
  • Rollback is a routine, instant version-pointer change, exercised far more often than for models given how frequently prompts iterate.
  • A dedicated, non-engineer-friendly review gate catches prompt-specific risks (like an accidentally-removed safety instruction) before rollout.
  • Security/injection-resistance needs its own explicit eval, separate from task-success metrics, since the two can diverge.
built so a prompt tweak that quietly triples cost gets caught before it ships to everyone — make the calls, blow up a guardrail, run the gauntlet.
Finished this one? 0 / 61 AI System Designs done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More AI System Designs