Paj Digital Labs
All articles
AI & Automation

Prompt Versioning and Evals: Treating Prompts Like Production Code

A prompt edit can silently break a feature that worked yesterday. How to version prompts, build a small evaluation set, and catch regressions before your users do.

Paj Digital Labs 2 min read
Robotic gripper sorting components on a laboratory workbench
Editorial illustration · AI & Automation

Someone tweaks a prompt to fix one bad answer. The fix works. Two weeks later, support notices the summarisation feature has started dropping dates from every summary. Nobody connects the two, because nobody knew the prompt changed.

Prompts are code. They change behaviour, they can break things, and they deserve the same discipline.

Keep prompts in the repository

Prompts hidden in a database row or pasted into a dashboard cannot be reviewed, diffed or rolled back. Store them as files next to the code that uses them:

text
prompts/
  summarise-ticket/
    v3.md
    v4.md
  classify-intent/
    v2.md

Every change goes through a pull request, like any other code change.

Log the version with every call

Each model call should record the prompt name, prompt version, model name and model version. When an output looks wrong, you can see exactly which combination produced it.

Build a small evaluation set

You do not need thousands of examples. Start with 30–50 real inputs that represent normal cases, edge cases and past failures. For each, write down what a good output must contain.

json
{
  class="text-code-string">"input": class="text-code-string">"Customer says order #4412 arrived damaged on 3 Oct...",
  class="text-code-string">"must_include": [class="text-code-string">"4412", class="text-code-string">"damaged", class="text-code-string">"3 Oct"],
  class="text-code-string">"must_not_include": [class="text-code-string">"refund approved"],
  class="text-code-string">"max_words": 60
}

Add every production failure you find to the set. Over time it becomes a precise description of what your feature must do.

Use the right kind of check

| Check type | Good for | |---|---| | Exact / contains | Required facts, IDs, labels | | Schema validation | Structured outputs | | Length and format | Summaries, titles | | Model-graded rubric | Tone, helpfulness, faithfulness | | Human review | Final judgement on a sample |

Model-graded checks are useful but imperfect. Keep the rubric narrow ("Does the summary mention every date in the input? yes/no") rather than "rate quality from 1–10."

Run evals on every change

Changing the prompt, switching models, or updating retrieval should all trigger the eval run. Compare the new pass rate against the current version and look at every case that flipped from pass to fail.

text
classify-intent  v2 -> v3
  pass: 44/50 -> 47/50
  newly failing: case_17, case_31
  newly passing: case_04, case_22, case_40, case_45, case_49

A higher score with new failures still needs review — those two failing cases might matter more than the five fixed ones.

Pin model versions

Model aliases that automatically move to newer versions can change behaviour under you. Pin a specific version in production, and upgrade deliberately, with an eval run, like any dependency upgrade.

Roll out gradually

For high-traffic features, send a small share of traffic to the new prompt version first and compare real outcomes — user ratings, retries, escalations — before switching fully.

Keep it lightweight

None of this requires a platform. Prompts in files, a JSON eval set, and a script that runs the cases and prints a comparison table will catch most regressions. Add tooling once the simple version becomes painful.

The teams that ship reliable AI features are not the ones with the cleverest prompts. They are the ones who notice when a prompt gets worse.

Paj Digital Labs

The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.

Related reading