Developing a prompt versioning system for LLMs

Edits to templates directly in the live environment break output, and it is already impossible to tell which version worked yesterday. We set up prompt versioning turnkey: a version registry, rollback in minutes, and analysis of discrepancies between environments. The publication policy reduces the time to release changes and eliminates blind edits.

AI Development Areas

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Prompt versioning: what breaks without version control

A prompt is not "text for the model" but part of the product logic: it defines the response format, refusal rules, tone, and boundaries of acceptable topics.

At the same time, it most often lives outside version control — in an admin field, a spreadsheet cell, an environment variable, or directly in the handler code. As soon as there is more than one such revision, system behavior stops being reproducible.

The most costly thing is untracked edits directly in production.

Someone changes the wording to fix one unsuccessful response, and it goes through neither review nor history: a week later no one can say which revision is currently running or why the share of correct responses changed. Rollback is impossible — there is nothing to roll back to, the previous state was not saved.

The second class of failures is divergence between environments. A test environment validated one revision of the template, while production runs another: some changes were missed, some went directly to production. Tests are green, but users get a different result.

Response quality regression in such a scheme is not diagnosed: it is clear that things got worse, but there is no link between the text change and the metric.

A separate pain point is multiple templates for one task: short for chat, extended for a document, compressed for export. Without template version control, they are edited separately, and the logic diverges in small details that are noticed only during acceptance.

Below we look at how this is addressed: template revisions, environment binding, change history with author and quality metric for each revision.

What a version registry provides: rollback, stability, traceability

A prompt stops being a string in someone else's branch and becomes an artifact with a history: each edit is a separate version with author, date, and reason for change. There is a single source of truth — the registry, from which the build takes the text.

Previously, working wording lived in notes, in code, and on an analyst's machine at the same time, and no one could say what exactly was responding to the user right now.

Change rollback time drops from tens of minutes to seconds: reverting is done by switching the pointer to the previous version, not by manually restoring text under load.

If a new wording breaks output, the on-call engineer restores the previous one in a single operation and without stopping the service — comparable to rolling a build back to the previous release.

Reproducibility of model responses rests on the request being linked to the exact prompt version and fixed output parameters.

Re-running the same input on the same version produces a matching result, and discrepancies become explainable: it is clear which edit caused them, rather than "the model is answering differently today."

Incident analysis turns into reading a log: we pull up which version was responding at the time of the complaint, diff it with the previous one, and find the specific change.

A separate class of failures caused by environment desynchronization goes away — when the test environment has one version and the production environment has another, and the discrepancy surfaces only through a customer request. Such cases stop being a blind search: every response has a version to which it can be linked.

Prompt versioning: comparing approaches and operating modes

Choosing an approach to prompt versioning comes down to two decisions: where request templates are stored and how a new version reaches the product. This determines the speed of edits, rollback depth, and the ability to compare two versions on live requests rather than by eye.

Industry practice is collected in the open Prompt Engineering Guide — we use it as a reference, but select the scheme for your stack and processes.

Option When it fits Limitations
Templates next to code One product, small team, edits go through review Publishing a prompt equals an application release, and there is nowhere to compare versions
Template registry with metadata Multiple products or teams, audit, tags, and rollback are needed Requires infrastructure and discipline: without a test set, the registry quickly turns into a dump
External management service Fast start and version switching without a release are needed Vendor dependency, restrictions on custom checks and data handling

Publication modes and test environment

The development environment and test environment are separated by roles: in the first, a version is assembled and run against a set of reference requests; in the second, behavior is confirmed on real scenarios.

Promotion to the production environment happens via an immutable tag, while intermediate versions remain in the registry — rollback takes minutes instead of a release cycle.

The main limitation of any approach: without quality metrics and a test set, version history guarantees nothing. Prompts are edited more often than code, so a registry only lives when each version is tied to a verification result, not to the edit date.

Implementation: from template audit to publication policy

From a text file with a prompt to a managed artifact is a path of several steps, and order matters more than speed here. We start with inventory, then define branching rules and the registry, and only after that enable automated checks. Below is how this sequence looks in a project.

  1. Audit of existing templates. We collect prompts from everywhere: from code, service settings, spreadsheets, and chats. We remove duplicates, mark versions that no one maintains anymore, and build a map — which template is called where and what will break if it is edited.
  2. Branching scheme. We agree that experimental edits live separately from the working branch, and each change receives a semantic version label. The rule is simple: changing wording is a new version, not "fixed directly in production."
  3. Registry setup. Prompts are stored as files next to code, together with invocation parameters and a binding to a specific version. Then the same logic does not spread across three services in four variants.
  4. Verification on a reference set. We collect real cases with expected responses and run the new version against the previous one: match rate, refusals, behavior on rare requests. The release decision is made based on numbers, not on a feeling that "it got better."
  5. Publication policy. We define who releases a version and what is mandatory for that: checks, change review, label, and log entry. We keep the policy short — a long one gets bypassed.
  6. Rollback plan. The pointer to the active version switches without a rebuild, so returning to the previous one takes a single operation. We describe rollback conditions in advance: degradation in quality metrics or an increase in the refusal rate.

We hand over the system together with training for the customer's team: how to add a case to the reference set, release a version, and roll back. We demonstrate on their own templates so that support can continue without us.

What we hand over: schemes, access policies, procedures

The project ends not with a demonstration but with the moment when your team independently releases a new template version and rolls it back without us.

