Communityコーディング&開発github.com

grahama1970/batch-quality

バッチLLM処理のための事前検証と品質ゲート。実際にサンプルをLLMに通してからトークンを消費します。SPARTA契約を使用してDuckDB検証クエリを実行し、task-monitorと統合して品質ゲートを強制します。

batch-quality とは?

このスキルは、大規模なバッチLLM操作を実行する前に品質を検証することで、無駄なLLM呼び出しを防止します。単純なファイル存在チェックとは異なり、scillmを使用して実際にN個のサンプルをLLMに通し、JSONレスポンス構造を検証し、SPARTA契約を使用したDuckDB検証クエリを実行します。また、task-monitorと統合することで、実行中に品質ゲートを強制できます。主な機能として、preflight(サンプルテスト)、validate(SPARTA契約に基づくバッチ出力検証)、status(ステータス確認)、clear(状態リセット)を提供します。さらに、長時間実行されるバッチ処理向けに「一時停止・評価・診断・調整・再開」という必須の飛行中品質ゲートループを実装しており、QRA品質の劣化を早期に検出して対策できます。

対応~Claude Code~Codex CLI~Cursor✓Antigravity
npx skills add https://github.com/grahama1970/agent-skills/tree/main/skills/batch-quality

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

バッチ品質スキル

フルバッチ操作を実行する前に品質を検証することで、無駄なLLM呼び出しを防止します。

このスキルが実際に行うこと

単純なファイル存在チェックとは異なり、このスキルは以下のことを行います。

  1. scillmを使用してN個のサンプルで実際にLLMを実行
  2. JSONレスポンス構造を検証(抜粋、source_qualityなど)
  3. SPARTA契約を使用したDuckDB検証クエリ
  4. task-monitorと統統合して品質ゲートを強制

クイックスタート

cd .pi/skills/batch-quality

# プリフライト: 3サンプルを実際のLLMでテスト
uv run python cli.py preflight \
    --stage 05 \
    --run-id run-recovery-verify \
    --samples 3

# プリフライトが成功したら、バッチを実行
# ...バッチ操作...

# 検証: DuckDBの内容を契約に対してチェック
uv run python cli.py validate \
    --stage 05 \
    --run-id run-recovery-verify \
    --task-name "sparta-stage-05"

コマンド

preflight

フルバッチを実行する前に、実際のLLMでNサンプルをテストします。

uv run python cli.py preflight \
    --stage <stage-name> \
    --run-id <sparta-run-id> \
    --samples 3 \
    --prompt <optional-prompt-file>

実際に行うこと:

  1. ステージのSPARTA契約を読み込む(存在する場合)
  2. 環境変数をチェック(CHUTES_API_KEY、CHUTES_TEXT_MODEL)
  3. 実行のDuckDBに接続
  4. 入力キューからNアイテムをサンプリング
  5. 各サンプルをscillmで実行(実際のLLM呼び出し)
  6. JSONレスポンス構造を検証
  7. 50%以上のサンプルが合格する必要がある

終了コード:

  • 0: 合格 - 続行しても安全
  • 1: 不合格 - 先に問題を修正

validate

SPARTA契約を使用してバッチ出力を検証します。

uv run python cli.py validate \
    --stage <stage-name> \
    --run-id <sparta-run-id> \
    --task-name <task-monitor-name>

実際に行うこと:

  1. SPARTA契約を読み込む(例: 05_extract_knowledge.json)
  2. 契約のすべてのvalidation_queriesをDuckDBに対して実行
  3. 各クエリ結果をexpected_minと比較
  4. 合格/不合格をtask-monitorに通知

契約の例(05_extract_knowledge.json):

{
  "validation_queries": [
    {"name": "url_knowledge_count", "query": "SELECT COUNT(*) FROM url_knowledge", "expected_min": 10},
    {"name": "urls_processed", "query": "SELECT COUNT(*) FROM url_extraction_log WHERE ok = true", "expected_min": 5}
  ]
}

status

現在のプリフライトステータスを確認します(JSON出力)。

uv run python cli.py status

clear

プリフライト状態をクリアします(新しいプリフライトが必要)。

uv run python cli.py clear

SPARTAパイプライン統合

# 1. 検証要件でタスクを登録
uv run python .pi/skills/task-monitor/monitor.py register \
    --name "sparta-stage-05" \
    --require-validation

# 2. プリフライトを実行(実際にLLMをテスト)
uv run python .pi/skills/batch-quality/cli.py preflight \
    --stage 05 \
    --run-id run-recovery-verify \
    --samples 3

# 3. バッチを実行(プリフライトが成功した場合のみ)
uv run python -m sparta.pipeline_duckdb.05_extract_knowledge \
    --run-id run-recovery-verify

# 4. 契約クエリを使用して検証
uv run python .pi/skills/batch-quality/cli.py validate \
    --stage 05 \
    --run-id run-recovery-verify \
    --task-name "sparta-stage-05"

設定

環境変数:

  • SPARTA_ROOT: SPARTAプロジェクトへのパス(デフォルト: ~/workspace/experiments/sparta)
  • CHUTES_API_KEY: LLM呼び出し用のAPIキー
  • CHUTES_API_BASE: APIベースURL(デフォルト: https://llm.chutes.ai/v1)
  • CHUTES_TEXT_MODEL: テキスト抽出用のモデルID

契約の場所: $SPARTA_ROOT/tools/pipeline_gates/fixtures/D3-FEV/contracts/

依存関係

  • typer - CLIフレームワーク
  • duckdb - データベースクエリ
  • scillm - LLMバッチ処理(実際のサンプルテスト用)

必須の飛行中品質ゲート(譲歩不可)

長時間実行されるバッチ操作(特にQRA生成、抽出など)では、プリフライトだけでは不十分です。実行中に品質ゲートを実行する必要があります。

一時停止-評価-診断-調整-再開ループ

Nバッチチェックポイントごとに(例: KNNバッチ5回ごと / 約1000 QRAごと):

  1. 一時停止 — 生成プロセスをSIGSTOP
  2. スナップショット — DuckDBをコピーしてオフライン分析、すぐにSIGCONT
  3. サンプリング — 層化ランダムサンプル(高/中/低グラウンディング層)
  4. 評価 — 各サンプルをチェック: エンティティグラウンディング、回答品質、推論
  5. 診断 — トレンド分析: グラウンディングは低下しているか?エンティティ障害が増加しているか?
  6. 調整 — 劣化している場合: プロンプト、フィルターしきい値、関係スコアを調整
  7. 再開 — 品質がしきい値を満たしている場合のみ
  8. 停止 + 通知 — 品質が下限を下回っている場合、停止して人間に通知

これはオプションではありません。 品質ゲートなしで10万QRAまで実行すると、ゴミが生成され、それを修正するよりも正しく再生成する方が時間がかかります。

QRA品質ゲートスクリプト

# 連続ウォッチドッグ(QRA生成と並行して実行)
python $SPARTA_ROOT/scripts/qra_quality_gate.py watch \
    --run-id run-recovery-verify \
    --batch-interval 5 \
    --samples 10

# 1回限りの評価
python $SPARTA_ROOT/scripts/qra_quality_gate.py assess \
    --run-id run-recovery-verify \
    --samples 20

# チェックポイント間のトレンドを表示
python $SPARTA_ROOT/scripts/qra_quality_gate.py trend \
    --run-id run-recovery-verify

品質しきい値

指標警告停止
平均グラウンディング< 0.65< 0.55
エンティティ障害率> 5%> 10%
サンプル不合格率> 15%> 30%
チェックポイントあたりのグラウンディング低下> 0.05> 0.10

これが重要な理由

ウォッチドッグが受動的だったため、QRAグラウンディングスコアは数時間かけて0.74から0.62に低下しました。適切な品質ゲートがあれば、0.70→0.65の低下を検出し、診断(KNNが簡単な関係を使い果たした、プロンプトドリフトなど)を行い、0.62まで低下させる代わりに対処できたはずです。

主要原則

プリフライトは安価です。バッチの失敗は高コストです。

3サンプルのテストには約$0.01と30秒かかります。 壊れたプロンプトで1000アイテムを実行するには約$3と数時間かかります。

飛行中ゲートは再生成よりも安価です。 1000 QRAごとに10秒間一時停止して品質を確認するコストはほとんどありません。10万QRAを盲目的に実行し、半分が使用不可能であることを後で知るコストは莫大です。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

grahama1970/acceptance-contract

Turn a client brief, zip bundle, directory, or single requirements file into a typed acceptance-contract bundle with extracted requirements, acceptance checks, open questions, an immutable-goal draft, and a create-report-backed decision report. Use when users say acceptance contract, brief to requirements, freeze the goal, create immutable goal, amend immutable goal, build a Battle requirements bundle, or extract requirements from this bundle.

grahama1970/agent-ecosystem

Canonical map and shared contracts for the agent-governance ecosystem: the pi.receipt_envelope.v1 boundary envelope, the component graph, and the rules for which component owns which schema. Use when wiring a skill or extension into the shared receipt world, when asking how shame, triage-error, tau, ask, project-watchdog, ops-herdr, ponytail, and Memory fit together, or when validating an envelope.

grahama1970/agentic-evals

Agentic evaluation of skills using multi-trial fixtures, deterministic command assertions, trajectory checks, safety constraints, and evidence-backed readiness scoring. Use when users ask for agentic evals, multi-trial skill evaluation, skill trajectory validation, or readiness scoring for a skill workflow.

grahama1970/agent-inbox

File-based inter-agent messaging with headless dispatch. Check inbox, send bugs/requests to other projects, automatically spawn headless agents to fix bugs, and track progress via task-monitor.

grahama1970/agents-registry

Generate and query the centralized agent identity registry. Scans .pi/agents/*/AGENTS.md, parses frontmatter, outputs agents-registry.json and optionally syncs to /memory for semantic search.

grahama1970/agent-status

Artifact-driven status surfaces for long-running project-agent work. Maintains status.json, events.jsonl, proof manifests, and a stale-aware STATUS.html so humans can tell where the agent is, what passed, what is still unproven, and what decision or action is next — without dashboard theater.

grahama1970/align

Round-based context alignment before execution. Use when the human, project agent, WebGPT, scillm, ask, dogpile, memory, or project-knowledge may each hold different facts about a task; especially before ambiguous design, infographic, product workflow, high-stakes implementation, plan-iterate, project-infographic, or multi-review work.

grahama1970/analytics

Flexible data science analytics for any dataset. Auto-discovers schema, recommends charts, exports to create-figure. Works with JSONL, JSON, CSV from any source.

grahama1970/analyze-chatterbox-emotions

Evaluate generated Chatterbox voice files as voice-quality artifacts: affect match, arousal/valence proxies, pause placement, intelligibility inputs, clipping, loudness, and discontinuity flags. Use when reviewing Chatterbox emotional tags, pauses, Turbo/base affect delivery, Persona Dream utterance renders, or whether generated speech matches an intended product-facing affect.

grahama1970/analyze-elf

Reverse-engineer features from ELF binaries. Extracts CLI commands, state machines, protocols, Zod schemas, and data models. Automatically generates a /create-walkthrough prosecution brief with Mermaid diagrams. Uses /treesitter for AST analysis of bundled JS/TS source.

grahama1970/animation-vocabulary

Reverse-lookup glossary that turns a vague description of a web animation or motion effect into its exact term ("the bouncy thing when a popover opens" → Pop in; "the iOS rubber-band scroll" → Rubber-banding). Use when the user asks "what's it called when…", or describes a motion effect without knowing its name and wants the right word to prompt an AI or designer with. For naming an effect, not designing or building one.

grahama1970/anonymize-data

Anonymize supported CSV, JSON, UTF-8 text, and SQLite files using an explicit policy through the oai-trial project. Use for anonymize data, pseudonymize exports, redact policy literals, or discover and explicitly approve fuzzy name aliases. The skill is a thin CLI/Docker interface, not another engine.

grahama1970/anvil

Heavy-duty "No-Vibes" debugging and hardening orchestrator. Use this for complex, stubborn bugs where `review-code` has failed, or for "Red Teaming" (hardening) a codebase. Runs multiple agents in parallel (Thunderdome) using git worktree isolation.

grahama1970/apple-design

Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.

grahama1970/argue

Multi-persona structured debate orchestrator. Personas research via /dogpile, consult colleagues via /ask, and argue toward nuanced synthesis on complex questions.

grahama1970/arxiv

Search arXiv for papers and extract knowledge into memory. Use `search` to find papers, `learn` to extract knowledge.

grahama1970/ask

Use when the user asks to query project memory, ask an oracle, use supported browser-backed reviewers, run Tau roundtable/single-handler workflows, ask Pi-native subagents from within Pi, run persona/deep-review workflows, generate image prompts, check OS/project health through composed skills, or run an ask DAG. This skill is the executable /ask runtime; do not replace it with an informal subagent, plain web search, or hand-written review; inside Pi, explicit Pi-native subagent targets are routed through the pi-subagents tool as an Ask target type.

grahama1970/assess

Step back and critically reassess project state. Use when asked to "assess", "step back", "fresh eyes", "check alignment", "sanity check", "health check", "prune documentation", or "evaluate what's working". Offers documentation pruning and doc-code alignment analysis. Offer to run after major changes (don't auto-run).

grahama1970/assistant

Shared GPT + classifier inference gateway for persona monitor tasks. Routes validation and classification through a 4-tier cascade: heuristic → classifier → local GPT → scillm.

grahama1970/assistant-lab

Self-improvement workbench for /assistant. All the tools needed to diagnose, train, evaluate, and promote models in a continuous loop. The "warm pond" where /assistant evolves its own inference stack.

関連スキル