К основному содержанию
скилл CX Codex

testing-llm — скилл для Claude Code: тесты ИИ и установка

Скилл testing-llm помогает тестировать функции с языковыми моделями: подменять ответы, оценивать качество RAG и проверять структурированный вывод. Включается при разработке тестов для ИИ-функций.

MIT 126 установок ★ 305 обновлён 2026-11-14

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add yonatangross/orchestkit --skill testing-llm -a claude-code
Открыть на GitHub

Что делает testing-llm

Для модульных тестов скилл предлагает подменять ответы модели, а для интеграционных — записывать взаимодействия через VCR.py. Это позволяет сделать проверки детерминированными; в CI живые API языковых моделей вызывать нельзя.

Для оценки ответов используются метрики DeepEval и RAGAS, включая проверку релевантности и соответствия контексту. Скилл также описывает проверку структурированного вывода через схемы Pydantic и агентный процесс с этапом исправления падающих тестов. Для DeepEval нужна версия не ниже 4.2.7, для RAGAS — не ниже 0.4.0.

Какие задачи решает

  • подменить ответы модели в модульных тестах
  • записать взаимодействия с моделью для интеграционных тестов
  • оценить релевантность и достоверность ответов RAG
  • проверить вывод модели по схеме Pydantic
  • исправить падающие тесты с помощью агента

Примеры запросов агенту

  • Добавь модульный тест для функции, которая вызывает языковую модель, и подмени ответ модели.
  • Настрой оценку качества ответов RAG с помощью DeepEval и RAGAS.
  • Проверь структурированный ответ модели по схеме Pydantic.

Как установить testing-llm

1Через Skills CLI (Vercel)

npx skills add yonatangross/orchestkit --skill testing-llm -a claude-code

2Вручную: положить файлы

~/.claude/skills/testing-llm/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/testing-llm/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о testing-llm

Как установить testing-llm в Claude Code?

Выполните npx skills add yonatangross/orchestkit --skill testing-llm -a claude-code. Файл скилла будет доступен по пути ~/.claude/skills/testing-llm/SKILL.md.

Что делает testing-llm?

Скилл описывает тестирование функций с языковыми моделями: моки для модульных тестов, запись запросов через VCR.py и оценку качества ответов с DeepEval и RAGAS.

Какие версии DeepEval и RAGAS нужны?

В настройках скилла указаны DeepEval версии >=4.2.7 и RAGAS версии >=0.4.0.

Исходный текст

SKILL.md · MIT
---
name: testing-llm
license: MIT
compatibility: "Claude Code 2.1.277+."
description: "LLM testing patterns: mocked responses, DeepEval and RAGAS evaluation, structured output checks, agentic tests. Use when testing AI features."
user-invocable: false
disable-model-invocation: false
targets:
  - library: "deepeval"
    version: ">=4.2.7"
  - library: "ragas"
    version: ">=0.4.0"
metadata:
  owner-agent: "test-generator"
  category: document-asset-creation
  version: "2.1.0"
  author: "OrchestKit"
  complexity: "medium"
  tags: "testing, llm, ai, deepeval, ragas, evaluation, mocking"
allowed-tools: "Read Glob Grep WebFetch WebSearch"
---

# LLM & AI Testing Patterns

Patterns and tools for testing LLM integrations, evaluating AI output quality, mocking responses for deterministic CI, and applying agentic test workflows (planner, generator, healer). Of that trio only the healer keeps a local reference here; the planner and generator stages belong to the `testing-e2e` skill.

## Quick Reference

| Area | File | Purpose |
|------|------|---------|
| **Rules** | `rules/llm-evaluation.md` | DeepEval quality metrics, Pydantic schema validation, timeout testing |
| **Rules** | `rules/llm-mocking.md` | Mock LLM responses, VCR.py recording, custom request matchers |
| **Reference** | `references/ork-delta.md` | House rules the vendor docs do not carry: GEval and RAGAS API corrections, threshold direction, cassette path, golden-dataset and latency budgets |
| **Reference** | `references/healer-agent.md` | Auto-fixes failing tests (selectors, waits, dynamic content) |
| **Reference** | `references/langfuse-v4.md` | Langfuse Python SDK v4 tracing and dataset runs, plus the non-zero throughput assertion |
| **Checklist** | `checklists/llm-test-checklist.md` | Complete LLM testing checklist (setup, coverage, CI/CD) |

