Agents In Use
What’s new todayLast update
108 use cases added today

How to use Claude to enforce test driven development

Claude Code hooks enforce a failing-test-first development loop, with Playwright checks retained in the codebase and manual testing and line-by-line review before merging.

OUR ADAPTATION

Suggested prompt

Suggested prompt written by Agents In Use, not the source author. Replace bracketed inputs and review tool permissions first.

For [feature] in [repository], follow the existing [Claude Code hooks] testing gates. Write relevant end-to-end and unit/integration/component tests, run them to observe failure, implement the change, and rerun them to observe success. Provide the diff for my manual testing and review.

Evidence at a glance

Sourced account
Source author
cadamsdotcom
Original account
Read the source ↗
Published
Source link checked
Reported result
The author reports building a SaaS codebase exceeding 300,000 lines with this workflow and retaining Playwright validation code as part of the project.
Human involvement
The author manually tests everything and reviews every line merged, even after automated checks pass.

A linked account supports attribution. It does not mean we independently reproduced its result.

Report an issue with this caseOpen correction email

Opens your email app with the case link included. Nothing is sent automatically.

How the agent did it

  1. Use hooks and a state machine to enforce the testing loop.
  2. Write tests and observe their failing results before coding.
  3. Write implementation that makes the tests pass.

A Claude Code user described a development workflow enforced by hooks rather than skills or MCP integrations. They report using it to build a SaaS codebase of more than 300,000 lines over more than a year. The hooks use deterministic automation and a state machine to force the agent through test driven development.

The sequence starts with writing failing tests and watching them fail. The agent then writes code to make those tests pass and witnesses the passing result. Refactoring is optional before the cycle repeats. The automation requires end-to-end tests and unit, integration, or component tests before permitting implementation. The author argues that observing an initial failure establishes that the tests exercise something meaningful.

For browser behavior, the agent writes Playwright code to validate its work, and those checks remain in the codebase. The author says they have never needed to hand the model a browser during that year. Despite the automated checks, they manually test everything and review every line they merge. They report that preparing a change for merging takes much longer than the model spends building it. Who it's for: developers maintaining complex applications who want enforced testing stages and are prepared to perform detailed human review.

Prompt
Suggested prompt (written by Agents In Use, not the author's)

Source: Hacker News · cadamsdotcom

Frequently asked questions

What sequence do the hooks enforce?

The agent writes tests, observes them fail, writes implementation, and observes the tests pass. It can then refactor and repeat the cycle.

Does automated testing replace human review here?

No. The author says they manually test everything and review every line they merge, despite the enforced automated test workflow.

More details

Remaining steps

  1. Observe passing tests and optionally refactor.
  2. Test manually and review every line before merging.

About this account

The agent writes tests and implementation under deterministic hooks that enforce the development sequence.

Platform: Hacker News. Attribution: https://news.ycombinator.com/item?id=48430429. Prompt: Suggested (written by Agents In Use, not the author's). Sourced by the Agents In Use pipeline.

Credit: cadamsdotcom on Hacker News

Source published

Added to Agents In Use

Source checked

Tools and topics

Claude Code · Claude Code hooks · Playwright

TDD · Testing · Playwright

Editorial completeness: 100/100. Measures documented fields, not agent performance or verified outcomes.