Testing LLM Prompts in CI: Automated Checks Before Every Deploy

Set up testing LLM prompts in CI: promptfoo evals, deterministic checks, LLM-as-judge rubrics and a GitHub Actions gate that blocks bad deploys.

By Galactic News Editorial · Published 2026-11-22T04:53:21+00:00 · Updated 2026-11-22T04:53:21+00:00

Testing LLM prompts in CI pipeline with automated checks before deploy

Testing LLM prompts in CI means every prompt change goes through the same pull request gate as code. A fixed set of test cases runs on each change. If the prompt breaks an expected behavior, the build fails before the change reaches users. Without this gate, a small wording tweak or a model update can silently change what an AI feature says. This guide sets up a working eval gate with promptfoo and GitHub Actions, and explains how to keep the suite fast, stable, and trusted.

Why testing LLM prompts in CI matters

Prompts are code that behaves unpredictably. A small change to a system prompt, a model version, or an input format can change outputs in ways no one expects. Evaluations give teams a quantitative way to measure that behavior. LangSmith's docs describe the core idea: run evaluations on curated datasets, compare versions, and build confidence before exposing changes to users.

CI evals and production evals catch different failures. CI evals rerun a fixed set of known cases on every change and block regressions before users see them. Production evals watch live traffic for new failures. A team needs both. CI is the gate. Production is the alarm. This guide covers the CI half.

The cost of skipping the gate is paid in user reports. A support triage prompt that starts misclassifying billing tickets, a summarizer that drops key facts, or a refusal that stops working all surface as complaints. A CI eval catches the same failure in minutes, on the pull request that caused it. The failing test names the exact behavior that changed.

Two layers: deterministic checks and LLM-as-judge

Start with deterministic assertions. They cost nothing beyond the model call, run in milliseconds, and never flake. Promptfoo's built-in assertion types include is-json, contains, regex, javascript, python, latency, and cost checks. Use them for everything that can be checked by rules: the output must be valid JSON, must contain a required field, must stay under a word limit, must classify into exactly one of three categories.

Add LLM-as-judge assertions only where rules cannot reach. Tone, helpfulness, factual accuracy against a reference answer, and semantic equivalence are judge territory. Promptfoo's llm-rubric assertion scores an output against a written rubric. LangSmith offers prebuilt evaluators such as Correctness, plus custom evaluators written in code. Judges are slower and cost more than deterministic checks, so use them sparingly.

Keep the judge's rubric specific. A rubric that says "the answer is good" produces noisy scores. A rubric that lists the facts the answer must contain and the claims it must not make produces stable scores. Pin the judge model and its temperature. A judge that changes behavior between runs makes the whole suite flaky.

Setting up the eval gate with promptfoo

Promptfoo is an open-source CLI for testing LLM apps. Its README states it is now part of OpenAI and remains open source under the MIT license. It runs evals on a CI runner and calls the model providers you configure. It needs Node.js 22.22 or newer, provider API keys stored as secrets, and a config file.

Keep prompts and evals in the repository, next to the code that uses them. A common layout puts the prompt text in a prompts folder and the eval config in an evals folder. Keeping the prompt in its own file means a diff shows exactly what changed. Start with 20 to 50 golden cases taken from real traffic, with personal data removed. Each case should describe one behavior the team would be upset to lose.

  1. Create the prompt file, such as prompts/triage.txt, with the prompt under test.
  2. Create promptfooconfig.yaml listing the prompt, the providers, and the test cases.
  3. Write deterministic assertions first: is-json, contains, and regex checks.
  4. Add one llm-rubric assertion per behavior that needs a judge.
  5. Run the eval locally with npx promptfoo eval and fix failing cases.
  6. Add the GitHub Actions workflow below to the repository.
  7. Open a pull request that changes the prompt and confirm the gate runs.

The workflow runs on pull requests that touch prompts or the config. It installs Node, runs the eval, and fails the job when any test fails. Promptfoo's eval command exits with code 100 when at least one test fails, so the step already fails the job. The jq step below makes the gate explicit and readable in the logs.

name: LLM Eval
on:
  pull_request:
    paths:
      - 'prompts/**'
      - 'promptfooconfig.yaml'
jobs:
  evaluate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '24'
          cache: 'npm'
      - name: Run eval
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          PROMPTFOO_CACHE_PATH: ~/.cache/promptfoo
        run: |
          npx promptfoo@latest eval \
            -c promptfooconfig.yaml \
            -o results.json \
            -o report.html
      - name: Check quality gate
        run: |
          FAILURES=$(jq '.results.stats.failures' results.json)
          if [ "$FAILURES" -gt 0 ]; then
            echo "$FAILURES eval(s) failed"
            exit 1
          fi
      - name: Upload results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: eval-results
          path: |
            results.json
            report.html

LangSmith offers a parallel path for teams already on LangChain. An evaluation needs three parts: a dataset of test inputs with expected outputs, a target function to test, and evaluators that score the outputs. Its regression test type measures performance consistency across versions, and its comparison view highlights regressions in red and improvements in green. The same dataset can run in CI through the LangSmith SDK, with an assertion that fails the build when accuracy drops below a threshold.

How to keep the suite fast and stable

Cache model responses. Promptfoo can cache responses so reruns cost nothing and return identical outputs. Set PROMPTFOO_CACHE_PATH to a cached directory in the workflow. A cached rerun of a passing suite should be free and instant. Without caching, every pull request pays for the full eval.

Set a pass-rate threshold, not a demand for perfection. A suite that must pass 100 percent of cases will block good changes when a judge flakes once. A threshold such as 95 percent, plus a rule that no critical case may fail, is more honest. Mark critical cases clearly in the config so the team knows which failures are blockers.

Feed production failures back into CI. When a user reports a bad output, or production monitoring flags one, add it as a regression case. Keep one YAML file per regression case in a folder, and let the config load the whole folder. The suite grows with real failures, which is how it earns trust.

Control cost and time. Cap the number of cases per run, and keep the judge model small. A suite of 50 cases with a small judge model runs in a few minutes. Split the suite into a fast gate that runs on every pull request and a deeper suite that runs nightly. The fast gate blocks regressions. The nightly suite catches slow drift.

ToolBest forCI fit
PromptfooPrompt regression tests, deterministic assertions, red teamingExits 100 on failure; native GitHub Actions support
LangSmithDatasets, experiments, regression comparison across versionsSDK runs in CI; assert on aggregate metrics
DeepEvalPython pytest-style evals with built-in metricsRuns as a normal pytest suite in CI
RagasRAG quality metrics such as faithfulness and retrieval relevanceOffline evals in CI or nightly jobs

Bottom line

Testing LLM prompts in CI is a small setup with a large payoff. Store prompts as files. Write deterministic assertions first and add a judge only where rules cannot reach. Gate pull requests on the eval, cache responses to keep it cheap, and feed production failures back as regression cases. The result is a prompt change that can be reviewed, tested, and trusted like any other code change.