promptfoo
БесплатноБез исполняемых скриптовНе проверенPromptfoo is an open-source framework that tests and evaluates LLM prompts systematically. Use when someone asks to "test my prompts", "evaluate LLM output"…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Promptfoo
Overview
Promptfoo is an open-source framework for testing LLM prompts — define test cases, run them against one or more models, and assert on outputs. Think "unit tests for prompts." Compare models side-by-side, catch regressions when you change a prompt, and run red-team attacks to find vulnerabilities. Web UI for viewing results, CLI for CI integration. Evals run on your machine and call the providers with your own API keys; the project is MIT licensed and is now part of OpenAI.
When to Use
- Changing a prompt and want to make sure it doesn't break existing behavior
- Comparing model performance (GPT vs Claude vs Gemini on your use case)
- Red-teaming an LLM application for prompt injection and harmful outputs
- Building a prompt evaluation suite for CI/CD
- Systematic prompt engineering (not vibes-based)
Instructions
Setup
npm install -g promptfoo # or: brew install promptfoo
# Or run without installing: npx promptfoo@latest eval
promptfoo --version
promptfoo init --no-interactive # writes a starter promptfooconfig.yaml
Providers read their keys from the environment (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) or from a file passed with --env-file .env. A missing key is reported before any test runs.
Basic Evaluation
# promptfooconfig.yaml — Eval configuration
prompts:
- |
You are a customer support agent for a SaaS product.
Answer the following customer question concisely and helpfully.
Question: {{question}}
providers:
- openai:gpt-6-sol
- anthropic:messages:claude-sonnet-5
defaultTest:
options:
provider:
text: openai:gpt-6-luna # judge for llm-rubric
embedding: openai:embeddings:text-embedding-3-large # embeddings for similar
tests:
- description: password reset
vars:
question: "How do I reset my password?"
assert:
- type: contains
value: "password"
- type: llm-rubric
value: "Response should include step-by-step instructions"
- type: similar
value: "Go to Settings > Security > Reset Password"
threshold: 0.7
- vars:
question: "Can I get a refund?"
assert:
- type: contains-any
value: ["refund", "return", "money back"]
- type: llm-rubric
value: "Response should mention the refund policy and timeline"
- type: not-contains
value: "I don't know"
- vars:
question: "Your product sucks and I hate it"
assert:
- type: llm-rubric
value: "Response should be professional and empathetic, not defensive"
- type: not-contains-any
value: ["sorry you feel that way", "I understand your frustration but"]
# Check the file, then dry-run it: echo replaces the models under test and returns the rendered
# prompt. llm-rubric and similar still call the judge and embeddings model (and need their key).
promptfoo validate config
promptfoo eval -r echo
# Run evaluation (results are cached on disk; --no-cache forces fresh calls)
promptfoo eval
promptfoo eval --filter-pattern "password" -o results.json -o report.html
# View results in web UI (http://localhost:15500)
promptfoo view
promptfoo eval exits with code 100 when any test fails and 1 on other errors. PROMPTFOO_PASS_RATE_THRESHOLD=90 lets a run pass at 90% instead of 100%.
Assertion Types
tests:
- vars: { input: "Translate 'hello' to French" }
assert:
# Exact/partial match
- type: equals
value: "Bonjour"
- type: contains
value: "bonjour"
- type: icontains # Case-insensitive
value: "bonjour"
# Regex
- type: regex
value: "\\b[Bb]onjour\\b"
# LLM-as-judge
- type: llm-rubric
value: "Translation is accurate and natural-sounding"
# Semantic similarity (embeddings; OpenAI text-embedding-3-large unless overridden)
- type: similar
value: "Hello in French is Bonjour"
threshold: 0.8
# JSON validation
- type: is-json
- type: javascript
value: "output.length < 500"
# Safety
- type: not-contains
value: "I cannot"
- type: llm-rubric
value: "Response does not contain harmful content"
# Latency and cost
- type: latency
threshold: 3000 # Max 3 seconds; errors on a cached response, run with --no-cache
- type: cost
threshold: 0.01 # Max $0.01 per call
Model Comparison
# compare.yaml — Side-by-side model comparison
prompts:
- "Summarize this article in 3 bullet points:\n\n{{article}}"
providers:
- openai:gpt-6-sol
- openai:gpt-6-luna
- anthropic:messages:claude-sonnet-5
- anthropic:messages:claude-haiku-4-5-20251001
tests:
- vars:
article: file://test-articles/ai-regulation.txt # loads the file; do not wrap it in {{ }}
assert:
- type: llm-rubric
value: "Summa
Установить promptfoo в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл promptfoo?
Promptfoo is an open-source framework that tests and evaluates LLM prompts systematically. Use when someone asks to "test my prompts", "evaluate LLM output", "Promptfoo", "prompt regression testing", "compare LLM models", "LLM evaluation framework", or "benchmark prompts against test cases". Covers test cases, assertions, model comparison, red-teaming, and CI integration.
Как установить скилл promptfoo?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл promptfoo запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic