بنقرة واحدة
tdd
Use when implementing any feature or bugfix where correctness matters - before writing implementation code.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when implementing any feature or bugfix where correctness matters - before writing implementation code.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when adding API integration to a module - creates types, contracts, adapter, and service layer.
Use when checking if code follows ARCHITECTURE.md patterns - runs automated conformance checks.
Use when code changes need review before merge - validates architecture, types, security, and test coverage.
Use when checking if code follows ARCHITECTURE.md patterns - runs automated conformance checks.
Use when code changes need review before merge - validates architecture, types, security, and test coverage.
Use when checking if code follows ARCHITECTURE.md patterns - runs automated conformance checks.
| name | tdd |
| description | Use when implementing any feature or bugfix where correctness matters - before writing implementation code. |
| user-invocable | true |
| argument-hint | [feature or function to implement] |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Implement the feature using strict TDD methodology.
Target: $ARGUMENTS
╔══════════════════════════════════════════════════════════════╗
║ NO IMPLEMENTATION CODE WITHOUT A FAILING TEST FIRST ║
╚══════════════════════════════════════════════════════════════╝
For each behavior to implement:
┌───────┐ ┌───────┐ ┌──────────┐
│ RED │ ───► │ GREEN │ ───► │ REFACTOR │
└───────┘ └───────┘ └──────────┘
it('should [expected behavior] when [condition]', () => {
// Arrange
const input = ...;
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toBe(expected);
});
npm test -- --testNamePattern="[test name]"
Write minimum code to pass:
Run test:
npm test -- --testNamePattern="[test name]"
Verify PASSES - Capture output showing success
BLOCKED if test fails (fix before continuing)
Improve code quality:
Run ALL tests:
npm test
Verify ALL PASS
Commit cycle:
git add -A && git commit -m "feat: [behavior] (TDD cycle N)"
Continue cycles until feature is complete.
Every test run must be captured:
──── RED Phase ────
Test: should calculate discount for valid coupon
Running: npm test -- --testNamePattern="calculate discount"
Output:
FAIL src/discount.test.ts
✕ should calculate discount for valid coupon
Expected: 90
Received: undefined
Status: FAIL ✓ - Proceeding to GREEN
──── GREEN Phase ────
Running: npm test -- --testNamePattern="calculate discount"
Output:
PASS src/discount.test.ts
✓ should calculate discount for valid coupon
Status: PASS ✓ - Proceeding to REFACTOR
──── /tdd ────
Feature: [name]
Cycle #1: [behavior]
RED: Test written, FAIL ✓
GREEN: Implemented, PASS ✓
REFACTOR: Cleaned, PASS ✓
Cycle #2: [behavior]
RED: Test written, FAIL ✓
GREEN: Implemented, PASS ✓
REFACTOR: Cleaned, PASS ✓
──── TDD Summary ────
Cycles completed: 2
Tests added: 2
All tests passing: ✓
Coverage: [if available]
| Excuse | Reality |
|---|---|
| "I know it works, no need to test first" | Write the test. If it works, RED phase takes 30 seconds. |
| "This is too simple for TDD" | Simple code has simple tests. No excuse to skip. |
| "I'll write tests after" | Tests written after implementation verify your bias, not correctness. |
| "The test framework isn't set up" | Set it up. That's part of the task. |
| "Just this once I'll skip RED" | "Just this once" is how every shortcut becomes a habit. |