Version Control for Prompts
This lesson explains how prompts are stored as versioned files, which file formats are used, how pull requests evaluate prompt changes, and how prompt versions are released and traced.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why prompts are stored as files in Git.
- Describe the Prompty file format.
- Describe automated evaluation of prompt changes.
- Explain how prompt versions are traced and rolled back.
Prompts as files
A prompt embedded as a string in application code is hard to find, review and test, and changing it requires a code release. Storing each prompt as a file in Git, with its model settings, makes it a first-class artifact with history, review, tests and rollback. The application loads the file at start-up or build time and fills its placeholders at run time.
prompts/
support_answer/
system.jinja2 # system message template
settings.yaml # deployment, temperature, max tokens, response format
examples.jsonl # few-shot examples
ticket_classifier/
classifier.prompty
eval/
datasets/support_v4.jsonl
thresholds.yamlPrompt file formats
Two common approaches are plain template files and Prompty. A Jinja template holds the prompt text with placeholders and logic, and a separate settings file holds the model configuration. Prompty is an open file format that puts both in one Markdown file: YAML front matter with the name, model configuration, parameters and sample inputs, followed by the templated messages.
---
name: ticket_classifier
description: Classify a support ticket into one category.
model:
api: chat
configuration:
type: azure_openai
azure_deployment: chat
parameters:
temperature: 0
max_tokens: 20
sample:
ticket: My card was charged twice for one order.
---
system:
Classify the customer's ticket into exactly one of: billing, delivery, account, product, other.
Reply with the category name only.
user:
{{ticket}}Whatever the format, the important properties are the same: the file holds everything that defines the prompt's behaviour, contains no secrets or customer data, and can be loaded both by the application and by evaluation scripts.
Review and automated evaluation
Prompt changes go through pull requests. A GitHub Actions workflow triggered by changes under prompts/ runs the evaluation dataset against the changed prompt, compares the scores with the thresholds and with the main branch, posts a summary to the pull request, and fails the check if quality or safety falls below the thresholds. Branch protection then prevents merging a regression.
on:
pull_request:
paths: ["prompts/**", "eval/**"]
permissions:
id-token: write
contents: read
jobs:
evaluate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- run: pip install -r eval/requirements.txt
- run: python eval/run_eval.py --prompt prompts/support_answer --data eval/datasets/support_v4.jsonl --thresholds eval/thresholds.yamlReviewers see both the textual change and its measured effect, which turns prompt review from a matter of opinion into a decision based on evidence.
Releasing and tracing prompt versions
A merged prompt reaches production through the same release process as code: built into the application package or container image, or published to a configuration store such as Azure App Configuration with a version label, so that the application loads a specific version. Releases are tagged in Git, such as support-prompt-v12.
- Record the prompt version (tag or commit hash) as an attribute on every trace and in evaluation results.
- Roll back by redeploying the previous tagged version, or by switching the configuration label, rather than editing text under pressure.
- Keep the evaluation dataset versioned in the same repository, so a prompt version and the data it was evaluated on stay together.
- Agent definitions, which include instructions and tool configuration, are versioned the same way.
Who changed the prompt?
An assistant's answers became less accurate on Tuesday. Its system message is stored in an application setting that several engineers can edit in the portal, and nobody remembers changing it. The team wants every prompt change reviewed and tested, and the ability to roll back in minutes.
Move the system message into a prompt file in Git, with its settings, and remove the ability to edit it in the portal. Add a pull request workflow that runs the evaluation dataset and blocks merges below the thresholds. Release prompts with tagged versions and record the version in traces, so a quality change can be linked to a commit, and roll back by redeploying the previous tag.
Turning on activity logs for the application setting would show who changed it next time, but not test the change. Restricting portal access to one engineer reduces the number of editors without adding review or tests. Copying the prompt into a wiki is documentation, not version control.
What does a Prompty file contain in addition to the prompt messages?
Show answer
Model configuration, such as the deployment and parameters, and metadata and sample inputs, in a YAML front matter section, so the prompt and its settings are versioned together.
Exam Tips
Remember for the exam
- Store prompts as files in Git with their model settings, never as untracked strings or settings.
- Prompty puts model configuration and templated messages in one file; Jinja templates are an alternative.
- Pull request workflows evaluate changed prompts and block regressions.
- Tag prompt releases, record the version in traces, and roll back by redeploying a tag.