How it works · 3 of 27 Foundation
Why should prompts be versioned, tested and reviewed like code?
Version, review, test, roll back
Prompts are code: A prompt is part of the program: one word changed can rewrite every answer, so each edit is saved as a new version, reviewed and tested before it goes live, and the live prompt is a label that can be moved back to the last good version in one step.
Loading the animation…
Say it like this A prompt is part of the program: every edit is a new version that is reviewed and tested before it goes live, and the live one is a label you can move back in one step.
Under the hood — for builders
- A real case: a prompt edited without review
- xAI, May 2025: "an unauthorized modification was made to the Grok response bot's prompt". Fix: so "employees can't modify the prompt without review."
- Prompt and version
- Prompt: the fixed instructions sent with every request (the recipe card). Version: one saved text that never changes; any edit makes the next one.
- Label, gate, rollback
- Label: a movable name, such as production, that the app loads. Eval gate: a test the new version must pass first. Rollback: moving the label back.
- Run here: 96% the same text, a new program
- On the scene's card, v41 → v42 changed 1 word of 25. Python's difflib rates the texts 96% the same; only a test run shows the behaviour.
- Published number: formatting alone moves accuracy
- Sclar et al. (2023): performance differences "of up to 76 accuracy points when evaluated using LLaMA-2-13B", from prompt formatting alone.
- How a prompt registry does it
- MLflow: "Prompt versions in MLflow are immutable"; each has a commit message; an alias is "a mutable named reference", such as production, for "A/B testing and roll-backs".
- What one prompt release holds
- Full text and version · author and commit message · reviewer · model version tested with (A2) · eval score and test-set version · label and when it moved.
- Measure it
- Live answers whose trace names a prompt version (target: all) · prompt edits live without a test run (target: none) · minutes to roll back.
- Watch out
- Prompts typed into an admin screen with no history · one prompt copied into three services · tested on one model, run on another. The 63 is our example.
- Sources
- Sclar et al., arXiv 2310.11324 (2023) · MLflow Prompt Registry docs · The Register and AP, 16 May 2025 · all read 21 Nov 2026.
What happens in the prompts as code animation, step by step?
- The refund bot cooks every answer from a recipe card: its prompt. "Answer briefly. Always state the conditions." Yesterday's 100 answers all pass.
- 6 p.m.: someone changes one word in pencil, "briefly" → "in one line". No review, no test, no version number.
- Your turn: of tomorrow's 100 refund answers, how many will change? Tap a guess.
- All 100 change, and most drop the conditions (our example). In a published test, changing only a prompt's formatting moved one model's accuracy by up to 76 points.
- Now the same edit as code: it becomes a new card, v42, filed behind v41. A reviewer stamps it, a test run fails it, and v42 never goes live.
- Live is a clip on one card. If a bad card slips through, sliding the clip back to v41 is the rollback. Next: same recipe, different inputs.
What everyday example explains prompts as code?
A recipe card edited in pencil by whoever walks past. The card is the prompt, the cook is the model, every dish is an answer; a pencil edit leaves no old card to return to, while a box of dated, tabbed cards with a reviewer's stamp and a "live" clip lets the kitchen go back to yesterday's card.
Why should a team care about prompts as code?
Whoever can edit the prompt can change every answer the feature gives; deciding who may edit it, what test it must pass and how fast it can be rolled back is a release decision, and it belongs in the same pipeline as code.