Command Palette

Search for a command to run...

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

test-driven-development

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

Use when implementing features or fixing bugs - enforces RED-GREEN-REFACTOR cycle requiring tests to fail before writing code

withzombiesот withzombies★ 81 звезда на GitHub14 установок в других каталогах

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

Write the test first, watch it fail, write minimal code to pass. If you didn't watch the test fail, you don't know if it tests the right thing. LOW FREEDOM - Follow these exact steps in order. Do not adapt.

Violating the letter of the rules is violating the spirit of the rules.

Phase Action Command Example Expected Result
RED Write failing test cargo test test_name FAIL (feature missing)
Verify RED Confirm correct failure Check error message "function not found" or assertion fails
GREEN Write minimal code Implement feature Test passes
Verify GREEN All tests pass cargo test All green, no warnings
REFACTOR Clean up code Improve while green Tests still pass

Iron Law: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

**Always use for:** - New features - Bug fixes - Refactoring with behavior changes - Any production code

Ask your human partner for exceptions:

  • Throwaway prototypes (will be deleted)
  • Generated code
  • Configuration files

Thinking "skip TDD just this once"? Stop. That's rationalization.

1. RED - Write Failing Test

Write one minimal test showing what should happen.

Requirements:

  • Test one behavior only ("and" in name? Split it)
  • Clear name describing behavior
  • Use real code (no mocks unless unavoidable)

See resources/language-examples.md for Rust, Swift, TypeScript examples.

2. Verify RED - Watch It Fail

MANDATORY. Never skip.

Run the test and confirm:

  • ✓ Test fails (not errors with syntax issues)
  • ✓ Failure message is expected ("function not found" or assertion fails)
  • ✓ Fails because feature missing (not typos)

If test passes: You're testing existing behavior. Fix the test. If test errors: Fix syntax error, re-run until it fails correctly.

3. GREEN - Write Minimal Code

Write simplest code to pass the test. Nothing more.

Key principle: Don't add features the test doesn't require. Don't refactor other code. Don't "improve" beyond the test.

4. Verify GREEN - Watch It Pass

MANDATORY.

Run tests and confirm:

  • ✓ New test passes
  • ✓ All other tests still pass
  • ✓ No errors or warnings

If test fails: Fix code, not test. If other tests fail: Fix now before proceeding.

5. REFACTOR - Clean Up

Only after green:

  • Remove duplication
  • Improve names
  • Extract helpers

Keep tests green. Don't add behavior.

6. Repeat

Next failing test for next feature.

Developer writes implementation first, then adds test that passes immediately // Code written FIRST def validate_email(email): return "@" in email # Bug: accepts "@@"

// Test written AFTER def test_validate_email(): assert validate_email("[email protected]") # Passes immediately! // Missing edge case: assert not validate_email("@@")

When test passes immediately: - Never proved the test catches bugs - Only tested happy path you remembered - Forgot edge cases (like "@@") - Bug ships to production

Tests written after verify remembered cases, not required behavior.

**TDD approach:**
  1. RED - Write test first (including edge case):
def test_validate_email():
    assert validate_email("[email protected]")  # Will fail - function doesn't exist
    assert not validate_email("@@")            # Edge case up front
  1. Verify RED - Run test, watch it fail:
NameError: function 'validate_email' is not defined
  1. GREEN - Implement to pass both cases:
def validate_email(email):
    return "@" in email and email.count("@") == 1
  1. Verify GREEN - Both assertions pass, bug prevented.

Result: Test failed first, proving it works. Edge case discovered during test writing, not in production.

Developer has already written 3 hours of code without tests. Wants to keep it as "reference" while writing tests. // 200 lines of untested code exists // Developer thinks: "I'll keep this and write tests that match it" // Or: "I'll use it as reference to speed up TDD" **Keeping code as "reference":** - You'll copy it (that's testing after, with extra steps) - You'll adapt it (biased by implementation) - Tests will match code, not requirements - You'll justify shortcuts: "I already know this works"

Result: All the problems of test-after, none of the benefits of TDD.

**Delete it. Completely.**
git stash  # Or delete the file

Then start TDD:

  1. Write first failing test from requirements (not from code)
  2. Watch it fail
  3. Implement fresh (might be diff
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

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

resources/example-workflows.mdresources/language-examples.md

FAQ

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

Use when implementing features or fixing bugs - enforces RED-GREEN-REFACTOR cycle requiring tests to fail before writing code

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

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

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

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

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

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