TDD

You might say

Whenever I ask AI to fix a bug first and add tests afterward, the new tests just mirror the buggy code and stay green—I want it to write a failing test first before touching the implementation.

Test-Driven Development (TDD) is a Red → Green → Refactor rhythm: write a failing test to lock in expected behavior, write the minimal code to pass it, then clean up the code while tests stay green.When fixing a “30 off 200+” bug that misses exactly 200, you first write a test expecting 170 for 200 and watch it fail, then change > to >= until it turns green, and finally extract clean constants without changing behavior. It shines on bug fixes and clear business rules, but fits poorly while exploring visual layouts or unsettled product ideas.
Test-Driven DevelopmentRed-Green-Refactor

You can say this to an AI Agent

Ready to paste into Cursor, Claude Code, or Codex
Structured AI Agent prompt

Fix the “30 off 200+ fails at exactly 200” bug using TDD: first write a failing test and show me the red output, then make the minimal code change to turn it green, and finally refactor while keeping all related tests green.

Want your Agent to translate plain-language UI ideas automatically?Install free VibeHub Skill →
Oil UI Pro. Push AI’s design skills to the limit. Usability, existing projects and stricter review.
Further reading