Test-first with agents
For engineers
Write or approve failing tests first, lock them, then let the agent implement until they pass for the right reason
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
Why write and approve tests before the agent writes the code?
Check yourself · 2 of 5
What should you ask an agent for first when you want tests for a new function?
Check yourself · 3 of 5
In the red step, what do you check?
Check yourself · 4 of 5
A function has 100% line coverage. What does that guarantee?
Check yourself · 5 of 5
An agent says all tests pass. Which change in its diff is most suspicious?
Topics
- Approved tests as the agent's contract4 min read · Failing tests that encode the acceptance criteria, approved by a person and locked before implementation starts
- Drafting test cases with an agent4 min read · Asking for a list of cases before test code, then adding the edge, error and boundary cases the agent left out
- The red, green, review cycle4 min read · Seeing each test fail for the expected reason, letting the agent make it pass, then reviewing and refactoring
- Coverage numbers versus real confidence4 min read · Why high coverage proves little, and how mutation thinking shows whether tests protect a behaviour
- Agents that cheat to pass tests5 min read · Special-cased inputs, skipped or deleted tests, weakened assertions and other reward hacking in agent changes
Start here
- Canon TDD (Kent Beck) (opens in a new tab)ArticleFree
The author of TDD lists the steps: write a test list, one test at a time, make it pass, refactor.
- Test Driven Development (martinfowler.com) (opens in a new tab)ArticleFree
A short definition of the red, green, refactor loop and why it keeps changes small.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
A vendor's advice on giving agents tests and checks to verify their own work.
Helps to know first
110 questions · last verified 2026-12