Launch offer: the first 1,000 users get Settl free for a year* Claim your spot
settlbuilding in public

The prompt A/B testing setup: experiments, metrics, and the trap

The short version

A long messy set of AI instructions was rewritten into clean structured tables, which is what almost every prompt engineering guide recommends. Run head to head against real traffic, the tidy version was meaningfully slower and the messy original won.

The point is not that tidy prompts are bad. It is that prompt changes are guesses until they are measured, and the ones that feel most obviously correct are the ones nobody bothers to test.

Copy these prompts

Paste them into Claude Code (or any AI that can see your project), in this order. Each one answers a different question, and the first is usually the one that matters.

1. Write down what you expect to improve

I am about to change the instructions I give my AI. Before I do, help me write down exactly what I expect to get better and by how much, so I cannot move the goalposts afterwards.

2. Run both at once, not one after the other

Show me the simplest possible way to run two versions of my AI instructions side by side against real usage at the same time, and compare speed and quality. I do not want a whole experimentation platform, just enough to know which wins.

3. Decide the sample size in advance

Tell me the minimum number of runs before I should trust the difference between the two versions, given how variable my results are. I want that number decided before I see any results.

I refactored ~9k tokens of prose prompt into clean declarative tables: intent-dispatch table, disambiguation table, one example per hard rule. Everything the prompt-engineering posts tell you to do. Then I shipped it as a production A/B experiment instead of just believing in it: the "improved" table version ran p95 = 13.3s against the messy legacy's 10.4s. My objectively better prompt was 28% slower. It lost.

The setup

  1. Ship prompt changes as variants, never replacements. Keep the old prompt in code (STABLE_PREFIX vs STABLE_PREFIX_LEGACY in my case) with a one-line revert path:
const PROMPTS = { v1_legacy: STABLE_PREFIX_LEGACY, v2_tables: STABLE_PREFIX };
const variant = experiment('agent_prompt', sessionId); // sticky per session
  1. Bucket by session, not by request. A user mid-conversation must stay on one variant, or their turns are incomparable and the experience is inconsistent.
  2. Stamp the variant on everything. Every trace span, every telemetry event, every error carries prompt_variant. If your funnel events can't be attributed to a variant, you have decoration, not an experiment. (I lost days to confirm-events carrying a random session ID; the funnel showed zero confirms per variant until I threaded the real trace ID through.)
  3. Measure at least three axes: latency (p50 AND p95), task success (my proxy: user confirms the parsed expense vs. rejects/edits), and cost (tokens in/out). A prompt can win one and lose two.
  4. Let p95 veto p50. The tables version didn't feel slower on average. The pain lived in the tail. Users live in the tail.
  5. Run it on production traffic. Offline evals with synthetic inputs would never have surfaced this. The slowdown emerged from real utterances at real token lengths on real provider load.
  6. Decide with pre-set criteria, then keep the loser around. Legacy stayed the default; the tables version stayed installed at weight 0 for later re-testing (provider inference behavior changes; the result isn't permanent).

The trap

"Better-structured" optimizes for human readers. The model doesn't owe your aesthetics anything. Structure, length, and format interact with tokenization, caching, and provider inference in ways you cannot reason out from the armchair. If you're not A/B-testing prompts in production, you're decorating, not engineering.

Steal this for your app

Run this on your codebase

Paste this into Claude Code in your repo:

Audit this repo's LLM prompts for untested changes.
Find every production prompt (system prompts, prefixes, templates) and check whether old and new versions coexist in code with a one-line revert path, or whether edits replaced the old prompt outright.
Check experiment bucketing; flag anything bucketed per request instead of sticky per session.
Verify every trace span, telemetry event, and error carries the prompt variant; flag funnel events that cannot be attributed to a variant.
Check what gets measured per variant: p50 and p95 latency, task success, and token cost.
Scan git history for prompt rewrites that shipped with no experiment or metrics attached.
Report findings as a checklist before changing anything.

Get the next one in your inbox