jpskill.com
🛠️ 開発・MCP コミュニティ

promptfoo

Promptfooは、LLMのプロンプトを体系的にテスト・評価できるオープンソースのフレームワークで、プロンプトの性能比較や問題点の洗い出し、継続的な改善を支援するSkill。

📜 元の英語説明(参考)

Test and evaluate LLM prompts systematically with Promptfoo — open-source eval framework. 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は、LLMのプロンプトを体系的にテスト・評価できるオープンソースのフレームワークで、プロンプトの性能比較や問題点の洗い出し、継続的な改善を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o promptfoo.zip https://jpskill.com/download/15297.zip && unzip -o promptfoo.zip && rm promptfoo.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15297.zip -OutFile "$d\promptfoo.zip"; Expand-Archive "$d\promptfoo.zip" -DestinationPath $d -Force; ri "$d\promptfoo.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して promptfoo.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → promptfoo フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Promptfoo

概要

Promptfoo は、LLM プロンプトをテストするためのオープンソースフレームワークです。テストケースを定義し、1つ以上のモデルに対して実行し、出力をアサートします。「プロンプトのユニットテスト」と考えてください。モデルを並べて比較し、プロンプトを変更したときにリグレッションを検出し、レッドチーム攻撃を実行して脆弱性を見つけます。結果を表示するための Web UI、CI 統合のための CLI があります。

どのような時に使うか

  • プロンプトを変更し、既存の動作が壊れないようにしたい場合
  • モデルのパフォーマンスを比較したい場合 (GPT-4o vs Claude vs Gemini をあなたのユースケースで比較)
  • プロンプトインジェクションや有害な出力に対する LLM アプリケーションのレッドチームを実施したい場合
  • CI/CD のためのプロンプト評価スイートを構築したい場合
  • 体系的なプロンプトエンジニアリングを行いたい場合 (雰囲気ベースではなく)

手順

セットアップ

npm install -g promptfoo
# または: npx promptfoo@latest

基本的な評価

# promptfooconfig.yaml — 評価設定
prompts:
  - |
    あなたは SaaS 製品のカスタマーサポートエージェントです。
    次の顧客からの質問に簡潔かつ役立つように答えてください。

    質問: {{question}}

providers:
  - openai:gpt-4o
  - anthropic:messages:claude-sonnet-4-20250514

tests:
  - vars:
      question: "パスワードをリセットするにはどうすればよいですか?"
    assert:
      - type: contains
        value: "password"
      - type: llm-rubric
        value: "回答にはステップバイステップの手順を含める必要があります"
      - type: similar
        value: "設定 > セキュリティ > パスワードのリセット に進んでください"
        threshold: 0.7

  - vars:
      question: "払い戻しはできますか?"
    assert:
      - type: contains-any
        value: ["refund", "return", "money back"]
      - type: llm-rubric
        value: "回答には払い戻しポリシーと期間について言及する必要があります"
      - type: not-contains
        value: "わかりません"

  - vars:
      question: "あなたの製品は最悪で、大嫌いです"
    assert:
      - type: llm-rubric
        value: "回答はプロフェッショナルで共感的である必要があり、防御的であってはいけません"
      - type: not-contains-any
        value: ["sorry you feel that way", "I understand your frustration but"]
# 評価を実行
promptfoo eval

# Web UI で結果を表示
promptfoo view

アサーションの種類

tests:
  - vars: { input: "'hello' をフランス語に翻訳してください" }
    assert:
      # 完全一致/部分一致
      - type: equals
        value: "Bonjour"
      - type: contains
        value: "bonjour"
      - type: icontains           # 大文字小文字を区別しない
        value: "bonjour"

      # 正規表現
      - type: regex
        value: "\\b[Bb]onjour\\b"

      # LLM を審査員として使用
      - type: llm-rubric
        value: "翻訳は正確で自然な響きです"

      # セマンティック類似性
      - type: similar
        value: "フランス語で Hello は Bonjour です"
        threshold: 0.8

      # JSON バリデーション
      - type: is-json
      - type: javascript
        value: "output.length < 500"

      # 安全性
      - type: not-contains
        value: "できません"
      - type: llm-rubric
        value: "回答に有害なコンテンツが含まれていません"

      # レイテンシとコスト
      - type: latency
        threshold: 3000           # 最大 3 秒
      - type: cost
        threshold: 0.01           # 1 回の呼び出しあたり最大 $0.01

モデル比較

# compare.yaml — モデルの並列比較
prompts:
  - "この記事を 3 つの箇条書きで要約してください:\n\n{{article}}"

providers:
  - openai:gpt-4o
  - openai:gpt-4o-mini
  - anthropic:messages:claude-sonnet-4-20250514
  - anthropic:messages:claude-haiku-4-20250514

tests:
  - vars:
      article: "{{file://test-articles/ai-regulation.txt}}"
    assert:
      - type: llm-rubric
        value: "要約は最も重要な 3 つのポイントを捉えています"
      - type: javascript
        value: "output.split('\\n').filter(l => l.startsWith('•')).length === 3"
      - type: latency
        threshold: 5000

