Home / Insights / Generative AI and LLMs

Generative AI and LLMs

Prompt Management and Versioning for LLM Apps: Treating Prompts Like Code

In an LLM application the prompt is part of the program. Changing one sentence can alter behaviour for every user, so prompts need the same discipline as code: version control, review, automated tests and controlled releases.

TopicsGenerative AI and LLMsQA and Software Testing

Key takeaways

  • Treat the prompt, the model version and the generation settings as one versioned unit; a change to any of them is a release.
  • Keep prompts in the repository by default, and move to a prompt registry only when non-engineers need to edit them or you need runtime switching, with the same review and test gates either way.
  • Every prompt change should run against an evaluation set before release; without it you are guessing whether the change helped or hurt.
  • Pin model snapshots and plan for provider deprecations: OpenAI shut down text-davinci-003 and other InstructGPT models on 4 January 2024, six months after announcing it.
  • Log the prompt version with every request so that support, debugging and audits can trace any output back to the exact instructions that produced it.

Most LLM features start life as a prompt pasted into a code file or a vendor playground. That is fine for a prototype. It becomes a problem when the feature reaches real users and several people start editing the prompt to fix individual complaints. Within weeks, nobody can say which version is live, why a sentence was added or whether last Tuesday’s change caused the rise in support tickets.

This article is for CTOs, engineering managers and product owners running LLM features in production or about to. I set out how to store, version, review, test and release prompts, and how to choose between keeping them in code and using a prompt registry. It reflects the way we build on our LLM application development projects, where prompt versioning, regression testing and monitoring are part of the delivery rather than an afterthought.

Why do prompts need the same discipline as code?

A prompt is executable specification. It tells the model what role to play, what format to return, what to refuse and how to use the context you supply. Unlike code, a small wording change can have broad, non-obvious effects, and the output is probabilistic, so a single manual test proves little.

What goes wrong without prompt management

  • Silent regressions: a change that fixes one complaint breaks formatting or tone for other cases.
  • Untraceable outputs: when a customer disputes an answer, you cannot reproduce it because you do not know which prompt and model produced it.
  • Drift between environments: staging and production run different prompts because someone edited one in a dashboard.
  • Provider changes: a model update or deprecation alters behaviour even though your prompt did not change.
  • Security gaps: instructions meant to constrain the model are weakened by an edit nobody reviewed.

Provider guidance points the same way. Anthropic’s prompt engineering overview says that before working on a prompt you need clear success criteria, ways to test empirically against them, and a first draft to improve. That is a software process, not copywriting.

Action: list every prompt running in production, who can change it and how. If the answer for any prompt is “anyone, directly in production”, fix that first.

What exactly should you version?

Versioning only the prompt text is not enough. The behaviour your users see comes from several inputs, and a change to any of them can alter results.

The versioned unit

  • Prompt templates: system instructions, user message templates and any few-shot examples.
  • Model identifier: the specific model snapshot, not a moving alias, where the provider offers one.
  • Generation settings: temperature, maximum tokens, stop sequences and any response format option such as JSON mode.
  • Tool or function definitions: names, descriptions and parameter schemas the model can call.
  • Retrieval configuration: for retrieval-augmented features, the number of passages, filters and how context is inserted into the prompt.
  • Output parsers and validators: the code that checks and transforms the model’s response.

Bundle these into a single configuration with one version identifier, for example claims-summary@1.8.0. Use semantic versioning loosely: a major version for changes in output contract, minor for behaviour changes, patch for wording fixes that should not change outcomes.

Why model versions matter

Hosted models change and retire. OpenAI’s deprecations page records that in July 2023 it announced the retirement of text-davinci-003 and the other InstructGPT completion models, with a shutdown date of 4 January 2024, and earlier dated GPT-3.5 and GPT-4 snapshots have also been scheduled for retirement. Every such change is a forced release of your feature. If your prompt and model identifier are versioned together and you have an evaluation set, migrating is a measured project rather than a scramble.