## Upstream coverage (do not restate)

DeepEval, RAGAS, VCR.py and Playwright document themselves. This skill carries only the
OrchestKit delta (`references/ork-delta.md`) plus the house subsets in `rules/` and
`checklists/`. Fetch the source below instead of expecting the material here.

| Topic | Source |
|-------|--------|
| Full DeepEval metric catalog and per-metric constructor arguments (the house threshold table and the two-metric quick start stay in this file, `rules/llm-evaluation.md` and `checklists/llm-test-checklist.md`) | https://deepeval.com/docs/metrics-introduction |
| `GEval` custom criteria: `evaluation_params`, `evaluation_steps`, `criteria` (the house import correction stays in `references/ork-delta.md`) | https://deepeval.com/docs/metrics-llm-evals |
| `HallucinationMetric` arguments (the house 0.3 ceiling and the inverted-direction warning stay in `references/ork-delta.md`) | https://deepeval.com/docs/metrics-hallucination |
| RAGAS metric catalog (`Faithfulness`, `LLMContextRecall`, `FactualCorrectness`) | https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/ |
| `EvaluationDataset` construction (the house note on the post-0.2 field names stays in `references/ork-delta.md`) | https://docs.ragas.io/en/stable/concepts/components/eval_dataset/ |
| VCR.py configuration keys (the house record-mode gate and header filters stay in `rules/llm-mocking.md`) | https://vcrpy.readthedocs.io/en/latest/configuration.html |
| Playwright Planner and Generator agents, `init-agents` CLI and generated files (the house healer subset stays in `references/healer-agent.md`) | https://playwright.dev/docs/test-agents |
| Playwright semantic locator ladder used by generated tests | `testing-e2e` skill (`rules/e2e-playwright.md`) plus https://playwright.dev/docs/locators |
| Confidence intervals over metric score samples | https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.t.html |

## When to Use This Skill

- Testing code that calls LLM APIs (OpenAI, Anthropic, etc.)
- Validating RAG pipeline output quality
- Setting up deterministic LLM tests in CI
- Building evaluation pipelines with quality gates
- Applying agentic test patterns (plan -> generate -> heal)

## LLM Mock Quick Start

Mock LLM responses for fast, deterministic unit tests:

```python
from unittest.mock import AsyncMock, patch
import pytest

@pytest.fixture
def mock_llm():
    mock = AsyncMock()
    mock.return_value = {"content": "Mocked response", "confidence": 0.85}
    return mock

@pytest.mark.asyncio
async def test_with_mocked_llm(mock_llm):
    with patch("app.core.model_factory.get_model", return_value=mock_llm):
        result = await synthesize_findings(sample_findings)
    assert result["summary"] is not None
```

**Key rule:** NEVER call live LLM APIs in CI. Use mocks for unit tests, VCR.py for integration tests.

## DeepEval Quality Quick Start

Validate LLM output quality with multi-dimensional metrics:

```python
from deepeval import assert_test
from deepeval.test_case import LLMTestCase
from deepeval.metrics import AnswerRelevancyMetric, FaithfulnessMetric

test_case = LLMTestCase(
    input="What is the capital of France?",
    actual_output="The capital of France is Paris.",
    retrieval_context=["Paris is the capital of France."],
)

assert_test(test_case, [
    AnswerRelevancyMetric(threshold=0.7),
    FaithfulnessMetric(threshold=0.8),
])
```

## Library notes (DeepEval, RAGAS)

**DeepEval** metrics expose a `reason` field alongside the numeric score when `include_reason=True`, so a failing CI build gets a human-readable explanation without a second LLM call:

```python
metric = AnswerRelevancyMetric(threshold=0.7, include_reason=True)
metric.measure(test_case)
print(metric.score, metric.reason)
# 0.62  "Response addresses the topic but omits the date asked for."
```

