Red Team an LLM Application with Promptfoo
Run the canonical promptfoo red team workflow against an LLM application: configure prompts and targets, generate adversarial test cases via plugins, wrap them in attack strategies, run the pentest, and review the vulnerability report.
Use this skill when
- Setting up the first red team for an LLM application
- Configuring
promptfooconfig.yaml(prompts, targets, plugins, strategies, grader) - Generating adversarial tests with
promptfoo redteam generate/redteam run - Reviewing the vulnerability report with
promptfoo redteam report - Scoping a red team to specific OWASP LLM Top 10 categories (LLM01, LLM08, LLM09)
- Comparing multiple LLM targets side-by-side
Do not use this skill when
- Testing a content filter / guardrail service directly → use
promptfoo-redteam-guardrails - Testing a RAG system with retrieved context → use
promptfoo-redteam-rag - Testing LLM agents with tools/state/memory → use
promptfoo-redteam-agents - Testing an app with multiple input fields (user_id + message) → use
promptfoo-redteam-multi-input - Testing vision/audio/video models → use
promptfoo-redteam-multimodal - Assessing a foundation/base model in isolation → use
promptfoo-redteam-foundation-models - Setting up CI/CD drift detection or supply chain gates → use
promptfoo-redteam-supply-chain
🛡️ Edge cases (mandatory handling)
Every red team config MUST handle these defensively — not just the happy path:
- Missing grader API key — the default grader is
gpt-5requiringOPENAI_API_KEY; if unavailable, override viadefaultTest.options.provider(e.g.ollama:chat:llama4:scout) or every test fails to grade - Empty prompt — if the user has no prompt (direct API pentest), omit the
prompts:field entirely; do not leave an empty string - Multiple targets — when comparing models, each target must have a distinct
labelor results are indistinguishable in the report - Long generation time —
redteam generatetakes ~5 min,redteam evaltakes ~15 min for default plugins; set CI timeouts accordingly - Plugin scope — running all default plugins when only a subset is needed wastes time; use
--plugins 'harmful,hijacking'to scope - Chat-style vs single-turn prompts — chat-style prompts go in
prompt.jsonreferenced asfile://prompt.json; inlineprompts:strings are single-turn
🎯 Core workflow
- Scaffold —
npx promptfoo@latest redteam init my-project --no-guicreatespromptfooconfig.yaml. - Configure prompts — load
references/prompts-and-targets.mdfor prompt formats and target types. - Select plugins — load
references/plugins.mdto map vulnerability classes to plugin IDs. - Select strategies — load
references/strategies.mdfor attack-framing options. - Generate + run —
npx promptfoo@latest redteam run(generate + eval in one step). - Review —
npx promptfoo@latest redteam reportopens the vulnerability report. - Checklist — run
references/checklist.mdend-to-end before declaring done.
🎯 Core principles (summary)
- Plugin = what vulnerability class; Strategy = how the attacker frames it. Pair them under
redteam.plugins+redteam.strategies. promptfooconfig.yamlis the single source of truth — prompts, targets, plugins, strategies, grader, purpose all live here.- Treat the red team as pentest, not unit tests — tests are adversarial, scored by an LLM grader, not deterministic.
- Default plugins cover OWASP LLM01 (injection/jailbreak), LLM08 (excessive agency), LLM09 (overreliance) + harmful categories from ML Commons / HarmBench.
purposeguides generation and grading — always setredteam.purposedescribing the app's intended behavior and security boundaries.- Multiple targets = side-by-side comparison — set 2+
targets:with distinctlabels to compare models.
📦 Default stack
- Runtime: Node.js
>=22.22.0 - CLI:
npx promptfoo@latest - Default grader:
gpt-5(override viadefaultTest.options.provider) - Default plugins:
contracts,excessive-agency,hallucination,harmful,imitation,hijacking,overreliance,pii,politics - Optional plugin:
competitors - Generation time: ~5 min
- Eval time: ~15 min (default plugins)
References
references/prompts-and-targets.md— prompt formats (inline, chat-style JSON, dynamic Python/JS) and target types (LLM APIs, custom flows, HTTP endpoints, webhooks)references/plugins.md— default + optional plugins, vulnerability-class mapping, OWASP LLM Top 10 mapping, harmful categoriesreferences/strategies.md— jailbreak variants,--pluginsscoping,numTeststuning, grader overridereferences/checklist.md— pre-flight and post-run checklistreferences/cli.md— full CLI command reference (init, generate, eval, run, report, view)