CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
Catch Prompt Regressions Before Users Do: LLM App Testing with Promptfoo

Catch Prompt Regressions Before Users Do: LLM App Testing with Promptfoo

Chris Harper

3 min read

Aug 11, 2026 · 12:05 UTC

AI
Tutorial
Agents
Best Practices
Developer Tools

Promptfoo runs every prompt variant against every model in parallel with YAML-defined assertions — catch regressions and prompt injection in CI before users see them.

What you'll be able to do after this:

  • Define prompt variants and test cases in a single YAML file and evaluate all combinations in seconds
  • Write deterministic and LLM-graded assertions that pass/fail like unit tests
  • Run automated red-team scans with 67+ attack plugins to catch jailbreaks and prompt injection before shipping

Setup

npx promptfoo@latest init

This creates promptfooconfig.yaml:

prompts:
  - "Summarize the following text: {{text}}"
  - "In 3 bullet points, summarize: {{text}}"

providers:
  - anthropic:claude-haiku-4-5-20251001
  - openai:gpt-4o-mini

tests:
  - vars:
      text: "Anthropic builds AI that is safe and helpful."
    assert:
      - type: contains
        value: "Anthropic"
      - type: llm-rubric
        value: "Response is a concise summary, not a direct quote"
      - type: latency
        threshold: 5000

  - vars:
      text: "The meeting is at 3pm on Friday in room 4B."
    assert:
      - type: contains
        value: "meeting"
      - type: not-contains
        value: "I cannot"

Run the eval

npx promptfoo eval              # runs every test × provider combo in parallel
npx promptfoo view              # opens local web UI — a grid of pass/fail results
npx promptfoo eval --ci         # exits code 1 if any assertion fails

The web UI shows a grid: rows are test cases, columns are prompt-provider combinations, cells show pass/fail with the model's actual output. You see at a glance which prompt wording wins across all your cases and providers.

Assertion types:

  • Deterministic (contains, not-contains, regex, latency, cost) — free and instant, no LLM call needed
  • LLM-graded (llm-rubric) — sends output to a judge model for subjective quality checks like tone or completeness
  • Custom — Python or JavaScript functions for domain-specific checks

Add to CI (GitHub Actions)

- name: LLM regression test
  run: npx promptfoo eval --ci
  env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Fails the build on prompt regressions exactly like a unit test suite — no more "we broke the prompt in last week's deploy."

Red-teaming (optional, 2 commands)

npx promptfoo redteam init   # generates adversarial test cases for your app
npx promptfoo redteam run    # runs 67+ attack plugins: jailbreaks, injections, policy violations

Promptfoo is Apache 2.0 open source, runs 100% locally, and supports 90+ model providers. The evaluation framework was acquired by OpenAI in March 2026 but remains open source with first-party Anthropic support.

Sources: Promptfoo configuration guide — promptfoo.dev · Promptfoo tutorial — DataCamp · Red-team guide — promptfoo.dev · CI/CD integration — promptfoo.dev