Action: define the configuration schema for your versioned unit and make the application load it as a whole, never piece by piece.

Should prompts live in code or in a prompt registry?

This is the main architectural choice, and the answer depends on who edits prompts and how often.

ApproachHow it worksStrengthsWeaknessesBest for
Prompts in the repositoryTemplates as files beside the code, loaded at build or start-upPull-request review, CI tests, one deployment path, full history in GitEvery change needs a deployment; non-engineers depend on developersMost teams, especially early on and in regulated contexts
Prompt registry or management servicePrompts stored in a database or service, fetched at runtime by name and versionDomain experts can edit; instant switching and A/B tests; central view across appsSecond deployment path; risk of untested edits; runtime dependencySeveral apps sharing prompts, frequent content changes, mature evaluation
HybridRegistry for drafts and experiments; approved versions exported to the repository or pinned by IDFast iteration with controlled releasesMore process to maintainTeams with product or domain specialists who tune prompts

Rules that apply whichever you choose

  • Production loads prompts by explicit version, never “latest”.
  • Every version is immutable once published; changes create a new version.
  • Promotion from draft to production passes the same evaluation gate.
  • The application logs the version identifier with every request.

For example, a 40-person insurance broker building a claims summary feature might keep prompts in the repository for the first six months, then add a registry when its claims specialists want to adjust wording weekly. Treat this as an illustrative path rather than a rule: the trigger is who needs to edit, not company size.

Action: start with prompts in the repository unless you have a concrete reason not to, and write down the condition that would justify a registry.

How do you test a prompt change?

Testing is what turns prompt editing from opinion into engineering. The goal is to know, before release, whether a change improves the cases you care about without breaking others.

Build an evaluation set

  • Collect 50 to 200 representative inputs to start, drawn from real usage where privacy allows, plus known edge cases and past failures. Treat that range as a practical starting assumption that grows over time.
  • For each input, record what a good answer must contain or avoid, rather than a single exact expected output.
  • Include adversarial cases: attempts to override instructions, irrelevant requests and inputs containing embedded instructions.

Layer the checks

  1. Deterministic checks: valid JSON, required fields present, length limits, no banned phrases, correct language.
  2. Reference checks: key facts present, citations pointing to supplied sources, numbers matching the input.
  3. Model-graded checks: a separate model scores relevance or tone against a rubric, calibrated against human ratings.
  4. Human review: a sample of changed outputs reviewed by a domain expert before major releases.

Run the full set in CI for every prompt change and compare against the current production version, not against an absolute threshold alone. Because outputs vary, run important cases more than once or at low temperature, and look at score distributions rather than single results. Our article on testing AI features with evaluation sets and regression checks goes deeper into building and maintaining these sets.

Action: make a passing evaluation run a required check on any pull request or registry promotion that touches a prompt.

How should prompt changes be released and rolled back?

Even with good tests, production traffic is more varied than any evaluation set. Release prompt changes the way you would release a risky code change.

A release workflow that works

  1. Propose: a pull request or registry draft describing the problem, the change and the expected effect.
  2. Review: a second engineer or prompt owner checks the diff, including security-relevant instructions.
  3. Evaluate: automated evaluation against the current production version, with results attached to the review.
  4. Stage: deploy to a staging environment with realistic data and run smoke tests.
  5. Roll out gradually: send a small share of traffic to the new version behind a feature flag, then increase.
  6. Monitor: watch error rates, validation failures, user feedback and cost per request for the new version.
  7. Roll back fast: switching back is a configuration change to the previous immutable version, not an emergency edit.

Observability

Log, for every request, the prompt version, model identifier, token counts, latency and validation outcome. Store inputs and outputs according to your data retention policy, with personal data handled appropriately. When a user reports a bad answer, support should be able to find the request and see exactly which configuration produced it.

Action: add the prompt version to your request logs and dashboards this sprint, even before the rest of the workflow is in place.

What about security and governance?

Prompts often carry your main controls on model behaviour, so changes to them are security-relevant.

Prompt injection and instruction integrity

The OWASP Top 10 for LLM Applications lists prompt injection as LLM01 and notes that LLMs do not separate instructions from external data, so there is no fool-proof prevention within the model itself. Its recommended mitigations include least-privilege access for the model, human approval for privileged actions, clearly marking untrusted content and treating the model as an untrusted user. Prompt management supports these controls: you can review every change to the instructions that separate trusted and untrusted content, and test injection attempts in your evaluation set on every release.

Access and approvals

  • Restrict who can publish production prompt versions; editing drafts can be broader.
  • Require a second approver for changes to system instructions, tool definitions or safety-related wording.
  • Keep secrets, API keys and personal data out of prompt templates.

Fitting a wider risk framework

If your organisation uses the NIST AI Risk Management Framework, released in January 2023, prompt management maps naturally onto its Govern, Map, Measure and Manage functions: ownership and approval rules, documented intended use, evaluation results and controlled change with rollback.

Action: name an owner for each production prompt and record the approval rule for changes in your engineering handbook.

Implementation checklist

Use this as a 30-day plan for an LLM feature that is already live.

  1. Inventory all production prompts, owners and current editing paths.
  2. Move prompt templates into the repository or a registry with immutable versions.
  3. Define the versioned unit: prompt, model snapshot, settings, tools and parsers.
  4. Log the version identifier with every request.
  5. Build a first evaluation set from real cases, past failures and injection attempts.
  6. Add deterministic and reference checks to CI; add model-graded checks once calibrated.
  7. Introduce review and approval rules for production prompt changes.
  8. Release changes behind a flag with gradual rollout and one-step rollback.
  9. Track provider deprecation notices and schedule model migrations as releases.
  10. Review evaluation coverage monthly and add every new production failure as a test case.

If you are still choosing a model, our guide to evaluating GPT-4, Claude, Gemini and open models uses the same evaluation-set approach, and our piece on scoping an AI-first MVP covers how to keep the first release small enough to test properly.

Frequently asked questions

Do we need a dedicated prompt management tool?

Not at first. Prompts in your repository with pull-request review, CI evaluation and version logging cover most needs. A registry becomes worthwhile when non-engineers need to edit prompts regularly or several applications share them.

Can product or domain experts edit prompts safely?

Yes, if they edit drafts that must pass the same evaluation and approval gates as engineering changes before reaching production. Give them a way to run the evaluation set themselves so they see the effect of their changes.

How big should our evaluation set be?

Start with what you can build quickly from real cases and past failures, often a few dozen to a couple of hundred inputs, and grow it every time a new failure appears in production. Coverage of important scenarios matters more than raw size.

What happens when the model provider retires a model?

Treat it as a release. Run your evaluation set against the replacement model with your current prompt, adjust the prompt if needed, and roll out gradually. Versioning the model identifier with the prompt makes this routine.

Should we log full prompts and responses?

Log the version identifier always. Log full inputs and outputs only in line with your privacy and retention policy, with personal data minimised or redacted, because they often contain customer information.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Anthropic: Prompt engineering overview — accessed 9 November 2026. Guidance to define success criteria, test empirically and start from a first draft before iterating on prompts.
  2. OpenAI: Deprecations — accessed 9 November 2026. Retirement of text-davinci-003 and other InstructGPT models, announced July 2023 with shutdown on 4 January 2024, and scheduled retirement of dated chat model snapshots.
  3. OWASP Top 10 for LLM Applications 2023-24: LLM01 Prompt Injection — accessed 9 November 2026. Definition of direct and indirect prompt injection, lack of fool-proof prevention within the model, and recommended mitigations.
  4. NIST: AI Risk Management Framework — accessed 9 November 2026. AI RMF 1.0 release in January 2023 and its Govern, Map, Measure and Manage functions.

Do you know which prompt version produced your last customer complaint?

We can set up prompt versioning, evaluation sets and controlled releases for your LLM features, without slowing your team down.