tdd
БесплатноБез исполняемых скриптовНе проверенTest-driven development via strict RED-GREEN-REFACTOR cycle. Build aggregates and domain logic with passing tests before any production code (when the…
от fmflurry★ 173 звезды на GitHubОб этом скилле
Test-Driven Development — RED-GREEN-REFACTOR (mandatory baseline + optional ATDD outer loop)
The Core Mandate: RED-GREEN-REFACTOR
Features are built via strict TDD discipline: every behavior emerges via a failing test, minimal production code makes it green, then refactor while tests stay green. Tests and production code never change in the same commit. Hardcoding/faking is expected in the green step, then triangulated away during refactoring or by new tests.
This discipline applies to all layers: domain aggregates, Application handlers, Infrastructure implementations.
Behavior-preserving refactor
A restructure that must keep current behavior does not start RED. /tdd refactor writes characterization tests that pass immediately on the unchanged code, then freezes them. The restructure does not edit those tests. A failure on unchanged code means the test is wrong. New behavior still starts RED.
Optional: Double-Loop Method (ATDD Outer Loop)
For explicit use-case specification, you may adopt a two-loop structure: the outer loop turns a specification into acceptance tests at the handler level (Application layer); the inner loop builds domain behavior via strict RED-GREEN-REFACTOR. The outer loop helps document and test integration points; it is not mandatory.
OPTIONAL OUTER (ATDD): write the WHOLE shopping list of stub acceptance tests (all scenarios)
│
▼ then, one stub at a time:
flesh stub into real red test ──► create Application artifacts ──► still red
│
▼ domain behavior missing?
INNER (TDD): red ─► green ─► refactor (repeat)
│
▼
acceptance test goes green ─► refactor ─► next stub ─► … ─► done
MANDATORY (all features, all layers):
write test ─► compile shells ─► green code ─► refactor ──┐
└─► next behavior
Input: Specification
Before writing any test, a specification exists. It may come from:
- OpenSpec change spec (
openspec/changes/<change>/specs/<capability>/spec.md) with#### Scenario:WHEN/THEN blocks. - Product Owner work item (issue, backlog story, design doc) enumerating scenarios and examples.
- Finalized use-case documentation in
docs/usecases/<context>/(less common going forward; prefer OpenSpec).
Specifications must enumerate every scenario (principal + alternatives) with concrete examples (1–3 per scenario) so the acceptance test list is exhaustive and unambiguous.
Outer Loop (ATDD) — Application Layer & Acceptance Tests (Optional)
When adopting acceptance-test-driven design (ATDD), this is where you turn a specification into working Application plumbing + a test harness. The outer loop owns handlers, commands/queries, read models, repository interfaces, and acceptance tests. This is optional; you may also write these artifacts and their tests via the core RED-GREEN-REFACTOR cycle.
Phase 1 — Build the shopping list (all stubs up front, red, bodyless)
Before implementing anything, turn **every scenario in the spec into a stub acceptance test — one per scenario: the principal/happy path plus every alternative path. This fixes the full scope of the use case as a visible backlog and tells you exactly when the feature is done.
These stubs are red but deliberately bodyless — you cannot write the real Arrange/Act/Assert yet, because you don't yet know how the use case will be exercised against the domain, nor what dependencies it will need. The body emerges in Phase 2, once the inner loop has shaped the domain.
[Fact]
[Trait("Category", "Unit test")]
[Trait("Nature", "Acceptance test")]
public async Task PlaceOrder_WithNoOrderItems_ShouldFailAndReturnError()
{
Assert.False(true, "shopping-list marker: scenario specified, body not writable yet");
}
- One stub per scenario — including alternative flows (errors, edge cases, shipping-fee tiers, …). A scenario's 1–3 examples become
[InlineData]rows when the stub is fleshed out in Phase 2. - Don't create any Application artifacts yet; stubs need only the test project.
- Commit the whole list in one go:
test(<context>): add acceptance test list for <UseCaseName>.
Phase 2 — Tackle the list one stub at a time
Repeat the loop below for each stub until the list is exhausted. Work in order of complexity: the happy path first, in the simplest possible form, then the alternative paths. Commit at every phase (red test, artifacts/compile, green, refactor) — each commit is a restore point.
- Pick one stub and flesh it into a real failing acceptance test at the handler level, expressing the scen
Установить tdd в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл tdd?
Test-driven development via strict RED-GREEN-REFACTOR cycle. Build aggregates and domain logic with passing tests before any production code (when the aggregate is event-sourced, drive it the same way). Optional: outer-loop acceptance tests (Application layer, ATDD) for explicit use-case specification. Mandatory: 80%+ coverage, narrow + wide test layers, domain-driven design, immutable aggregates, no hardcoding. Applies universally to any stack's TDD discipline. See patterns.md for stack-specific examples. [[dotnet-clean-architecture]] for DDD context.
Как установить скилл 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