Topic 1 of 5 · 4 min read
Prompts as versioned code with reviews
Goal: Move an inline prompt into a versioned prompt file with its model settings and a linked eval.
A prompt is behaviour, so version it like code: one file, one reviewed change, one eval run before it ships. The prompt text alone is not the unit. The model name, temperature, token limit, tool definitions and output schema change the result just as much, so they belong in the same file.
Check yourself · 1 of 3
Which of these belongs in the same versioned unit as a prompt's text?
Why it matters
A string buried inside a handler is invisible to review. Someone adds "be more friendly" on a Friday, the extraction format drifts, and nobody can say which commit did it. When the prompt, its settings and its tests live together, git blame answers "what changed" and a pull request answers "who agreed".
How to do it
- Move the prompt out of the code path. Put it in its own file (for example
prompts/support-reply.v3.yaml) and load it by name. - Store the whole bundle. Prompt template, model id, parameters, tool schemas and the expected output schema sit in one versioned unit.
- Give it a version. Either the git commit, or an explicit
versionfield you bump on every change, so logs can name it later. - Link an eval. The same pull request changes the prompt and shows the result of the regression set on the old and the new version.
- Review it like code. A reviewer reads the diff, the eval table and the sample outputs, not just the wording.
Prompt-management platforms such as Langfuse, LangSmith or a gateway's prompt registry let people edit and release prompts without a deploy. That is useful for non-engineers, but it moves the change outside your review. If you use one, keep the same rules: versions are immutable, a release is a label that points at a version, and every release needs an eval run first.
Before and after
// before: inline, unversioned, settings hidden elsewhere
const reply = await llm.chat("You are helpful. Answer briefly: " + question);
// after: loaded by name, bundle versioned, eval linked
const p = await prompts.load("support-reply"); // version 3, model + params inside
const reply = await llm.chat({ ...p.settings, messages: p.render({ question }) });
What goes wrong
- Only the text is versioned. The temperature or model changes in a config file and nobody connects it to the new behaviour.
- Edits in a dashboard go live at once. A typo fix reaches all users with no eval and no reviewer.
- The prompt file changes, the eval does not. The test set no longer covers the new instructions, so it passes while quality drops.
Examples
Inline prompt to prompt file
- const reply = await llm.chat("Summarise this ticket in 3 bullets: " + text);
+ const p = await prompts.load("ticket-summary");
+ const reply = await llm.chat({ ...p.settings, messages: p.render({ text }) });
# prompts/ticket-summary.yaml
version: 4
model: claude-sonnet-4-5-20250929
temperature: 0.2
max_tokens: 400
template: |
Summarise this ticket in 3 bullets. Quote the order id.
{{text}}
eval: evals/ticket-summary.jsonl
The model, temperature and eval path now change in the same reviewed commit as the wording.
A dashboard edit with no review
A product manager edits the live prompt in a prompt platform to add "always apologise first". It is released instantly. Classification prompts that shared the template start returning apologies instead of labels. With a release label that only moves after an eval passes, the change would have been caught before any user saw it.
Key points
- Version the whole bundle: prompt text, model id, parameters, tool definitions and output schema.
- Keep prompts in files or a registry that records an immutable version for every change.
- A prompt change goes through review with an eval result attached, like any code change.
- Platforms that edit prompts without a deploy need the same gates: immutable versions, labels for releases and an eval before release.
- Name each version so logs and traces can refer to it later.
Common mistakes
- Versioning the prompt text but not the model, temperature or tool definitions.
- Letting a prompt platform release edits straight to production with no eval or reviewer.
- Changing a prompt without rerunning the eval set that covers it.
- Keeping several near-identical prompt copies in different services.
Check yourself · 2 of 3
A teammate fixes a typo in the live prompt through a prompt platform's dashboard and it goes to all users at once. What is the main problem?
Check yourself · 3 of 3
A pull request changes the prompt in prompts/triage.yaml. Which addition makes it reviewable?
Practice items, not counted towards your mastery.
Start here
- Prompt management (Langfuse docs) (opens in a new tab)DocsFree
How a prompt-management tool versions prompts, labels releases and links each version to traces.
- Model deprecations (Claude docs) (opens in a new tab)DocsFree
The real retirement schedule format: status, deprecation date, retirement date and the suggested replacement.
- Deprecations (OpenAI API) (opens in a new tab)DocsFree
OpenAI's list of shutdown dates with recommended replacements, to plan a migration from.
More for this topic
- Feature Toggles (martinfowler.com) (opens in a new tab)ArticleFree
Release toggles let you switch behaviour by configuration, which is the mechanism behind fast prompt rollback.