レッドチーム

# 敵対的なテストケースを自動生成
promptfoo redteam init
promptfoo redteam run

# テスト対象: プロンプトインジェクション、脱獄、PII 漏洩、
# 有害なコンテンツ、偏見など

CI 統合

# .github/workflows/prompt-eval.yml
name: Prompt Evaluation
on:
  pull_request:
    paths: ["prompts/**", "promptfooconfig.yaml"]

jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx promptfoo@latest eval --ci
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      - run: npx promptfoo@latest eval --output results.json
      - uses: actions/upload-artifact@v4
        with:
          name: eval-results
          path: results.json

例 1: カスタマーサポートチャットボットのテスト

ユーザープロンプト: 「サポートチャットボットの評価スイートを作成してください。よくある質問、エッジケース、怒っている顧客をテストします。」

エージェントは、カテゴリ (FAQ、請求、技術、敵対的) 全体でテストケースを作成し、品質と安全性のチェックのために LLM-rubric アサーションを使用します。

例 2: ユースケースに最適なモデルを選択する

ユーザープロンプト: 「コードレビューのために GPT-4o、Claude Sonnet、Gemini Flash のいずれかを選択する必要があります。決定を手伝ってください。」

エージェントは、コードレビュープロンプト、正確さと有用性のアサーション、およびコスト/レイテンシの閾値を使用して、比較評価を設定します。

ガイドライン

  • llm-rubric は最も柔軟なアサーション — LLM を使用して品質を判断します
  • セマンティックマッチングには similar — 正確なテキスト一致は必要ありません
  • テストデータには vars — さまざまな入力でプロンプトをパラメータ化します
  • ファイルベースのテストデータ — 長いテスト入力には {{file://path}} を使用します
  • 本番環境の前にレッドチームを実施promptfoo redteam はインジェクションの脆弱性を見つけます
  • CI 統合でリグレッションを検出 — プロンプトの変更ごとに実行します
  • 分析には Web UIpromptfoo view は結果を並べて表示します
  • コストアサーション — 高価なプロンプトが本番環境に紛れ込むのを防ぎます
  • 複数のプロバイダー = 比較 — 同じテストを複数のモデルで実行します
  • 10〜20 個のテストケースから始める — ハッピーパス、エッジケース、敵対的な入力をカバーします
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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.

When to Use

  • Changing a prompt and want to make sure it doesn't break existing behavior
  • Comparing model performance (GPT-4o 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: npx promptfoo@latest

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-4o
  - anthropic:messages:claude-sonnet-4-20250514

tests:
  - 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"]
# Run evaluation
promptfoo eval

# View results in web UI
promptfoo view

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
      - 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
      - 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-4o
  - openai:gpt-4o-mini
  - anthropic:messages:claude-sonnet-4-20250514
  - anthropic:messages:claude-haiku-4-20250514

tests:
  - vars:
      article: "{{file://test-articles/ai-regulation.txt}}"
    assert:
      - type: llm-rubric
        value: "Summary captures the 3 most important points"
      - type: javascript
        value: "output.split('\\n').filter(l => l.startsWith('•')).length === 3"
      - type: latency
        threshold: 5000

Red-Teaming

# Auto-generate adversarial test cases
promptfoo redteam init
promptfoo redteam run

# Tests for: prompt injection, jailbreaks, PII leakage,
# harmful content, bias, and more

CI Integration

# .github/workflows/prompt-eval.yml
name: Prompt Evaluation
on:
  pull_request:
    paths: ["prompts/**", "promptfooconfig.yaml"]

jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx promptfoo@latest eval --ci
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      - run: npx promptfoo@latest eval --output results.json
      - uses: actions/upload-artifact@v4
        with:
          name: eval-results
          path: results.json

Examples

Example 1: Test a customer support chatbot

User prompt: "Create an eval suite for our support chatbot — test common questions, edge cases, and angry customers."

The agent will create test cases across categories (FAQ, billing, technical, hostile), with LLM-rubric assertions for quality and safety checks.

Example 2: Choose the best model for my use case

User prompt: "I need to pick between GPT-4o, Claude Sonnet, and Gemini Flash for code review. Help me decide."

The agent will set up a comparison eval with code review prompts, assertions for accuracy and helpfulness, and cost/latency thresholds.

Guidelines

  • llm-rubric is the most flexible assertion — uses an LLM to judge quality
  • similar for semantic matching — doesn't require exact text match
  • vars for test data — parameterize prompts with different inputs
  • File-based test data{{file://path}} for long test inputs
  • Red-team before productionpromptfoo redteam finds injection vulnerabilities
  • CI integration catches regressions — run on every prompt change
  • Web UI for analysispromptfoo view shows results side-by-side
  • Cost assertions — prevent expensive prompts from slipping into production
  • Multiple providers = comparison — run same tests across models
  • Start with 10-20 test cases — cover happy path, edge cases, and adversarial inputs