Skip to content
AgenticAIWiki
  1. Learn
  2. Part 2
  3. 15. Prompt chaining and multi-pass review
  4. 15.4

Lesson 15.4 · 4 of 5 · 4 min read · Reviewed 24 Nov 2026

Versioning and testing prompts

By the end, you can

  • Version prompts like code.
  • Test prompts automatically before they ship.

Prompts are code. They change behaviour as much as any function, so treat them that way.

Version them

  • Keep prompts in git, in files next to the code that uses them.
  • Review changes in pull requests, with the evalEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. results attached.
  • Give each prompt a version number or use the commit hash.

Test them

  • Run the prompt test set (15.3) in CIContinuous integration (CI): Automatically building and testing code on every change, usually in a hosted pipeline. on every change.
  • Block the merge if the score drops below a threshold, just as you would for failing unit tests. Chapter 20 shows how to set those gates.

Trace them

Log the prompt version with every output. When a complaint comes in, you can see exactly which prompt produced the reply, and compare with the version before.

Model changes count too

Upgrading the model is a prompt change in effect. Run the same eval before switching.

Key points

  • Store prompts in version control, not in a dashboard or someone's notes.
  • Run the prompt test set in CI on every change, and block merges that lower the score.
  • Record which prompt version produced each output, so you can trace problems later.
Hands-on labOn your own machine

Gate prompt changes in CI

Store a prompt in git and make CI run its test set on every change, blocking merges that lower the score.

You will have: A repository with a versioned prompt file, an eval script and a CI workflow that fails when the score drops below a threshold.

Steps

  1. In a practice repository on your own machine, move the prompt into a file such as prompts/support_v1.txt and commit it.
  2. Write a small eval script that loads the prompt, runs your test cases and exits with a non-zero code if the pass rate is under your threshold. Read any API key from an environment variable, never from the file.
  3. Add a CI workflow (for example GitHub Actions) that runs the eval script on every pull request that touches prompts/, with the key stored as a CI secret.
  4. Open a pull request that deliberately weakens the prompt and confirm the check fails and blocks the merge.
  5. Log the prompt file name or commit hash with every output your app produces.

Done when

  • A pull request that lowers the score shows a failing check.
  • A pull request that keeps or raises the score passes.
  • Every logged output records which prompt version produced it.
  • No key appears in the repository; it lives only in environment variables and CI secrets.

Docs: GitHub Actions documentation · Define success criteria and build evaluations (Claude docs)

Quick checkA support bot's quality dropped last week and nobody knows what changed. What practice would have prevented the mystery?
How sure are you?
Pick an answer and how sure you are