**RAGAS** uses a class-based metric API — instantiate metric classes and pass an `EvaluationDataset`. `llm=` is optional; omit it to use the configured default grader:

```python
from ragas import evaluate
from ragas.metrics import Faithfulness, LLMContextRecall

result = evaluate(
    dataset,
    metrics=[Faithfulness(), LLMContextRecall()],
)
```

> Bump floors: `deepeval >= 4.0`, `ragas >= 0.4`.

House rules the vendor docs do not state (the inverted `HallucinationMetric` threshold,
the `gpt-5-mini` grader default, the 95 percent confidence-interval recipe, and the
latency, quality-gate and truncation numbers) are recorded in `references/ork-delta.md`.
Read that before writing either library's setup code.

## Quality Metrics Thresholds

| Metric | Threshold | Purpose |
|--------|-----------|---------|
| Answer Relevancy | >= 0.7 | Response addresses question |
| Faithfulness | >= 0.8 | Output matches context |
| Hallucination | <= 0.3 | No fabricated facts |
| Context Precision | >= 0.7 | Retrieved contexts relevant |
| Context Recall | >= 0.7 | All relevant contexts retrieved |

## Structured Output Validation

Always validate LLM output with Pydantic schemas:

```python
from pydantic import BaseModel, Field

class LLMResponse(BaseModel):
    answer: str = Field(min_length=1)
    confidence: float = Field(ge=0.0, le=1.0)
    sources: list[str] = Field(default_factory=list)

async def test_structured_output():
    result = await get_llm_response("test query")
    parsed = LLMResponse.model_validate(result)
    assert 0 <= parsed.confidence <= 1.0
```

## VCR.py for Integration Tests

Record and replay LLM API calls for deterministic integration tests:

```python
@pytest.fixture(scope="module")
def vcr_config():
    import os
    return {
        "record_mode": "none" if os.environ.get("CI") else "new_episodes",
        "filter_headers": ["authorization", "x-api-key"],
    }

@pytest.mark.vcr()
async def test_llm_integration():
    response = await llm_client.complete("Say hello")
    assert "hello" in response.content.lower()
```

## Agentic Test Workflow

The three-agent pattern for end-to-end test automation:

```
Planner -> specs/*.md -> Generator -> tests/*.spec.ts -> Healer (auto-fix)
```

1. **Planner**: Explores your app and produces Markdown test plans. Owned by the
   `testing-e2e` skill (`rules/e2e-ai-agents.md`); the CLI and its generated files are
   documented at https://playwright.dev/docs/test-agents.

2. **Generator**: Converts Markdown specs into Playwright tests, validating selectors
   against the running app. Also owned by `testing-e2e` (`rules/e2e-ai-agents.md`); the
   locator ladder it follows lives in `testing-e2e` `rules/e2e-playwright.md`.

3. **Healer** (`references/healer-agent.md`): Automatically fixes failing tests by replaying failures, inspecting the DOM, and patching locators/waits. Max 3 healing attempts per test.

Agent initialization is CLI-only (`npx playwright init-agents`); there is no config key
for it. Only the healing stage keeps a local reference, because its 3-attempt ceiling and
its refusal to touch test logic are house limits rather than vendor defaults.

## Edge Cases to Always Test

For every LLM integration, cover these paths:

- **Empty/null inputs** -- empty strings, None values
- **Long inputs** -- truncation behavior near token limits
- **Timeouts** -- fail-open vs fail-closed behavior
- **Schema violations** -- invalid structured output
- **Prompt injection** -- adversarial input resistance
- **Unicode** -- non-ASCII characters in prompts and responses

See `checklists/llm-test-checklist.md` for the complete checklist.

## Anti-Patterns

| Anti-Pattern | Correct Approach |
|-------------|-----------------|
| Live LLM calls in CI | Mock for unit, VCR for integration |
| Random seeds | Fixed seeds or mocked responses |
| Single metric evaluation | 3-5 quality dimensions |
| No timeout handling | Always set < 1s timeout in tests |
| Hardcoded API keys | Environment variables, filtered in VCR |
| Asserting only `is not None` | Schema validation + quality metrics |

