Test-Driven Iteration & Interview Pattern

Advanced

Apply iterative refinement techniques for progressive improvement · Difficulty 2/5

0%
test-driveninterview-patterniterationfeedback

Two powerful iterative refinement patterns deserve deeper treatment: test-driven iteration and the interview pattern.

Test-Driven Iteration

Write tests BEFORE asking Claude to implement:

  • Define test suites covering expected behavior, edge cases, and performance requirements
  • Ask Claude to implement the solution
  • Run the tests and share failures with Claude
  • Claude fixes the specific failing tests
  • Repeat until all tests pass
  • This is more effective than reviewing code manually because:

  • Test failures are unambiguous -- no room for interpretation
  • Each iteration targets specific, concrete failures
  • Progress is measurable (X of Y tests passing)
  • The Interview Pattern

    Before implementing in unfamiliar domains, have Claude ask questions:

  • "What cache invalidation strategy should I use?"
  • "How should the system handle partial failures?"
  • "What concurrency model is appropriate here?"
  • This surfaces considerations the developer may not have anticipated, producing better first-pass implementations by front-loading design decisions.

    Batched vs Sequential Feedback

    Choosing the right feedback strategy matters:

    SituationStrategyWhy

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

    Interacting problemsSingle detailed message with all issuesFixes may affect each other; Claude needs full picture
    Independent problemsSequential, one at a timeEach fix is isolated; simpler context per iteration

    Specific Test Cases for Edge Cases

    When Claude mishandles edge cases (e.g., null values in migration scripts), provide specific test cases with example input and expected output rather than describing the edge case in prose. This eliminates ambiguity about the expected behavior.

    Key Takeaways

    • Test failures are unambiguous feedback -- more effective than prose review
    • The interview pattern front-loads design decisions in unfamiliar domains
    • Batch interacting issues together; handle independent issues sequentially
    • Provide specific test cases with input/output for edge case fixes