- Home
- Skills
- Testing & Debugging
- Failing Test First TDD
Works with the AI Agents 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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.
Assumes the project already has a runnable test suite and runner configured; without one, the first cycle spends time on setup. The strict discard-and-restart rule intentionally feels heavy for throwaway spikes, which need an explicit opt-out.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
2 uses
Times used to date
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 1 month ago
- Free with an Agensi account
Permissions
File Scopes
Terminal access runs the test commands that prove each red and green state; read/write scope covers the test and source files the cycle creates and edits.