## Related Skills

- `ork:testing-unit` — Unit testing fundamentals, AAA pattern
- `ork:testing-integration` — Integration testing for AI pipelines
- `ork-extras:golden-dataset` — Evaluation dataset management
- `ork:testing-e2e` owns the Planner and Generator agent workflow and the Playwright locator ladder
- `ork:testing-perf` owns the latency and load budgets referenced in `references/ork-delta.md`

© OrchestKit · MIT · yonatangross/orchestkit

Похожие скиллы

Все скиллы по теме «Тесты и QA» →
ia-qa mcp llm and RAG testing - Dev/QA toolbox ia-qa ia-qa mcp llm and RAG testing - Dev/QA toolbox — MCP-сервер для Claude Code, который проверяет LLM, RAG и задачи Dev/QA: считает токены и стоимость запросов, делит текст на чанки и сравнивает промпты. CX Codex +1 12 266установок deepeval Confident AI Добавляет метрики DeepEval — фреймворка для тестирования систем на больших языковых моделях. Запускает оценку агентов, RAG-пайплайнов и чат-ботов по критериям G-Eval, галлюцинаций, релевантности и выполнения задач. ★ 19 587звёзд репо llm-testing Eyadkelleh Скилл llm-testing для Claude Code, Codex, Cursor и других агентов содержит готовые тест-кейсы для проверки LLM на утечки данных, смещения и устойчивость к adversarial-промптам. CX Codex +1 621установок python-testing-patterns Seth Hobson Скилл python-testing-patterns помогает писать тесты Python с pytest, фикстурами и моками. Подходит для настройки тестового набора и отладки падающих проверок. CX Codex +1 36 943установок python-testing affaan-m Скилл python-testing задаёт подход к тестам Python на pytest: TDD, фикстуры, моки, параметризацию и проверку покрытия. Пригодится при создании и ревью тестов. CX Codex +1 6 800установок vitest-testing secondsky Скилл vitest-testing для Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI и OpenCode, который добавляет знания о Vitest — фреймворке для юнит- и интеграционных тестов на TypeScript/JavaScript. CX Codex +1 1 300установок

Из того же набора86

Весь набор →
user-research Скилл user-research для структурированного исследования пользователей: персоны, карты пути, интервью, тестирование юзабилити и card sorting. Помогает понять, что нужно пользователям, и обоснованно проектировать продукт. CX Codex +1 134установок brainstorm Скилл brainstorm собирает варианты решения через параллельных агентов, фильтрует их по реализуемости и помогает сравнить компромиссы. Код он не строит и не чинит. CX Codex +1 133установок setup Скилл setup сканирует проект, определяет стек, советует скиллы и MCP-серверы, а затем считает готовность проекта. Есть режимы повторного сканирования и настройки. CX Codex +1 133установок testing-integration Скилл testing-integration помогает проверять границы API и сервисов: интеграционные тесты, контракты Pact и валидацию схем Zod. Включается при работе с тестами API или взаимодействием сервисов. CX Codex +1 131установок prioritization Скилл prioritization для ранжирования задач бэклога методами RICE, WSJF, ICE, MoSCoW и анализом альтернативных издержек. Агент подсчитывает баллы, строит сравнительные таблицы и обосновывает выбор между конкурирующими фичами. CX Codex +1 125установок competitive-analysis Скилл competitive-analysis формирует анализ рынка по пяти силам Портера, SWOT-матрицы, профили конкурентов и карты позиционирования. Включается при оценке ниши или подготовке сейлз-батлкард. CX Codex +1 125установок visualize-plan Скилл visualize-plan показывает план изменений в виде схемы «до и после», карты рисков и порядка выполнения. Запускается при разборе плана или изменений в текущей ветке. CX Codex +1 124установок market-sizing Скилл market-sizing считает TAM, SAM и SOM двумя методами — top-down и bottom-up — и сверяет их. Запускается при подготовке слайдов для питча или оценке размера рынка. CX Codex +1 124установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой