tdd
БесплатноБез исполняемых скриптовНе проверенGuide through the Red-Green-Refactor cycle for test-driven development
от jellydn★ 130 звёзд на GitHubОб этом скилле
Test-Driven Development (TDD)
Guides you through the complete TDD workflow with Red-Green-Refactor cycle.
Usage
/tdd <ACTION> [ARGUMENTS]
Actions
- start
- Initialize TDD session for a feature - red
- Create failing test (Red phase) - green - Run tests and implement code (Green phase)
- refactor - Guide refactoring process (Refactor phase)
- cycle
- Run complete Red-Green-Refactor cycle - watch - Start test watcher for continuous feedback
- status - Show current test status and next steps
TDD Principles
The Red-Green-Refactor Cycle
- Red: Write a failing test that defines desired behavior
- Green: Write minimal code to make the test pass
- Refactor: Improve code quality while keeping tests green
Best Practices
- Write tests first - Tests define the interface and behavior
- Small steps - Make tiny, incremental changes
- Fast feedback - Run tests frequently for immediate validation
- Clean code - Refactor regularly to maintain quality
- One concept per test - Keep tests focused and atomic
- AAA Pattern - Structure tests as Arrange, Act, Assert
- Black-box testing - Test only public methods and behavior, not implementation details
- Test at an agreed seam - Before writing a test, identify the public interface that exposes the behavior and prefer the highest existing seam
- Independent expectations - Expected values come from a literal, worked example, or spec; do not recompute them with the same algorithm as the implementation
- Vertical slices - Write one meaningful test, implement the minimum, then repeat; avoid writing an entire imagined test suite before learning from the first cycle
Anti-Patterns
- Implementation-coupled tests mock private collaborators or inspect internal state. They fail during harmless refactors and provide weak behavioral confidence.
- Tautological tests derive the expected value with the same logic as the code under test, so both can be wrong together.
- Horizontal slicing writes all tests first and all implementation later. Prefer tracer-bullet slices that exercise one user-visible behavior at a time.
- Unconfirmed seams test a low-level helper only because it is easy to reach. If the behavior matters at a higher interface, test there instead or document why the lower seam is the correct one.
Before the first Red phase, discover the repository's test runner and command from its manifest, task runner, docs, or CI. Do not assume TypeScript, Vitest, npm, or pnpm. Record the exact command used for the red failure and why it failed; a syntax/import error is not a valid Red state.
Check that tests can detect mistakes
For risky behavior, name a plausible wrong implementation and choose an input whose expected result differs from it. A test that still passes when the relevant result or side effect is removed does not protect that behavior. Strengthen the observable assertion, not checks of private calls. If no honest automated test is practical, record the missing seam and use a repeatable manual check; do not claim automated regression coverage.
If the project already uses mutation testing, run it on the affected scope when useful. Inspect uncovered paths and surviving mutations against the contract. Add a test for a meaningful missed behavior; do not chase equivalent mutations or a perfect score, install a new tool by default, or delete code solely because coverage did not exercise it.
Process
For "start ":
- Initialize TDD session for the feature
- Create or identify target source file
- Create corresponding test file if it doesn't exist
- Explain the feature requirements and acceptance criteria
For "red ":
- Create a failing test that describes the desired behavior
- Ensure test fails for the right reason (not syntax errors)
- Run tests to confirm red state
- Explain what the test is validating
For "green":
- Implement minimal code to make failing tests pass
- Focus on making tests pass, not perfect code
- Run tests to confirm green state
- Write just enough code to pass the test
For "refactor":
- Improve code quality while maintaining green tests
- Remove duplication and improve design
- Run tests continuously during refactoring
- Make one refactoring change at a time
Test Template
A test template is available at $SKILL_PATH/templates/test-template.md:
import { describe, it, expect } from "vitest";
import { functionName } from "./module";
describe("functionName", () => {
it("should return formatted output when given valid input", () => {
// Arrange - Setup test scenario
const input = "test input";
const expectedOutput = "expected output";
// Act - Execute the unit under test
const result = functionName(input);
// Assert - Verify expected outcome
expect(result).toBe(expectedOutput);
});
});
Common Commands
- Run tests: `npm t
Установить tdd в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл tdd?
Guide through the Red-Green-Refactor cycle for test-driven development
Как установить скилл tdd?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tdd запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic