بنقرة واحدة
tdd
Use when writing any new code or feature to enforce the TDD red-green-refactor cycle.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when writing any new code or feature to enforce the TDD red-green-refactor cycle.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use whenever writing, modifying, or reviewing tests in this project. Defines the expected style for unit tests and API controller (slice / narrow integration) tests. Stack-agnostic — examples are in Kotlin, but principles apply to any language/framework.
Use whenever writing, modifying, or reviewing UI tests in React projects. Defines naming, structure, query priority, render conventions, and mocking patterns for component and hook tests. Framework-agnostic on the component library; assumes React + Testing Library + a modern test runner (Vitest or Jest). Inherits the high-level principles from [[testing]].
Clean Architecture conventions — Vaughn Vernon-shaped folder structure (aggregate-per-package on the write side, peer query/ folder on the read side, application/ holding UseCases not Services), dependency rules, design patterns, repository conventions, and code conventions. Invoke this skill when you need to know where layers live, what can import what, or how to structure production code.
HTTP / REST boundary rules — controller shape, REST URL design, request/response modeling, validation ownership, status codes, HTTP semantics, idempotency. Stack-agnostic. Invoke this skill when designing or reviewing a new HTTP endpoint, modeling request/response DTOs or error payloads, choosing HTTP methods or status codes, or drawing the line between input-format validation and domain rule enforcement.
CQRS conventions — when to split write side (Repository + UseCase) from read side (Query). Invoke when planning a new port, deciding whether a UseCase is needed, naming a port, shaping a read model, choosing where to place it, or evaluating whether a class is a pass-through middleman. Stack-agnostic — example is in Kotlin.
Use when working on untested, tangled, or outdated code — adding tests to a system that has none, untangling shared mutable state, replacing deprecated patterns, language/framework migrations, dependency rewrites. Follows Michael Feathers' "Working Effectively With Legacy Code" approach. Language-agnostic.
| name | tdd |
| description | Use when writing any new code or feature to enforce the TDD red-green-refactor cycle. |
| argument-hint | <what-to-implement> |
| allowed-tools | Read, Write, Edit, Glob, Grep, Bash |
Implement using strict TDD: $ARGUMENTS
No production code without a failing test first. If you didn't watch the test fail, you don't know if it tests the right thing. Code written before a test must be deleted and reimplemented from the test — no exceptions.
The cycle below tells you how to do red-green-refactor. ZOMBIES and the Transformation Priority Premise tell you which test to write next.
Walk the ZOMBIES categories in order — earlier categories force the simplest production transformations and are usually the strongest discriminators for catching inversions and off-by-ones. Resist jumping straight to "many" or "mixed" — One tests carry more information than they look like they do.
Each new test should force the next-simplest transformation in production code (Uncle Bob's TPP). Rough priority, simplest first:
if)The implementation that emerges is whatever satisfies the contract — SQL, in-memory, HTTP, whatever. It is downstream of the test list, not the source of it. If you find yourself designing tests against an existing implementation (e.g. an already-written SQL string), you are working in reverse: write the tests against the port contract and let the implementation be accidental.
Pair every test you pick with the mutation question (see the testing skill): if no mutation of the production code would make this test fail, the test is vacuous.
References: James Grenning, "TDD Guided by Zombies"; Robert C. Martin, "The Transformation Priority Premise".
Each behavior is one tracer bullet: RED → GREEN → REFACTOR. Then move to the next behavior. Do not batch tests across behaviors.
Then return to RED for the next behavior.
Do not write all of a layer's tests first, then all of the production code. Tests written in bulk validate imagined behavior, not actual behavior — they commit to a contract guess that no running code has confirmed. Each cycle should learn from the previous one.
A plan from an architect tells you which tests and what order. It does not tell you the test's setup, assertions, or fake API — those are design decisions made during the cycle, one test at a time.
LLMs generate plausible excuses for skipping or deferring TDD. Common ones and why they fail:
| Excuse | Reality |
|---|---|
| "I'll add tests after the implementation" | You won't, or you'll write tests that pass by definition — they validate what you wrote, not what should work. |
| "This is too simple to test" | Simple code breaks too. The test takes 30 seconds. |
| "I need to see the implementation shape first" | That's a spike. Spike, throw it away, then TDD. |
| "I'm just refactoring, not adding behavior" | Existing tests must pass throughout. If there are no tests, write characterization tests first. |
| "Writing the test first would be slower" | TDD is faster than debugging. It catches errors at the cheapest moment. |
| "The test is hard to write — I'll come back to it" | Hard-to-test code is hard-to-use code. The test is design feedback. Listen to it. |
If you catch yourself composing an excuse not on this list, it is still an excuse.
Response: delete code written without a test. Restart from RED.
testing skill.