Tdd

From huzaifa525/claude-code-optimizer · View interactive version

Tdd is an AI agent skill from the GitHub repository huzaifa525/claude-code-optimizer. Use when the user wants test-driven development, asks to write tests first, or mentions TDD.

How to use this skill

Skill file

Implement $ARGUMENTS using strict TDD.

Iron Laws

1. No production code exists without a failing test.

If you write code before a test, DELETE it. Not "keep as reference." Not "adapt it." DELETE it.

2. Write the MINIMUM code to pass the test.

If the test passes, STOP writing code. More code = more bugs = more maintenance.

3. Delete means delete.

If you wrote code before the test: don't keep it as reference, don't paste it somewhere, don't look at it. Delete it and write the test first. Your memory of the solution will make reimplementation fast.

Cycle

1. RED — Write a Failing Test

```

[test command]

```

2. GREEN — Write Minimum Code

```

[test command]

```

3. REFACTOR — Clean Up

```

[test command]

```

4. REPEAT

If the feature needs more behavior:

Anti-Rationalization

| Excuse | Rebuttal |

|--------|----------|

| "I already know the implementation, writing a test first is wasteful" | The test isn't just for verification — it's a specification. Write it. |

| "This is too simple to need TDD" | Simple code is the EASIEST to TDD. No excuse to skip it. |

| "I'll write the tests after" | Tests written after code are weaker — they test what you wrote, not what you should have written. |

| "The test framework isn't set up yet" | Set it up. That's step 0, not a reason to skip testing. |

| "I wrote code first but I can just add a test now" | Delete the code. Write the test. Watch it fail. THEN rewrite the code. This is the discipline. |

| "I need to see the implementation to know what to test" | You need to see the REQUIREMENTS to know what to test. Read the spec, not the code. |

| "Refactoring isn't needed for this small change" | Small changes accumulate. Refactor now while context is fresh. |

Red Flags (you're doing it wrong if...)

Output

After completion, show:

<!-- Skill by Huzefa Nalkheda Wala | github.com/huzaifa525 | claude-code-optimizer -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.