test-driven-development
Use when implementing any feature or bugfix, before writing implementation code. Observe the required behavior first. Do not use it to keep a green suite that…
от jeremybrasher★ 41 звезда на GitHub
Установить test-driven-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Test-Driven Development (TDD)
Overview
Write the test first. Watch it fail. Write minimal code to pass.
Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.
Violating the letter of the rules is violating the spirit of the rules.
When to Use
Always:
- New features
- Bug fixes
- Refactoring
- Behavior changes
Exceptions (ask your human partner):
- Throwaway prototypes
- Generated code
- Configuration files
Thinking "skip TDD just this once"? Stop. That's rationalization.
Do not use this to:
- Write tests after the production code already exists (that is verification, not TDD)
- Keep a green suite that encodes the wrong object
- Add coverage for its own sake
- Explore a design you intend to throw away (spike first, then start over with TDD)
- Produce a test plan, a coverage report, or a testing strategy document
Intake — before RED
You need three things. Nothing else starts. Do not write a test. Do not write production code.
- A named required behavior. What should the system do, for whom, after this change? "Add tests," "make it work," or "cover this file" is not enough.
- A way to tell the object is wrong. A concrete failure a user would see, or a production change that would be a bug if it shipped. If you cannot name what would be wrong if we shipped without this, you do not have a requirement.
- A surface you can exercise. Code, an API, or a behavior you can call from a test. A requirement with no observable surface is not a TDD object yet.
If any of those is missing, stop. Say what is missing and what you need. Do not invent a test to keep moving. Do not write production code "so we have something to test."
The test is not the intake. The requirement is. A failing test written against a guessed requirement is generation, not observation.
HOLD — stop and return this, not a green suite
When you cannot proceed, return the gap. Do not fill it with a passing test or a stub that makes a guessed test green.
| Condition | What is missing | What it needs | Return instead of a green suite |
|---|---|---|---|
| No named required behavior | The object of the change | What the system should do, for whom, after this change | "I need the required behavior, not a test idea. I will not invent one." |
| Cannot say what would be wrong if we shipped without it | A failure the user would see | A concrete wrong outcome, or a production change that would be a bug | "If I cannot name the wrong outcome, I do not have a requirement. Holding." |
| No observable surface | Something a test can call | Code, API, or behavior you can exercise | "No surface to exercise. I will not write a test against a guess." |
| Test would encode a guessed requirement | Confirmation the requirement is the right object | Human yes on the named behavior | The named behavior and the question. No test. No production code. |
| Green suite would pass and the required behavior would still be missing or inverted | A test whose green state is the required object | Rewrite the test against the requirement, or HOLD | "A green suite can be the wrong object. I will not keep these tests." |
| Code already written, no failing test first | A deleted implementation | Delete, then RED | Delete the code. Do not "adapt" it. |
| Test passes immediately | A test of missing behavior | Fix the test until it fails for the right reason | The unexpected pass and why. No production change. |
| Test errors instead of failing | A correct failure | Fix the error, re-run until it fails because the feature is missing | The error. No GREEN. |
| Exception surface (prototype, generated, config) without a human yes | Authority to skip | Explicit yes from the partner | The exception and the question. No skip on your own. |
Companion writing-good-tests.md missing |
Nothing — that file is optional | The method already in this file | Do not stall. Use the method card below. |
A HOLD is a return value, not a delay before you write the test anyway.
Defaults: cut first
This operation defaults to less, not more.
- No production code without a failing test first. Write code before the test? Delete it. Start over.
- Do not keep untested code as "reference." Do not "adapt" it while writing tests. Delete means delete.
- Do not add a feature, option, or helper the current test does not require.
- Do not refactor other code in GREEN. GREEN is the smallest change that makes this test pass.
- Do not add a second test until this one has gone RED for the right reason, then GREEN, then (if needed) REFACTOR.
- Prefer one behavior per test. "And" in the name means split, not expand.
- Prefer a real dependency over a mock. A mock is allowed only when the real one is slow or external and you have already named why.
- Extra files, extra fixtures, or a new test harness need a reason from the requirement — not from a habit of completeness.
- If
writing-good-tests.mdis missing, do not create it
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- LICENSE
- SCORE.json
- SOURCE.md
- writing-good-tests.md
FAQ
Что делает скилл test-driven-development?
Use when implementing any feature or bugfix, before writing implementation code. Observe the required behavior first. Do not use it to keep a green suite that encodes the wrong object, to write tests after the code, or to ship production code without a failing test.
Как установить скилл test-driven-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-driven-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…