ai-eval-ci
AIエージェントやLLMの品質評価をCI/CDパイプラインに組み込み、AIの出力品質が低下した場合にビルドを失敗させることで、プロンプトの劣化を検知したり、モデルを比較したり、AIの品質基準を設定したりするのに役立つSkill。
📜 元の英語説明(参考)
Run AI agent and LLM evaluations in CI/CD pipelines — automated quality gates that fail the build when AI output quality drops. Use when someone asks to "test my AI agent", "add evals to CI", "catch prompt regressions", "compare models", "evaluate LLM output quality", "set up AI quality gates", or "benchmark my agent before deploying". Covers eval frameworks (Cobalt, Promptfoo, Braintrust), LLM-as-judge scoring, threshold-based assertions, and GitHub Actions integration.
🇯🇵 日本人クリエイター向け解説
AIエージェントやLLMの品質評価をCI/CDパイプラインに組み込み、AIの出力品質が低下した場合にビルドを失敗させることで、プロンプトの劣化を検知したり、モデルを比較したり、AIの品質基準を設定したりするのに役立つSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-eval-ci.zip https://jpskill.com/download/14611.zip && unzip -o ai-eval-ci.zip && rm ai-eval-ci.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14611.zip -OutFile "$d\ai-eval-ci.zip"; Expand-Archive "$d\ai-eval-ci.zip" -DestinationPath $d -Force; ri "$d\ai-eval-ci.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
ai-eval-ci.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
ai-eval-ciフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
CIにおけるAI評価
概要
AIエージェントとLLMの出力を、コードをテストするのと同じようにテストします。CIで実行される自動評価を行い、ベースラインと比較し、品質が低下した場合はビルドを失敗させます。手動で確認するダッシュボードはありません。npx eval run --ci を実行するだけで、ビルドが成功か失敗か分かります。
活用場面
- AI機能を本番環境にデプロイする前に品質ゲートを追加する
- システムプロンプトやモデルが変更された場合にプロンプトの回帰を検出する
- モデルのパフォーマンスを比較する(GPT-4o vs Claude Sonnet vs ローカルのLlama)
- テストデータセットに対してRAGパイプラインの精度を検証する
- エージェントのツール呼び出しの精度とレイテンシをベンチマークする
手順
戦略1:Promptfoo(設定駆動型評価)
Promptfooは、最も人気のあるオープンソースの評価フレームワークです。YAMLでテストケースを定義し、複数のプロバイダーに対して実行し、比較マトリックスを取得します。
# promptfooconfig.yaml — 評価設定
# 3つのモデルでカスタマーサポートエージェントを品質アサーションでテストします
description: "Customer support agent eval"
providers:
- id: openai:gpt-4o
- id: anthropic:messages:claude-sonnet-4-20250514
- id: ollama:llama3.1:8b
prompts:
- |
あなたはSaaS製品のカスタマーサポートエージェントです。
親切かつ正確に対応してください。分からない場合は、そう言ってください。
お客様からのメッセージ: {{message}}
tests:
- vars:
message: "パスワードをリセットするにはどうすればよいですか?"
assert:
- type: llm-rubric
value: "応答はパスワードのリセットプロセスを明確に説明している"
- type: not-contains
value: "分かりません"
- type: latency
threshold: 3000 # 3秒以内に応答する必要があります
- vars:
message: "年間プランの払い戻しはできますか?"
assert:
- type: llm-rubric
value: "応答は払い戻し要求を認識し、ポリシーを説明している"
- type: not-contains
value: "私はAIです" # キャラクターを崩さないでください
- vars:
message: "あなたの製品が私のデータをすべて削除しました!"
assert:
- type: llm-rubric
value: "応答は共感を示し、問題を深刻に受け止め、次のステップを提供する"
- type: sentiment
threshold: 0.3 # 軽視してはいけません
- vars:
message: "東京の天気はどうですか?"
assert:
- type: llm-rubric
value: "応答は製品関連のトピックに丁寧にリダイレクトする"
- type: not-contains
value: "東京" # オフトピックの質問に答えてはいけません
# ローカルで評価を実行する
npx promptfoo@latest eval
# CIで閾値を使用して実行する — テストが失敗した場合、ゼロ以外のコードで終了します
npx promptfoo@latest eval --ci --output results.json
# 2つのプロンプトバージョンを比較する
npx promptfoo@latest eval --prompts prompt-v1.txt prompt-v2.txt --share
戦略2:カスタム評価フレームワーク(TypeScript)
完全な制御が必要な場合 — カスタムスコアリングロジック、データベースバックのテストセット、ドメイン固有のメトリクス。
// eval.ts — CI統合されたカスタムAI評価フレームワーク
/**
* AIエージェント/LLMに対して評価スイートを実行します。
* 各評価は、入力、期待される動作、およびスコアリング基準を定義します。
* スコアが閾値を下回った場合、コード1で終了します。
*/
import OpenAI from "openai";
interface EvalCase {
name: string;
input: string;
rubric: string; // 「良い」とは何か
threshold: number; // 最小スコア0-1
metadata?: Record<string, unknown>;
}
interface EvalResult {
name: string;
score: number;
pass: boolean;
output: string;
reasoning: string;
latencyMs: number;
}
const openai = new OpenAI();
/**
* LLM-as-judgeを使用してAI出力をスコアリングします。
* 推論とともに0-1のスコアを返します。
*/
async function judge(output: string, rubric: string): Promise<{ score: number; reasoning: string }> {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini", // 判定用の安価なモデル
messages: [
{
role: "system",
content: `あなたは評価判定者です。AI出力をルーブリックに対してスコアリングしてください。
JSONを返してください: {"score": 0.0-1.0, "reasoning": "簡単な説明"}
スコア1.0 = 完全に一致。スコア0.0 = 完全な失敗。`,
},
{
role: "user",
content: `ルーブリック: ${rubric}\n\nAI出力:\n${output}`,
},
],
response_format: { type: "json_object" },
temperature: 0, // 決定論的な判定
});
return JSON.parse(response.choices[0].message.content!);
}
/**
* AIエージェントに対して単一の評価ケースを実行します。
*/
async function runEval(
agentFn: (input: string) => Promise<string>,
evalCase: EvalCase
): Promise<EvalResult> {
const start = Date.now();
const output = await agentFn(evalCase.input);
const latencyMs = Date.now() - start;
const { score, reasoning } = await judge(output, evalCase.rubric);
return {
name: evalCase.name,
score,
pass: score >= evalCase.threshold,
output: output.slice(0, 200),
reasoning,
latencyMs,
};
}
/**
* すべての評価を実行し、CIに適したコードで終了します。
*/
async function runSuite(
agentFn: (input: string) => Promise<string>,
cases: EvalCase[]
): Promise<void> {
console.log(`${cases.length}個の評価を実行中...\n`);
const results: EvalResult[] = [];
for (const evalCase of cases) {
const result = await runEval(agentFn, evalCase);
results.push(result);
const icon = result.pass ? "✅" : "❌";
console.log(`${icon} ${result.name}: ${result.score.toFixed(2)} (閾値: ${evalCase.threshold}) [${result.latencyMs}ms]`);
if (!result.pass) {
console.log(` 推論: ${result.reasoning}`);
}
}
// サマリー
const passed = results.filter((r) => r.pass).length;
const failed = results.filter((r) => !r.pass).length;
const avgScore = results.reduce((s, r) => s + r.score, 0) / results.length;
console.log(`\n📊 結果: ${passed}個合格, ${failed}個不合格 (平均スコア: ${avgScore.toFixed(2)})`);
// CI終了コード
if (failed > 0) {
console.log("\n❌ 評価スイートは失敗しました — 品質が閾値を下回っています");
process.exit(1);
} else {
console.log("\n✅ 評価スイートは合格しました");
}
}
export { runSuite, EvalCase };
戦略3:Gi
(原文はここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
AI Eval in CI
Overview
Test AI agents and LLM outputs the same way you test code — automated evaluations that run in CI, compare against baselines, and fail the build when quality drops. No dashboards to check manually. Just npx eval run --ci and a red or green build.
When to Use
- Adding quality gates before deploying AI features to production
- Catching prompt regressions when system prompts or models change
- Comparing model performance (GPT-4o vs Claude Sonnet vs local Llama)
- Validating RAG pipeline accuracy against a test dataset
- Benchmarking agent tool-calling accuracy and latency
Instructions
Strategy 1: Promptfoo (Config-Driven Evals)
Promptfoo is the most popular open-source eval framework. Define test cases in YAML, run against multiple providers, get a comparison matrix.
# promptfooconfig.yaml — Eval configuration
# Tests a customer support agent across 3 models with quality assertions
description: "Customer support agent eval"
providers:
- id: openai:gpt-4o
- id: anthropic:messages:claude-sonnet-4-20250514
- id: ollama:llama3.1:8b
prompts:
- |
You are a customer support agent for a SaaS product.
Respond helpfully and accurately. If you don't know, say so.
Customer message: {{message}}
tests:
- vars:
message: "How do I reset my password?"
assert:
- type: llm-rubric
value: "Response explains the password reset process clearly"
- type: not-contains
value: "I don't know"
- type: latency
threshold: 3000 # Must respond within 3 seconds
- vars:
message: "Can I get a refund for my annual plan?"
assert:
- type: llm-rubric
value: "Response acknowledges the refund request and explains the policy"
- type: not-contains
value: "I'm an AI" # Don't break character
- vars:
message: "Your product deleted all my data!"
assert:
- type: llm-rubric
value: "Response shows empathy, takes the issue seriously, and offers next steps"
- type: sentiment
threshold: 0.3 # Must not be dismissive
- vars:
message: "What's the weather in Tokyo?"
assert:
- type: llm-rubric
value: "Response politely redirects to product-related topics"
- type: not-contains
value: "Tokyo" # Should not answer off-topic questions
# Run evals locally
npx promptfoo@latest eval
# Run in CI with threshold — exits non-zero if any test fails
npx promptfoo@latest eval --ci --output results.json
# Compare two prompt versions
npx promptfoo@latest eval --prompts prompt-v1.txt prompt-v2.txt --share
Strategy 2: Custom Eval Framework (TypeScript)
When you need full control — custom scoring logic, database-backed test sets, domain-specific metrics.
// eval.ts — Custom AI eval framework with CI integration
/**
* Runs evaluation suites against AI agents/LLMs.
* Each eval defines inputs, expected behavior, and scoring criteria.
* Exits with code 1 if any score drops below threshold.
*/
import OpenAI from "openai";
interface EvalCase {
name: string;
input: string;
rubric: string; // What "good" looks like
threshold: number; // Minimum score 0-1
metadata?: Record<string, unknown>;
}
interface EvalResult {
name: string;
score: number;
pass: boolean;
output: string;
reasoning: string;
latencyMs: number;
}
const openai = new OpenAI();
/**
* Score an AI output using LLM-as-judge.
* Returns a score 0-1 with reasoning.
*/
async function judge(output: string, rubric: string): Promise<{ score: number; reasoning: string }> {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini", // Cheap model for judging
messages: [
{
role: "system",
content: `You are an eval judge. Score the AI output against the rubric.
Return JSON: {"score": 0.0-1.0, "reasoning": "brief explanation"}
Score 1.0 = perfect match. Score 0.0 = complete failure.`,
},
{
role: "user",
content: `Rubric: ${rubric}\n\nAI Output:\n${output}`,
},
],
response_format: { type: "json_object" },
temperature: 0, // Deterministic judging
});
return JSON.parse(response.choices[0].message.content!);
}
/**
* Run a single eval case against your AI agent.
*/
async function runEval(
agentFn: (input: string) => Promise<string>,
evalCase: EvalCase
): Promise<EvalResult> {
const start = Date.now();
const output = await agentFn(evalCase.input);
const latencyMs = Date.now() - start;
const { score, reasoning } = await judge(output, evalCase.rubric);
return {
name: evalCase.name,
score,
pass: score >= evalCase.threshold,
output: output.slice(0, 200),
reasoning,
latencyMs,
};
}
/**
* Run all evals and exit with appropriate code for CI.
*/
async function runSuite(
agentFn: (input: string) => Promise<string>,
cases: EvalCase[]
): Promise<void> {
console.log(`Running ${cases.length} evals...\n`);
const results: EvalResult[] = [];
for (const evalCase of cases) {
const result = await runEval(agentFn, evalCase);
results.push(result);
const icon = result.pass ? "✅" : "❌";
console.log(`${icon} ${result.name}: ${result.score.toFixed(2)} (threshold: ${evalCase.threshold}) [${result.latencyMs}ms]`);
if (!result.pass) {
console.log(` Reasoning: ${result.reasoning}`);
}
}
// Summary
const passed = results.filter((r) => r.pass).length;
const failed = results.filter((r) => !r.pass).length;
const avgScore = results.reduce((s, r) => s + r.score, 0) / results.length;
console.log(`\n📊 Results: ${passed} passed, ${failed} failed (avg score: ${avgScore.toFixed(2)})`);
// CI exit code
if (failed > 0) {
console.log("\n❌ Eval suite FAILED — quality below threshold");
process.exit(1);
} else {
console.log("\n✅ Eval suite PASSED");
}
}
export { runSuite, EvalCase };
Strategy 3: GitHub Actions Integration
# .github/workflows/ai-eval.yml
name: AI Eval
on:
pull_request:
paths:
- "prompts/**"
- "src/agents/**"
- "eval/**"
jobs:
eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci
- name: Run AI evals
run: npx tsx eval/run.ts --ci
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Post results to PR
if: always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('eval/results.json'));
const body = results.map(r =>
`${r.pass ? '✅' : '❌'} **${r.name}**: ${r.score.toFixed(2)} (${r.latencyMs}ms)`
).join('\n');
github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: `## AI Eval Results\n\n${body}`
});
Examples
Example 1: Add quality gates to a RAG chatbot
User prompt: "Set up automated evals for our RAG customer support bot. It should test accuracy on 50 known Q&A pairs and fail the deploy if accuracy drops below 85%."
The agent will:
- Create a test dataset from the 50 known Q&A pairs
- Write promptfoo config with llm-rubric assertions for each
- Set pass threshold at 0.85
- Add GitHub Actions workflow that runs on PR to
prompts/orsrc/agents/ - Post eval results as PR comment
Example 2: Compare models before switching
User prompt: "We're considering switching from GPT-4o to Claude Sonnet. Run our eval suite against both and show me which performs better."
The agent will:
- Configure promptfoo with both providers
- Run the existing eval suite against both models
- Generate comparison table with per-test scores, latency, and cost
- Recommend based on score-to-cost ratio
Guidelines
- Eval every prompt change — treat prompts like code; test before deploying
- LLM-as-judge is good enough — GPT-4o-mini costs pennies and correlates well with human judgment
- Use temperature 0 for judges — deterministic scoring reduces noise
- Keep test sets diverse — happy path, edge cases, adversarial inputs, off-topic
- Set realistic thresholds — start at 0.7, tighten as the agent improves
- Track scores over time — log results to detect gradual quality drift
- Separate eval cost from production cost — eval uses cheap judge models, production uses the best
- Cache eval results — don't re-run unchanged tests; hash input+prompt for cache keys
- Run evals on PRs, not just main — catch regressions before merge