Show HN: Enforce TDD in Claude Code

3 Nizoss 1 8/3/2025, 5:25:09 PM github.com ↗

Comments (1)

Nizoss · 4h ago
Hi HN!

I built this to automatically enforce Test-Driven Development in Claude Code so that I can focus on designing solutions instead of policing TDD. It uses test reporters to collect the latest results and hooks into file operations to block violations such as premature or over-implementation.

One key takeaway from building this tool is that mechanically blocking TDD violations doesn't automatically lead to better software and that the refactor phase is critical for achieving the software qualities that TDD aims to promote.

The agent often skips the refactor step of the red-green-refactor cycle, or at best performs only superficial changes. The result is code that works, but suffers from tight coupling, duplication, and poor design. This reinforced the idea that TDD’s value lies in the mindset and discipline it fosters, not in mechanically following its rules.

Another takeaway is that measuring “good design” is hard. Finding practical tools to detect unnecessary complexity was trickier than expected. Most tools I evaluated are correlated with line count, which is not very useful, or required extensive setup that made them impractical.

That said, I have added some mechanisms to prompt the agent to perform basic refactoring using lint tools. Deeper, more meaningful refactoring is still up to the developers.

I'm happy with the results so far and have received a lot of positive feedback.

It currently supports these test frameworks:

- JavaScript/TypeScript: Jest and Vitest

- Python: Pytest

- PHP: PHPUnit

I'd love to hear your feedback or questions. Contributions and support for additional frameworks are welcome!