К основному содержанию
скилл · Claude Code

tdd — скилл для Claude Code: что делает и как установить

Скилл управляет циклом красный-зелёный в TDD: проверяет, что тесты пишутся до кода, держит их на уровне публичных интерфейсов и не завязывает на внутреннюю структуру.

  • Автор Matt Pocock
  • Лицензия MIT
  • GitHub ★ 302 251
  • Установок 1 141 062
  • Обновлён 2026-10-22
  • Исходник показан ниже
Открыть на GitHub ↗

Что делает tdd

Скилл задаёт правила для test-driven development в формате красный → зелёный. Тесты проверяют поведение через публичные интерфейсы, не лезут внутрь реализации и переживают рефакторинг. Каждый цикл — один тест, один минимальный код, который его пропускает. Скилл требует заранее согласовать seams — точки, где тесты проверяют поведение, потому что нельзя покрыть всё.

Внутри три антипаттерна: implementation-coupled (тест ломается при рефакторе, хотя поведение не менялось), tautological (assertion пересчитывает ожидаемое значение так же, как код), horizontal slicing (сначала все тесты, потом код — тесты проверяют shape, а не работу). Скилл ссылается на tests.md и mocking.md из того же репозитория, читает GLOSSARY.md проекта, чтобы имена тестов совпадали с доменным языком.

Это для команд, которые строят фичи через TDD, а не пишут тесты задним числом. Если проект не договаривается о seams заранее, скилл добавит накладные расходы без пользы.

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

  • писать тесты до кода в цикле красный-зелёный
  • держать тесты на уровне публичных интерфейсов без привязки к реализации
  • согласовать seams перед первым тестом
  • избежать tautological assertions и horizontal slicing
  • прочитать GLOSSARY.md, чтобы имена в тестах совпадали с доменом

Как установить tdd

Команда из источника

/plugin marketplace add mattpocock/skills

Команда из источника

/plugin install mattpocock-skills@mattpocock

Команда из источника

npx skills add mattpocock/skills --skill tdd -a claude-code

Через Skills CLI (Vercel)

npx skills add mattpocock/skills --skill tdd -a claude-code

Вручную

~/.claude/skills/tdd/SKILL.md

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

Как пользоваться: примеры запросов

  • Напиши тест для checkout с валидной корзиной, потом реализуй минимальный код
  • Проверь seams для модуля аутентификации, какие интерфейсы тестируем
  • Добавь integration test для API эндпоинта через публичный интерфейс

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

SKILL.md · MIT
---
name: tdd
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
---

# 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](tests.md) for examples and [mocking.md](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-review` skill), not the red → green implementation cycle.

© Matt Pocock · MIT · mattpocock/skills

Вопросы о tdd

Как установить tdd в Claude Code?

npx skills add mattpocock/skills --skill tdd -a claude-code, файл скилла окажется в ~/.claude/skills/tdd/SKILL.md.

Что делает скилл tdd?

Управляет циклом красный-зелёный в TDD: тесты пишутся до кода, проверяют поведение через публичные интерфейсы, не завязываются на внутреннюю структуру. Требует заранее согласовать seams — границы, где тесты проверяют поведение.

Что такое seam в контексте tdd?

Публичная граница, на которой тест проверяет поведение без доступа внутрь. Скилл требует согласовать seams перед первым тестом, потому что нельзя покрыть всё, и тестирование должно попадать в критические пути, а не в каждый edge case.

Похожие

skill-creator Помогает создать новый скилл, доработать существующий и проверить результат через тестовые промпты и оценки. Claude Code · Claude.ai ★ 183 434 ↓ 414 180 improve-codebase-architecture Скилл ищет архитектурные узкие места в кодовой базе и показывает варианты углубления модулей в HTML-отчёте. Подойдёт для ревью перед рефакторингом. Claude Code ★ 302 251 ↓ 1 163 035 prototype Создаёт временный прототип, чтобы проверить логику, модель состояния или вид интерфейса до работы над основным кодом. Claude Code ★ 302 251 ↓ 986 201 codebase-design Скилл помогает проектировать модули с небольшим интерфейсом и скрытой внутри сложностью. Подходит для рефакторинга, тестируемости и поиска чистого seam. Claude Code ★ 302 251 ↓ 850 344 diagnosing-bugs Скилл ведёт агента через воспроизводимую диагностику сложных багов и регрессий производительности. Нужен, когда код падает, работает неверно или тормозит. Claude Code ★ 302 251 ↓ 834 802 implement Выполняет задачу по спецификации или тикетам, ведёт работу через тесты и завершает её ревью с коммитом. Подходит для задач, где нужен дисциплинированный цикл разработки. Claude Code ★ 302 251 ↓ 774 700

Смотрите также

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

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