Prompt Versioning: Versions, Labels and Rollback
Prompt versioning means storing every prompt change as an immutable, numbered version and pointing movable labels such as "staging" and "production" at versions. Applications resolve the label at runtime, so promoting or rolling back a prompt is a label change rather than a code deploy, and every evaluation result can be traced to the exact prompt that produced it.
Prompts behave like code: a one-word change can fix a bug or break a hundred cases. Yet many teams still keep them as strings in application code, edited in place, with no record of which wording produced which result. This article describes the version-and-label pattern most prompt tools have converged on, and how to tie it to evaluation. It belongs to the LLM evaluation guide.
The pattern: immutable versions, movable labels
- A prompt has a stable name, such as support.answer.
- Each save creates a new version (v1, v2, v3) that never changes. Store the system prompt, the template with its {{variables}}, a commit message and a content hash.
- Labels such as staging and production point at one version each. Moving a label is the only way to change what an application receives.
- The application fetches support.answer at label production at runtime, with caching.
- Rollback moves the label back to the previous version.
Step by step
- Move each prompt out of application code into the registry, as version 1, and point production at it.
- Change application code to resolve the prompt by name and label, with a short cache and a safe fallback if the registry is unreachable.
- Make every edit a new version with a short commit message saying what changed and why.
- Point staging at the new version and run your evaluation dataset against it; compare with the production version case by case.
- Promote by moving the production label only when the comparison passes. Record which run justified the move.
- If production quality drops, roll the label back and confirm that new traces carry the old version number.
# Resolve the production prompt at runtime (NexGen QA example)
curl -H "X-Api-Key: $NEXGEN_API_KEY" \
"https://app.qa-automation.com/api/v1/prompts/resolve/support.answer?label=production"Review diffs, not just outputs
Show a line diff between versions, including added and removed variables, in review. Many regressions are visible in the diff itself: a dropped constraint, a variable renamed in the template but not in the code, an instruction moved below a long example.
Common mistakes
- Editing a version in place, so old evaluation results no longer describe any prompt that exists.
- Hard-coding a version number in application code, which turns every promotion back into a deploy.
- Promoting on a handful of manual tries instead of a dataset run.
- Not logging the prompt version on each trace, so production issues cannot be traced to a change.
Prompt management in NexGen QA
NexGen QA's Prompts module stores immutable versions with commit messages, moves staging and production labels with one-step rollback to the previous version, shows a diff between any two versions including variable changes, and has a playground that runs a version on your own provider key with tokens, latency and estimated cost. Applications fetch a prompt by name and label with any organization API key; responses carry an ETag and a 60-second cache lifetime. Free includes 10 prompts; Pro has no prompt cap.
Frequently asked questions
What is prompt versioning?
Prompt versioning is storing each prompt change as an immutable numbered version, with labels such as staging and production pointing at versions, so applications fetch prompts by label and every result can be traced to an exact prompt.
How do you roll back a prompt?
Move the production label back to the previous version. Because the application resolves the label at runtime, no code deploy is needed. Confirm that new traces carry the old version number.
Should prompts live in Git or in a prompt registry?
Either works if versions are immutable and every result records the version. A registry with labels lets you promote and roll back without a deploy; Git keeps prompts next to the code that uses them.
Sources
NexGen QA puts AI evaluation (tracing, datasets and scorers, red teaming, human review, release gates and evidence) next to 35+ software testing modules, on your own model keys.
Related reading
More articles
- LLM Evaluation Metrics: Which to Use and When
The four families of LLM evaluation metrics (deterministic checks, reference similarity, judge-based scores and human ratings) and which to use for each task.
- How to Build an LLM Evaluation Dataset
What goes in a golden dataset for LLM evaluation, where cases come from, how many you need (with confidence intervals), and how to version and split it.
- LLM-as-a-Judge: How to Build a Judge You Can Trust
How LLM-as-a-judge works, how to write judge prompts, calibrate against human labels with kappa, and mitigate position, length and self-preference bias.
Published by the NexGen QA team at Techtonic Innovations LLC · About NexGen QA