ai-dev-guidance

Test-Driven Design Misapplication

When AI assistants blindly follow existing test patterns as a blueprint for implementation, rather than approaching the problem from first principles. Instead of using tests to verify a thoughtfully designed solution, the implementation becomes constrained by test structure.

How to Spot It

Look for these signs:

Why It’s Harmful

What to Do About It

When you see this happening:

  1. Say “Let’s set aside the tests for a moment and think about how we’d solve this problem naturally.”
  2. Ask “Why are we structuring the code this way? Is it just to match the tests?”
  3. Refocus: “What was the original problem we’re trying to solve here?”
  4. Suggest: “If we were designing this from scratch without considering the tests, what would be the clearest approach?”

To prevent it next time:

  1. Start with the domain: “Let’s model the domain first, then figure out how to test it.”
  2. Separate concerns: “First we’ll design the solution, then we’ll figure out how to test it.”
  3. Focus on fundamentals: “What are the core concepts and operations in this domain?”
  4. Clarify purpose: “Tests should verify our solution works, not dictate its structure.”
  5. Think from user perspective: “Let’s design this from the user’s perspective first.”

Example

AI: “Based on the test case TestUserRegistration, we need to create a UserRegistrationManager class with these specific methods to make the tests pass…”

You: “Let’s take a step back and think about user registration from first principles. What’s the core flow we need to implement? After we understand that, we can figure out how to structure it in a way that’s both testable and maintainable.”

Benefits of Fixing This