Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

test-driven-development

БесплатноБез исполняемых скриптовНе проверен

Drives implementation test-first through red-green-refactor cycles: one failing test, the minimal code to pass it, then cleanup under green. Use before…

jaktestowacот jaktestowac★ 124 звезды на GitHub

Об этом скилле

Test-Driven Development

Use this skill when tests should drive the design instead of documenting it afterwards. It keeps the work in small, verified steps: one failing test, one minimal implementation, one cleanup, repeat.

This skill is framework-agnostic. It does not assume a runner, an assertion library, or a mocking tool. Detect what the project already uses before the first cycle; if nothing exists yet, ask which runner to target before writing a test.

When to Use

Trigger phrases: "TDD", "test-driven", "test-first", "red-green-refactor", "write the test first", "start with a failing test", "make it fail, then make it pass", "reproduce it with a test before fixing".

Typical situations:

  • build a new behavior test-first
  • fix a bug by reproducing it with a failing test first
  • add safety before refactoring untested code
  • explore an unclear interface by writing the call you wish existed
  • recover a codebase where implementation consistently outruns verification

Reach for this skill before writing production code, not after. If tests are being added to code that already exists, use writing-unit-tests instead.

What TDD Is Here

TDD is a design technique that produces tests as a by-product - not a coverage technique. The loop's value is the pressure it puts on the interface: code that is hard to test first is usually code that is hard to use.

Judge a session by whether the design got clearer and every change was verified, not by the coverage number it produced.

The seam

A seam is the public boundary the test observes behavior through - the interface a real caller would use. Tests live at seams, never against internals.

Every cycle starts by knowing which seam it drives. If you cannot name the seam, you are not ready to write the test.

Seams are agreed, not assumed. Name the seams you intend to test at and get them confirmed before the first test exists. Testing effort is finite; agreeing the seams up front is how it lands on the critical paths and the complex logic instead of on every edge case. Do not write a test at a seam nobody has confirmed.

Choosing the loop shape

Situation Loop shape
A single unit's logic, interface already known Inner loop only - unit-level red-green-refactor
A feature crossing several units Double loop - one failing acceptance test held red on the outside, inner unit cycles until it goes green
The interface itself is the open question Write the call you wish existed as the first test, and let it define the shape
Behavior depends on a real boundary (DB, HTTP, browser) Drive the owned logic with unit cycles; verify the boundary separately in integration coverage

In the double loop, the outer test stays red for several inner cycles. Say so explicitly, so a red suite is not mistaken for broken work.

Never drive the loop with a slow test. Red-green pays for itself only while the feedback is fast. A browser or end-to-end test as the cycle signal costs minutes per iteration, and looping on one for a feature that does not exist yet reliably ends in concluding the test is broken. Drive with the fastest thing that can observe the behavior; in a double loop the outer acceptance test is the cheapest test that proves the feature, not the heaviest. Browser coverage is written after the behavior works.

Before the first cycle, decide whether this change deserves the loop at all - ./resources/tdd-fit-check.md has the decision table and what to verify with when the answer is no.

Core Rules

  • Red before green - no production code is written without a failing test demanding it.
  • Watch it fail for the right reason - a test that fails on a typo, a missing import, or a setup error proves nothing. Read the failure message every time.
  • Evidence, not assertion - actually run the tests at each step and quote the real output. Never claim a test is red or green without having seen it.
  • Minimal implementation - write only enough code to pass the current test. No speculative branches, no features the next test has not asked for yet.
  • One slice at a time - one behavior, one test, one implementation. Never write a batch of tests up front against imagined behavior.
  • Refactor only under green - restructure with the suite passing, and run it again after. Behavior must not change during a refactor step.
  • Test at the public interface - drive the unit through the seam a real caller would use, not through internals.
  • Assert against an independent source of truth - the expected value comes from the spec, a worked example, a known-good literal, or the reported symptom. A value recomputed the way the implementation computes it passes by construction.
  • Never weaken a test to reach green - if an existing assertion has to change, the specification changed. Say that out loud and get it confirmed. Loosening an assertion, deleting a stubborn test, or editing a test to
Полный SKILL.md на GitHub

Установить test-driven-development в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/green-step-strategies.mdresources/tdd-cycle-log-template.mdresources/tdd-fit-check.mdresources/worked-example.md

FAQ

Что делает скилл test-driven-development?

Drives implementation test-first through red-green-refactor cycles: one failing test, the minimal code to pass it, then cleanup under green. Use before writing production code for a new behavior, and whenever the request mentions TDD, test-driven, test-first, red-green-refactor, "write the test first", "start with a failing test", or reproducing a bug with a test before fixing it. Also use when implementation keeps landing before anyone knows how it will be verified.

Как установить скилл test-driven-development?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл test-driven-development запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить test-driven-development с