System Design · step by stepDesign a Prompt A/B Platform
Step 1 / 9

Design a Prompt Management & A/B Testing Platform — the walkthrough in full

A written version of the interactive walkthrough above — the same steps, decisions and trade-offs, laid out for reading, reference and 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.

  • H — a
  • A — n
  • L — i
  • G — u
  • R — o
  • A
  • S — e
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 / 54 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