Therefore, along with the working solution, we hand over the artifacts that prompt versioning then runs on: an engineer opens the document and acts according to it, without assembling context from chat.

  • Prompt registry configuration — version storage scheme, naming rules, binding a version to an environment tag, and retention policy for recent builds: the registry does not grow uncontrollably, and rollback remains possible.
  • Environment scheme — the path of a template from the development test environment to the production environment, mandatory checks before promotion, and tag correspondence between environments.
  • Template access policies — roles of author, reviewer, and release engineer, who is allowed to change production templates, mandatory review, and prohibition of edits bypassing the registry.
  • Release policy — publication procedure: pre-release checks, staged rollout to a share of traffic, stop criteria, and the condition for full promotion.
  • Rollback policy — returning to the previous version in a single operation, who makes the decision, how the reason is recorded, and what to do with accumulated evaluations.
  • Team instructions — how to add a template, link it to a set of test examples, and read the quality metrics report.
  • Ownership matrix — who is responsible for the template, registry, and release, where approval points are, and who receives notification during rollback.

Case study: environment discrepancies eliminated, rollback in minutes

The team is developing a conversational assistant based on OpenAI models: about a hundred text instructions were edited directly in the service configuration, without a separate storage.

The test environment and production environment were configured manually, so discrepancies were noticed from operator complaints rather than checks.

Measurements two weeks before work started: the share of discrepancies between the test and production environments was about 30%, returning to the previous revision took 40 minutes of manual reconciliation, and disputed edits were 8-10 per month.

What was changed

The instructions were moved to versioned storage: each revision is a separate record with author, linked task, reason for edit, and date.

They reach environments only through verification — first the test environment, then production, with both environments assembled from one source and differing only by explicitly defined parameters.

Change history is stored in full, and edit attribution is restored in seconds: you can see who changed the wording and why.

What changed

The share of discrepancies between the test and production environments fell below 3% — these are isolated cases caught by automatic reconciliation before release.

Returning to the previous revision takes about two minutes: the version is selected from history and applied with one command, without manually restoring text.

Disputed edits disappeared as a class — every change has an author and rationale, so the question "who changed the wording" is closed with a link to a log entry.

How a managed template release differs from edits in the live environment

Direct editing in the live environment seems faster: the text changes in the interface, and the model's next reply follows the new instruction. The price is the absence of a rollback point and a link between revision and metric.

A drop in the share of correct responses surfaces through complaints, and the cause is sought by going through recent changes.

In a managed release, an edit becomes a new immutable registry revision: a snapshot of the text with a content hash, author, time, binding to the model version and invocation parameters.

The live environment receives not the text directly but a reference to a tag — tagging revisions makes every state reproducible.

Pre-publication verification runs on a held-out sample of real requests: the new revision is compared with the current one by share of correct responses, format compliance, and refusal rate.

A discrepancy above the defined threshold blocks the rollout, rather than "going to the live environment, we'll see."

Staged rollout distributes traffic in steps: first a narrow share, then half, then the entire stream. Metrics at each step are compared with the baseline revision, and if they go beyond boundaries, traffic automatically returns to the previous tag. Rollback is a pointer switch, not searching for and editing text.

The main thing changes in the process: an edit stops being an action in the interface and becomes a decision with history and rationale. The question "why is it worse today" is answered by comparing metrics of two tags, not by reconstructing chronology from memory.

Technical concerns: common questions before starting

Before starting, the same technical concerns come up: how a prompt registry will coexist with existing code, what to do with change history scattered across repositories and spreadsheets, and whether teams will start interfering with each other in a shared storage. Below are brief answers to each point.

Will invocation code have to be rewritten?

No. The registry serves the prompt by identifier and version, while the application entry point remains the same.

We implement in stages: first one scenario, the rest work as before — switching via a configuration flag, and rollback returns the previous source without code changes.

What to do with already accumulated change history?

Existing prompts are loaded in batch: each revision is assigned an author and date based on version control system data, and unrecoverable ones are marked as the starting point. After that, history fills itself on every save.

How do multiple teams work in one registry?

Storage is divided into spaces by product or team: writing is limited to one's own space, reading another's is done as needed. A shared template is fixed once, and its change is visible to everyone who depends on it.

Which template option should be chosen?

Free text is faster at the start but does not validate substitutions. A template with variables forces you to describe input fields, but a missing parameter is caught before launch. In practice, a combination is used: short requests as text, critical scenarios as a template.

What are the risks of implementation?

The main one is dependency on the registry. It is addressed by a local copy of the last working version on the application side: if the service is unavailable, the system continues to run on the fixed snapshot and does not fail.

Let's discuss the task and send an estimate with a work plan

To make the prompt versioning estimate based on facts rather than assumptions, a short snapshot of the current environment is enough. Send what you have at hand — even a partial set of input data allows us to name the scope of work and identify bottlenecks before starting.

For the estimate, we will need:

  • a list of prompts and their purpose — from it we calculate the registry scope and the number of versions per template;
  • 3-5 working prompts as they are, together with the edit history for the last cycle;
  • a diagram of the environments where prompts are applied and the procedure for promoting them between environments;
  • a description of access: who edits, who approves, who reads logs and quality metrics;
  • audit and rollback requirements — what exactly needs to be restored and how quickly;
  • constraints on implementation stage timelines and upcoming releases so that the plan fits your calendar.

On the call, we will discuss the interaction procedure, the format for reviewing changes, and how prompt versions are linked to code, models, and metrics.

The implementation plan will include version storage and indexing, approval rules, automated pre-release checks, and rollback policy.

Describe the task in free form — we will return with an estimate and a work plan.