- Home
- Skills
- Testing & Debugging
- Failing Test First TDD
Works with the AI tools you already use
Failing Test First TDD
Prove every behavior change with an observed failing test before writing code, so no untested behavior ever ships.
Free
Failing Test First TDD
Example session with this skill installed
I'm fixing a bug in our comments service: users can currently post comments containing only whitespace, and they shouldn't be able to. The create_comment function lives in app/services/comments.py and the suite is in tests/test_comments.py. Please add the validation using strict test-first discipline: write the failing test documenting the expected rejection, run it and confirm it fails for the right reason, then implement the minimal fix, re-run the targeted test and the full pytest suite, and report the observed red and green states.
- Read your context and instructions
- Compiled the failing test first
Summary
Added whitespace-comment rejection via a full RED → GREEN → IMPROVE cycle: one failing test observed first, minimal implementation second, whole suite green afterwards.
| Stage | Command | Observed outcome |
|---|---|---|
| RED | pytest tests/test_comments.py::test_rejects_comment_containing_only_whitespace -q | Failed as intended — expected {"ok": False}, got {"ok": True} |
| GREEN | Same targeted test | Passed after a minimal text.strip() guard |
| SUITE | pytest -q | 112 passed, 0 failed, no new warnings |
def create_comment(text: str) -> dict:
if not text.strip():
return {"ok": False, "error": "Comment text is required"}
return store.insert(text)
Next steps
- Add tests for the empty string and tab/newline-only payloads to force generalization
- Write characterization tests for the edit-comment path before refactoring it
- Sweep other validators for the same missing
.strip()guard
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Writing tests after implementation often leads to biased coverage that only confirms what the code already does, rather than what it should do. This creates false confidence and makes bugs harder to catch during the development cycle.
What it does
- Enforces a strict Red-Green-Improve cycle for every behavior change.
- Identifies valid vs. invalid failure states to ensure tests are actually meaningful.
- Guides the creation of minimal, honest implementations that solve the immediate requirement without over-engineering.
- Provides clear criteria for safe refactoring only when the test suite is green.
- Detects design smells like high coupling or unclear boundaries via test setup friction.
Why this beats prompting it yourself
General LLMs often skip straight to providing the solution, ignoring the critical failure step that proves the test's validity. This skill prevents implementation bias by forcing a stop at the "Red" phase, ensuring you never ship unverified behavior or hollow proofs.
Use cases
- Fixing bugs by creating a failing reproduction before writing the patch.
- Developing new features with a clear specification of the public API.
- Safe refactors of legacy code using characterization tests as a safety net.
- Implementing validation rules and permission checks with verified edge-case coverage.
Known limitations
Requires an existing automated testing framework. Not suitable for disposable research spikes or static configuration changes.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
1 install
Downloaded by developers to date
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 2 days ago
- Free to download with an account