Your chatbot worked fine on Tuesday. On Wednesday it started refusing normal requests, and nobody can say what changed. The prompt lives in a vendor dashboard, or in a config file that nobody commits, or in a Slack thread from three weeks ago. There is no history to read and no way back. Teams that version prompts like code do not have this problem. A prompt template is text, and text is exactly what Git was built to track.
Why you should version prompts like code
A prompt is not a comment in your code. It is an instruction that shapes what your product says and does. One word can change the tone, one added sentence can change which tool an agent calls, and one deleted line can remove a guardrail that kept the bot from inventing prices. When behavior changes, you need the same answer Git gives you for code: what changed, when, and who changed it.
Version control also turns prompt work into a team activity instead of a solo one. A second person can read a diff before a prompt goes live. A new hire can read the history and see why the refund policy line exists. An incident review can point at a specific commit instead of guessing. And when a model update changes how your prompt behaves, the history shows which prompt version was running with which model, so you can separate a prompt problem from a model problem. If you want prompts that hold up across model updates, read our guide on system prompts that survive model updates.
What a prompt template repo looks like
Start with a folder called prompts, one file per template, written in plain text or Markdown. Each file holds the template with placeholders for variables, plus a small header of metadata at the top: the model it was written for, the temperature, the version, and a short note on what changed. Keep the template and its metadata in the same file so they cannot drift apart.
prompts/ support-reply.md # model: gpt-4o, temp: 0.3, version: 1.4.0 refund-policy.md onboarding-assistant.md tests/ evals/support-reply.json
Variables use double curly braces, like {{customer_name}} or {{order_id}}. Your application loads the template, fills in the variables, and sends the result to the model. It is the same layout as a config directory, and any developer on the team already knows how to read it. This is prompt template versioning at its simplest: one file, one history, one source of truth.
Two rules keep the repo honest. First, the prompt that runs in production must come from the repo, not from a dashboard edit or a pasted string in a chat message. If production can run a prompt that Git has never seen, the history is a fiction. Second, never commit API keys or customer data in a prompt file. Secrets belong in a vault or environment variables, and the repo should fail a pre-commit check if a key slips in. Our checklist on keeping secrets out of AI coding assistant prompts covers the checks worth adding.
Semantic versioning for prompts
Semantic versioning works for prompts once you define what a breaking change means. For a prompt, a breaking change is any edit that changes the output for the same input in a way users would notice. A wording fix that keeps answers the same is a patch. A new variable or an added capability is a minor version. A rewrite of the instructions, a changed output format, or a removed guardrail is a major version.
So version 1.4.0 to 1.4.1 means a typo fix. Version 1.4.0 to 1.5.0 means the prompt gained something, like a new {{language}} variable. Version 1.4.0 to 2.0.0 means the answers changed and downstream code or users should expect it. Write the version in the file header and tag the release in Git, so version 2.0.0 of the prompt maps to a commit you can check out at any time. If your team is new to the scheme, our semantic versioning explainer walks through when to bump major, minor, or patch.
One warning: semantic versioning prompts a useful question, does this edit change the answers, but the answer is a judgment call, not a measurement. Two reviewers can disagree about whether an edit changes outputs. That is fine. The version number is a signal, and the eval suite described below is the check that backs it up. Do not let arguments about 1.5.0 versus 2.0.0 block a release; pick the higher number when in doubt.
Branching and pull requests for prompts
Treat a prompt change the way you treat a code change. Create a branch, edit the template, open a pull request. The PR description should say what changed and why, and it should include before-and-after outputs for the same inputs. A reviewer reads the diff, runs the same inputs, and checks that the new outputs are actually better, not just different.
This git workflow for prompts borrows the branching model your team already uses for code. A short-lived feature branch per prompt change keeps main deployable at all times. Main holds the prompts running in production right now. A release tag marks the set of prompts that shipped together, so a rollback means checking out a tag, not hunting through a dashboard.
Small teams sometimes skip the PR step because the change looks trivial. That is exactly when review matters most. A one-line edit to a system prompt can change every answer the product gives. The review is cheap and the blast radius is large. If your team is still debating branching models, our comparison of GitFlow versus trunk-based development explains the trade-offs.
Testing prompts before they ship
A prompt change without a test is a guess. Keep a small eval set next to each template: ten to thirty inputs with the answers you expect. Some are exact matches, like a specific refusal for a disallowed request. Most are checks a human or a second model can grade: does the answer mention the refund window, does it cite the order number, does it stay under a word limit.
Run the evals in CI on every pull request that touches the prompts folder. The check does not need a perfect score. It needs to show the diff: which cases improved, which got worse, and by how much. A PR that fixes five cases and breaks two is a decision a human makes with the numbers in front of them, not a surprise discovered in production. Our guide on testing AI features with eval sets and human review shows how to build a regression set and keep it small enough to run on every commit.
Keep the eval set honest. When you find a bad output in production, add that input to the eval set first, then fix the prompt. The set grows from real failures instead of imagined ones, and the same failure cannot come back quietly in a later edit. This is prompt version control doing the job it exists for: the history shows the failure, the fix, and the test that prevents a repeat.
Rolling back a bad prompt
Every prompt change should be reversible in minutes. Because the prompt is a file in Git, a rollback is a revert or a checkout of the previous tag, followed by the same deploy step you already use. No dashboard spelunking, no copy-paste from a screenshot, no guessing which version was live at 2 pm.
Decide the rollback path before you need it. Write it down in the repo readme: which command restores the last good version, who can run it, and how you confirm the old prompt is live again. The teams that recover fast are the ones that practiced the rollback when nothing was on fire.
Mistakes that break prompt versioning
- Storing prompts only in a vendor dashboard. If the dashboard is the only copy, there is no history, no diff, and no rollback.
- Versioning the prompt but not the model and settings. A prompt that worked at temperature 0.2 can behave differently at 0.7. Record the model, temperature, and other settings with the version.
- One giant file for every prompt. Diffs become unreadable and two people editing different prompts create conflicts for no reason.
- Committing real customer data in test examples. Eval fixtures should use made-up names and order numbers.
- Skipping the changelog. A one-line note per version, written in the commit message or a CHANGELOG file, is what makes the history readable six months later.
Start small. Move one prompt into a file, commit it, and tag it version 1.0.0. Add an eval set with ten inputs. Open the next prompt change as a pull request and ask one teammate to read the diff. That is the whole workflow, and it is enough to answer the question that started this article: what changed, and how do we get back.