
TDD with Claude Code in .NET: red-green-refactor with a Stop hook and a guardian subagent
**TDD** is the perfect leash for a coding agent: the test written *first* defines the behaviour, and the agent writes ==only the code that makes it pass==. In this tutorial I build a **.NET Minimal API** with *Claude Code* in pure red-green-refactor, and I mount two guardrails: a **Stop hook** that re-runs `dotnet test` whenever the agent tries to call itself "done", and a **subagent** that checks the tests were not weakened.





