Iterative Refinement Techniques

Core

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

0%
iterative-refinementtest-driveninterview-patternexamples

Iterative refinement is the practice of progressively improving Claude's output through structured feedback rather than trying to get perfect results in one shot.

Concrete Input/Output Examples

When prose descriptions are interpreted inconsistently, provide 2-3 concrete examples:

Input: "2024-01-15T10:30:00Z"
Expected: "January 15, 2024 at 10:30 AM UTC"

Input: "2024-12-31T23:59:59Z"
Expected: "December 31, 2024 at 11:59 PM UTC"

This eliminates ambiguity more effectively than prose like "format dates in a human-readable way."

Test-Driven Iteration

  • Write test suites covering expected behavior, edge cases, and performance requirements BEFORE implementation
  • Share test failures with Claude to guide progressive improvement
  • Each iteration fixes specific failing tests rather than vague "make it better" instructions
  • The Interview Pattern

    Have Claude ask questions before implementing in unfamiliar domains:

  • Surfaces design considerations you may not have anticipated
  • Examples: cache invalidation strategies, failure modes, concurrency concerns
  • Produces better first-pass implementations by front-loading design decisions
  • Batched vs Sequential Feedback

  • Interacting problems: Address all issues in a single detailed message (because fixes may affect each other)
  • Independent problems: Fix sequentially, one at a time (each fix is isolated)
  • Edge Case Handling

    Provide specific test cases with example input and expected output to fix edge cases (e.g., null values in migration scripts). Abstract descriptions of edge cases lead to incomplete fixes.

    Key Takeaways

    • Concrete input/output examples beat prose descriptions for communicating transformations
    • Write tests first, then iterate by sharing test failures with Claude
    • Use the interview pattern in unfamiliar domains to surface design considerations
    • Batch interacting issues in one message; fix independent issues sequentially