Command Palette

Search for a command to run...

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

tdd

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

WHEN using framework-neutral TDD Red-Green-Refactor in any project; NOT for merely classifying runtime evidence or replacing the project's test framework…

mintuzот mintuz★ 38 звёзд на GitHub

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

TDD Best Practices

Core Principle

Every line of new or changed behaviour must be written in response to a failing test.

This is non-negotiable: production code that adds or changes behaviour without a failing test demanding it is not TDD. Refactoring is the one exception: it changes structure while every test stays green, so it demands no new failing test.

Only an actual failing-before and passing-after behaviour test proves a RED/GREEN cycle. A build, typecheck or static page render does not replace it. Direct interaction with an identified running artifact and its observed effects is valid bounded runtime evidence, but does not retroactively prove TDD. Keep that evidence; if a fix preceded its test, reverse only your own fix, preserve unrelated work, and run the discriminating regression against pre-fix code before reapplying the minimal implementation. Report the command, result and what it proves at each transition (principle-prove-it-works).

Use the project's existing runner and test framework across web, iOS, CLI, library and service projects. Retain existing XCTest suites, including measure performance tests; TDD does not require migration to Swift Testing. Framework authoring belongs to the matching skill or the suite's established conventions.

Treat coverage as a by-product of the required behaviour cases, not a separate coverage-only task. Use a coverage report to discover missing business cases; never add implementation-detail assertions merely to satisfy a percentage.

The Sacred Cycle: Red → Green → Refactor

1. RED - Write a Failing Test

Write one test that describes the desired behaviour. Run it against the pre-change production code. The test must fail because the behaviour does not exist yet.

A failure that names the absent unit under test is a valid RED: an unresolved import of the module you are about to create, an undefined export you are about to add, or a wrong, missing, or thrown result from the code under test.

Any other failure is a harness fault, not RED: a wrong import path, a typo in the test file, a missing dependency, a broken runner configuration, or a compile error in unrelated code. Repair the harness fault first, preserving unrelated work and every existing test. Rerun the test before you write production code.

Never duplicate an existing test.

Rules:

  • An unexpected pass is a stop condition. Do not add or adapt the implementation. Inspect the production code and name the reason for the pass: the behaviour already exists, the test is ineffective, or your own production edit is already in the working tree. Strengthen an ineffective test and rerun it. Stop the slice when the behaviour already exists.
  • A pass caused by your own production edit is a false RED, not evidence. Reverse only your own edit, keep the test, and rerun it. Never revert, stash, or reset work you did not write (principle-preserve-unrelated-work).
  • Run the narrowest scope that exercises the new test, then confirm the failure is the one you intended. A broad run buries that failure in unrelated output.
  • Start with the simplest behaviour.
  • Test ONE thing at a time. Write the next test only after the current one is green. Record the behaviours still to come as a list or as empty placeholders, never as further written tests.
  • Test business behaviour, not implementation (principle-test-behavior-not-implementation).
  • Name tests to document intent.
  • Use fresh, explicit test data: factories in JavaScript/TypeScript; simple local immutable Swift values need no factory. Keep owned-resource lifecycle hooks.

2. GREEN - Minimal Implementation

Write the minimum code to make the current test pass. Nothing more.

Rules:

  • No "just in case" logic or speculative features (principle-foundational-thinking).
  • If you are writing more than the test needs, STOP and question why.
  • After focused GREEN, run the relevant existing regression suite as a distinct check before declaring the slice safe (principle-scale-verification).

3. REFACTOR - Assess and Improve

After every GREEN, assess whether refactoring would add value: once per behaviour, not once after a batch. If the code is already clean, move on. The refactoring skill owns the full procedure; these rules apply in every cycle:

  • Secure a reversible GREEN baseline first. Commit the green code when you are allowed to commit; when the user forbids a commit, keep the green state recoverable another way. Never refactor code you cannot restore (principle-capture-the-baseline).
  • Assess the changed, covered code before expanding to untested areas. Name the cleanup justified by the available code. If no worthwhile cleanup is justified, say so and leave that code unchanged. Never invent a cleanup to complete the cycle.
  • Refactor only code that green tests already cover. For untested code, first write a characterisation test that records the output the code actually produces today and passes against unchanged
Полный SKILL.md на GitHub

Установить tdd в Claude Code и Claude Desktop

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

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

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

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

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

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

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

references/patterns.mdreferences/test-factories.mdreferences/violations.mdreferences/workflow-examples.md

FAQ

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

WHEN using framework-neutral TDD Red-Green-Refactor in any project; NOT for merely classifying runtime evidence or replacing the project's test framework; proves failing-before and passing-after tests, then assesses refactoring.

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

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

Скилл tdd запускает скрипты?

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

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

Сравнить tdd с