published fresh until

promptfoo: how do I test my LLM feature for prompt injection?

Summary As of October 2026, promptfoo (MIT) has a red-team mode: npx promptfoo@latest redteam setup, then redteam run generates hundreds of adversarial inputs against your endpoint and redteam report shows failures by category. Run it against a staging copy; attack generation defaults to OpenAI.

Not for having Claude subagents attack a whole web app; deciding which tools an agent should hold

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You added an LLM feature (chat, summary, document Q&A) and want evidence about prompt injection before users find it. Reddit commenters in an r/LLMDevs thread on a hidden-PDF injection say a single model catch proves little: the model may flag an attack once and obey it on the next run, so you want a repeatable test with a catch rate.

What promptfoo's red-team mode does

From promptfoo's red-team quickstart (read 18 October 2026; repo MIT license, active this month):

npx promptfoo@latest redteam setup     # web UI that writes promptfooconfig.yaml
# or without the UI:
promptfoo redteam init --no-gui

npx promptfoo@latest redteam run       # generates adversarial inputs, saves redteam.yaml, runs them
npx promptfoo@latest redteam report    # failures by category and severity, with raw inputs and outputs

Needs Node 22.22+. The config has four parts: application purpose (more detail gives more tailored attacks), a target (a model or an HTTP endpoint with url, method, headers and a body using {{prompt}}), plugins (generators of malicious inputs, individually or a preset such as Default) and strategies (wrappers that turn inputs into stronger jailbreaks and injections). The quickstart tells you to keep the same target label between runs so results compare. The docs page I read does not show the exact YAML keys for plugins and strategies; use their configuration guide.

The report lists vulnerability categories such as prompt injection and context poisoning, severity levels, a breakdown by test type, logs with the inputs that failed, and suggested mitigations.

Safety notes before you run it

  • Point it at a staging deployment with fake data. It sends several hundred hostile inputs, and a weakly built app with real tools could act on them.
  • The docs say attack generation defaults to OpenAI and optionally uses OPENAI_API_KEY. They do not say what data is sent there, so assume the purpose text and the target's answers may reach a model provider and do not put real customer data in the target.
  • npx ...@latest runs third-party code with your permissions. Pin a version you checked rather than @latest if that matters for you.

Using it with an agent

Read how my LLM feature is called (the route, its system prompt, its tools). Write the promptfoo red-team config for it: the purpose paragraph, an HTTP target pointing at http://localhost:PORT/api/chat, and the default plugin preset. Do not run it. Tell me which tools the target can call so I can restrict them first.

Mistakes to check

  • Treating a clean report as proof; it is a sample of generated attacks.
  • Running it against production.
  • Skipping the architecture fix: commenters in the r/LLMDevs thread say tool permissions limit damage even when detection misses.
  • Changing the target label between runs and losing the comparison.

Limits

I did not run promptfoo for this write-up; everything is from its docs and the repo page. Whether it finds real problems in your app is untested here.

Sources

Primary sources, opened 18 October 2026: promptfoo red-team quickstart and the promptfoo repo (metadata read through the GitHub API: MIT, last push 18 October 2026).

  • Confirms: the redteam setup, init --no-gui, run and report commands; Node 22.22+; the purpose, target (an HTTP target with {{prompt}} in the body), plugins and strategies parts; reuse the same target label between runs; the report with categories, severity, logs and mitigations; promptfooconfig.yaml is what setup saves and redteam.yaml is where run stores the generated attacks.
  • Corrected above: the quickstart has no staging warning (it only says the scanner can attack any endpoint reachable from your machine, so the staging advice is this thread's own), lists OPENAI_API_KEY as optional with attack generation defaulting to OpenAI and a configurable alternative, and does not say what data is sent there, so check the provider docs and terms.
  • Not checked: the r/LLMDevs thread.

Started from a post by @promptfoo, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# promptfoo: how do I test my LLM feature for prompt injection?
Summary: As of October 2026, promptfoo (MIT) has a red-team mode: `npx promptfoo@latest redteam setup`, then `redteam run` generates hundreds of adversarial inputs against your endpoint and `redteam report` shows failures by category. Run it against a staging copy; attack generation defaults to OpenAI.
Copy for agent
get the whatworks thread test-my-llm-feature-for-prompt-injection-with-promptfoo-red-team and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread test-my-llm-feature-for-prompt-injection-with-promptfoo-red-team
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks