My Agent Skill for Test-Driven Development
TL;DR Highlight
Giving agents a Canon TDD skill plus a separate review agent improved their tests.
Who Should Read
Backend developers frustrated by vague, pointless tests written by coding agents like Claude Code.
Core Mechanics
- Agents write poor tests
- The author says that as of May 2026, agent-written tests are often vague, overcomplicated and tautological.
- He blames the training data, since human-written tests are often just as bad.
- Canon TDD alone gets you 60% there
- The author suspects a skill saying only "Follow Kent Beck's Canon TDD" gets you about 60% of the way.
- This is his gut feeling, not a measured result.
- Specify-encode-fulfill loop
- Specify what to build, encode it as automated tests, then write code to fulfill it.
- He uses it in place of red-green-refactor.
- Core Canon TDD rules
- Change code just enough to make the current failure go away.
- Never refactor before committing the behavior change.
- Repeat until the list is empty.
- A separate agent reviews test design
- The Test Design Review skill spawns a separate agent to avoid bias.
- It finds design violations like tests focused on means rather than ends and suggests fixes.
- Claude follows "clean the kitchen first"
- The skill says that if a test is hard to write, the code may need cleanup first.
- Claude often pauses to ask about it, and often cleanup was indeed needed.
Community Reactions
- Separate-agent review improves quality
- One commenter adds 2-3 rounds of sub-agent review to plans and sees noticeably better code and fewer bugs.
- They say it costs tokens and time but beats fixing bugs later.
- TDD balloons token cost, a counterpoint
- One commenter found TDD heavy on tokens and velocity when features change or get removed.
- They also saw superficial tests that never really tested the components.
- Check that tests actually fail on bugs
- One commenter says that without injecting bugs to confirm tests fail, you only know tests can pass.
- Short instructions may be enough
- One commenter gets good results just telling Claude Code and Codex "Test with uv run pytest, use red/green TDD".
- Another says direct AGENTS.md instructions beat a skill for TDD.
How to Apply
- Add a TDD instruction to your agent file
- Paste the 5 Canon TDD steps into AGENTS.md or CLAUDE.md today.
- Assign one small feature and compare the tests.
- Run a dedicated test-design review agent
- When a test looks off, give only the test file to a separate agent to find design violations.
- Filter its suggestions by hand.
- Enforce separate commits for behavior and refactoring
- State in the instructions that no refactoring happens before the behavior change is committed.
- Check for mixed commits in PR review.
- Make the agent stop when a test is hard to write
- Tell it to ask whether code cleanup is needed first.
Try It
# Paste into Claude Code or AGENTS.md/CLAUDE.md (simplified version of the author's skill)
Follow this TDD process (Kent Beck's Canon TDD).
1. Write a list of specifications within scope of this task.
2. Encode one item as an automated test.
3. Change the code just enough to make the current failure go away. No speculative code.
4. Optionally refactor, but only after committing the behavior change. Never mix them.
5. Go back to step 2 until the list is empty.
If a test is hard to write, ask me whether we should clean up the code first.
Task: {{feature description}}
Test command: {{e.g. uv run pytest}}Terminology
Related Papers
Why Do LLMs Help with Scientific Misconduct Requests and What to Do About It?: Increasing the Trustworthiness of AI for Science
Adding an intention-analysis system prompt raised refusal of misconduct requests from 58% to 87%.
How Specification Explicitness Shapes Failure in LLM-Generated Code
Spelling out invariants, edge cases and constraints cut hidden-test failures in LLM code by 47.2%.
Same Task, Different Statement: When and How Reformulation Helps LLM Problem Solving
Rewriting problem statements to fit their type raises LLM accuracy, but blind rewriting hurts.
Show HN: STE80 Humanizer – de-AI text by writing 80% of the way to ASD-STE100
A skill strips 26 AI tells and rewrites text in short ASD-STE100-style sentences
Character-Name Concentration in LLM Fiction: Measuring Displacement and Mitigating Repetition
Drafting name candidates and filtering by frequency cut LLM character-name repetition by 95%
LLM Voice
Martin Fowler: LLM-drafted prose keeps an uncanny tone even after human editing.
The Instruction Tax on Factual Recall: Base Models Can Beat Their Instruction-Tuned Counterparts
Few-shot completion with repeated sampling on a base model beat chat: F1 0.684 vs 0.568
AI is a tool and using it well takes skill
A rebuttal to Hickey: LLMs are tools, and skill in directing and checking them decides the outcome