← All Semantic Contracts

TDD, Hamburg Style

Design-led TDD recipe by Ralf Westphal — close the requirements/logic gap before writing code, then test at service boundaries with minimal mocking

A semantic contract: vocabulary your project supplies itself — ready to drop into your CLAUDE.md / AGENTS.md.

    Design-led TDD recipe by Ralf Westphal — close the requirements/logic gap before writing code, then test at service boundaries with minimal mocking. Use it when the problem is too complex for pure micro-step Red-Green-Refactor.

  • **ACD cycle (Analyze → Design → Code)** precedes the test loop: first model the solution to close the gap between requirements and logic, only then code.
  • **"Right from the start" philosophy** — implement correctly the first time so refactoring is a correction, not routine cleanup.
  • **Service-level testing** — test behind the public API, independent of API technology.
  • **Minimal mocking** — closer to *TDD, Chicago School* than *London School*.
  • **IOSP (Integration Operation Segregation Principle)** — a function is either composition (Integration) or logic (Operation), never both; structural support for simple unit tests.
  • **Deep Work over Small Steps** — accept that some problems can't be sliced into tiny green increments; stay red longer when the design demands it.
  • Composes: *TDD, London School*, *TDD, Chicago School*, *Red-Green-Refactor*, *IOSP*.

    Sources: https://ralfw.de/hamburg-style-tdd/, https://ralfw.de/tdd-how-it-can-be-done-right/

Related Anchors