TDD с интеграционными тестами
Ведёт разработку через тесты на публичных интерфейсах: согласует с пользователем швы для тестов, делает по одному циклу red-green на тест, мокает только границы системы, рефакторинг оставляет ревью. Для случаев, когда фичу или баг делают тестами вперёд.
tdd- Автор
- Matt Pocock
- Источник
- mattpocock/skills/skills/engineering/tdd @ abeeaf9
- Лицензия
- MIT · Copyright (c) 2026 Matt Pocock
Об этом скилле
Что делает
Справочник по циклу red-green, нацеленный на тесты, которые стоит хранить. Прежде чем писать тест, агент называет швы — публичные границы, где поведение видно, не заглядывая внутрь, — к каждому пишет строку о том, что он ловит и что пропускает, и просит вас подтвердить список. Каждый цикл — один шов, один падающий тест и минимум кода, чтобы тест прошёл. Рефакторинг из цикла вынесен на этап ревью.
Названы три антипаттерна: тесты, привязанные к реализации (моки внутренних модулей, приватные методы, проверка через базу вместо интерфейса); тавтологичные тесты, где ожидаемое значение считается так же, как в коде; горизонтальная нарезка — сначала все тесты, потом весь код. Агент читает GLOSSARY.md, если он есть, чтобы называть тесты словами предметной области, и учитывает ADR.
В папке два файла-помощника. tests.md сравнивает хорошие и плохие тесты на TypeScript: оформление заказа через публичный API, проверка пользователя через getUser, а не SQL-запросом, итог сверяется с готовым числом, а не пересчитывается тем же способом, что в коде. mocking.md разрешает моки только на границах системы — внешние API, время, случайность — и показывает внедрение зависимостей и клиент в стиле SDK, где на каждый внешний вызов своя функция.
Когда включать и когда не надо
Для фичи или исправления бага тестами вперёд, когда нужны интеграционные тесты через настоящие интерфейсы, а не набор моков.
Не нужен для кода на выброс — авторский Прототип на выброс нарочно обходится без тестов — и для покрытия уже написанного кода: там лучше подойдёт Написание юнит-тестов.
Как поставить и вызвать
Команда установки ниже кладёт всю папку. Агент сам подхватывает скилл по описанию, когда работа идёт через тесты; вызвать вручную:
- Claude Code:
/tddили попросить скилл по имени. - Codex:
$tdd. - Cursor: наберите
/в чате Agent и выберитеtdd.
Пример: /tdd Добавь промокоды в оформление заказа. Сначала предложи швы для тестов.
Когда под вопросом форма интерфейса, скилл вызывает Проектирование глубоких модулей, а рефакторинг оставляет на Ревью по стандартам и спецификации — поставьте оба. Реализация спецификации по тикетам запускает этот скилл в каждом субагенте-исполнителе.
Чем отличается от похожих
Три других TDD-скилла каталога держат рефакторинг внутри цикла. Наша Разработка через тесты (TDD) добавляет базовый прогон и отчёт о каждом красном и зелёном шаге, TDD по методу Superpowers удаляет код, написанный раньше теста, а TDD: красный, зелёный, рефакторинг Адди Османи делает ставку на юнит-тесты. Только этот скилл сначала согласует с вами швы и тестирует только на них. Те три ставятся в папку test-driven-development, этот — в tdd, так что ни с одним из них он не конфликтует.
Установка
Выполните одну команду — она сохранит SKILL.md и файлы, которые он использует, в папку скиллов агента. Claude Code и Codex подхватывают новый скилл без перезапуска; если скилл не появился, перезапустите агента.
Скилл написан на английском — агент поймёт его и ответит вам по-русски.
curl -fsSL --create-dirs -o ~/.claude/skills/tdd/SKILL.md https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md -o ~/.claude/skills/tdd/LICENSE https://anymodel.org/en/skills/matt-pocock/tdd/LICENSE -o ~/.claude/skills/tdd/agents/openai.yaml https://anymodel.org/en/skills/matt-pocock/tdd/agents/openai.yaml -o ~/.claude/skills/tdd/mocking.md https://anymodel.org/en/skills/matt-pocock/tdd/mocking.md -o ~/.claude/skills/tdd/tests.md https://anymodel.org/en/skills/matt-pocock/tdd/tests.md
curl -fsSL --create-dirs -o ~/.agents/skills/tdd/SKILL.md https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md -o ~/.agents/skills/tdd/LICENSE https://anymodel.org/en/skills/matt-pocock/tdd/LICENSE -o ~/.agents/skills/tdd/agents/openai.yaml https://anymodel.org/en/skills/matt-pocock/tdd/agents/openai.yaml -o ~/.agents/skills/tdd/mocking.md https://anymodel.org/en/skills/matt-pocock/tdd/mocking.md -o ~/.agents/skills/tdd/tests.md https://anymodel.org/en/skills/matt-pocock/tdd/tests.md
foreach ($f in 'SKILL.md','LICENSE','agents/openai.yaml','mocking.md','tests.md') { $p = Join-Path "$HOME\.claude\skills\tdd" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/matt-pocock/tdd/$f" -UseBasicParsing -OutFile $p }foreach ($f in 'SKILL.md','LICENSE','agents/openai.yaml','mocking.md','tests.md') { $p = Join-Path "$HOME\.agents\skills\tdd" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/matt-pocock/tdd/$f" -UseBasicParsing -OutFile $p }Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/matt-pocock/tdd/SKILL.md
SKILL.md
Test-Driven Development
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
When exploring the codebase, read GLOSSARY.md (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
What a good test is
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
See tests.md for examples and mocking.md for mocking guidelines.
Seams: where tests go
A seam is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
Test only at pre-agreed seams. Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
Ask: "What's the public interface, and which seams should we test?" Give each proposed seam a one-line note on what it catches and what it misses.
When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
Anti-patterns
- Implementation-coupled: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
- Tautological: the assertion recomputes the expected value the way the code does (
expect(add(a, b)).toBe(a + b), a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec. - Horizontal slicing: writing all tests first, then all implementation. Bulk tests verify imagined behavior: you test the shape of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in vertical slices instead: one test → one implementation → repeat, each test a tracer bullet that responds to what the last cycle taught you.
Rules of the loop
- Red before green. Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
- One slice at a time. One seam, one test, one minimal implementation per cycle.
- Refactoring is not part of the loop. It belongs to the review stage (see the
code-reviewskill), not the red → green implementation cycle.
Подключить через AnyModel API
Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.
AnyModel