Best tools to test LLM prompts in CI

By

Last updated

The best tools to test LLM prompts in CI look at the answers, not only the unit tests: checks you write for shape and behaviour, plus ClearRun when an answer starts sounding surer than its reasoning. To add LLM regression testing to GitHub Actions, and to test prompt changes before deploying, keep a small fixed sample and run one scoring step on the pull request.

You changed the prompt and bumped the model version in the same pull request. Unit tests passed, because unit tests don't read the answers. Two weeks later, support noticed the feature stating things flatly that it used to hedge. This guide covers how to put a check in CI that looks at the answers themselves, runs only when it matters, and doesn't eat the CI budget.

1. Decide what a regression means for your feature

Write down the ways your feature can get worse that a user would notice. Common ones:

  • Shape: the output stops being valid JSON, or a field disappears. Check this in code.
  • Behaviour: it stops routing refund requests to a person. Check with assertions on known cases.
  • Tone of certainty: it starts stating guesses as facts. This one is hard to catch with string checks. It is the gap ClearRun is built for.

2. Keep a small, fixed sample set

Start with a small fixed set taken from real traffic and past incidents (the same advice appears in lucaberton.com's 2026 guide and the scalar.com MCP testing guide). Every production incident should add a case. Save the answers your feature produces for those cases as .txt or .md files, either generated in an earlier CI step or committed to the repo.

How to test prompt changes before deploying

Limit the job to pull requests that touch your prompts folder, model settings or the sample answers. That keeps cost predictable and stops unrelated pull requests from waiting on it.

How to add LLM regression testing to GitHub Actions

Add the confidence check as one step:

- name: Score sample answers with ClearRun
  run: npx -y @clearrun/cli@1.2.0 score
  env:
    CLEARRUN_API_KEY: ${{ secrets.CLEARRUN_API_KEY }}

Put the folder and your threshold in clearrun.config.json. The threshold is a number you choose from 0 to 100. ClearRun doesn't pick one for you.

What you get back: a pass or fail per run (exit code 0 means every answer passed; exit code 1 means an answer fell below your line or the run failed), JSON output with each answer's score and verdict id to keep as a build artifact, and a signed receipt for each hosted score, so you can look back at what a given build was scored on.

Report first, then block

Run in report mode for a week or two. Look at which answers score low and whether you agree with them. Then turn on blocking. A gate that fails at random gets switched off, so earn trust before you enforce it.

Measure whether it is working

Use your own numbers. We don't supply any. Track:

  • pull requests the check failed that led to a prompt or model change before merge,
  • rollbacks or hotfixes on LLM features after release, before and after the gate,
  • time reviewers spend on pull requests that touch prompts,
  • credits used per CI run.

What this check does not do

A pass does not mean the answers are true. It means each answer's confidence was backed by its reasoning above your line. Keep your own correctness tests for facts your feature must get right.

ClearRun scores whether an AI answer's confidence is backed by its reasoning. It does not check facts. A high score does not mean an answer is true. Treat the score as one signal your team can use.

FAQ

What is LLM regression testing?

Re-running a fixed set of cases after a prompt, model or code change and checking that the answers did not get worse in ways users notice, such as broken format, wrong routing or stating guesses as facts.

How many test cases do I need to start?

A small fixed set from real traffic and past incidents is enough to start. Add a case after each production incident.

Does ClearRun call my model?

No. The CLI scores the answer files you give it. Generate the answers in an earlier CI step or commit them.

Which CI systems work?

GitHub Actions, GitLab CI or any CI with Node.js 18 or newer.

Does a passing run mean the answers are correct?

No. ClearRun is not a fact-checker. A pass means each answer's confidence was backed by its reasoning above your threshold.

Internal links on this page