tdd-discipline
Skill0 starsChanged 5 months agoMITView on GitHub
Enforce test-first development. Trigger on "write a feature", "add functionality", "implement", or any code task that touches business logic. Auto-activate when writing code without tests. Pairs with debug-loop-breaker (prevention vs cure).
1 other project uses a version of this.
Adopted by
Most recently taken up by
- joeldevz/skynex-pitheir own version, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- joeldevz/skynex-pi★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- annotateSkill
- debug-loop-breakerSkill
- deploy-checklistSkill
- goalSkill
- growth-playbookSkill
- security-scannerSkill
- seo-auditSkill
- svg-diagramSkill
- teaching-modeSkill
- verify-frontend-changeSkill
- SKILL_NAMESkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 14 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Read the relevant source files.
- Distinctive: line 44
Write a test that:
- Distinctive: line 60
If the test passes already → your test is wrong (it's not testing new behavior).
- Distinctive: line 62
If it errors on import/setup → fix the test infrastructure, not the source code.
- Distinctive: line 66
Write ONLY enough production code to make the failing test pass.
- Distinctive: line 68
Don't add error handling for cases you haven't tested
- Distinctive: line 69
Don't refactor while implementing
- Distinctive: line 70
Don't add features beyond what the test covers
- Distinctive: line 80
If it fails → fix the production code (not the test, unless the test had a typo).
- Distinctive: line 91
If other tests broke → you introduced a regression.
- Distinctive: line 99
When fixing a bug, the order is strict:
- Distinctive: line 105
Never fix a bug without a test that proves it was broken.
- Distinctive: line 109
Before committing any code change, verify:
- Distinctive: line 120
If any check fails, do not commit.
- Very specific: line 135
Vitest watch mode can mask failures: Run with --run flag for a clean single pass before committing.
- Very specific: line 138
React component tests: use @testing-library/react, test user interactions not component internals.
- Very specific: line 139
FastAPI tests: use TestClient from starlette.testclient.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TDD Discipline
Adapted from tdd-guard by nizos; renamed to avoid clashing with that project (see README Credits).
No production code without a failing test first. This is the prevention layer — debug-loop-breaker is the cure.
Detection — When to Activate
Activate this skill when:
- The user asks to build a new feature or add functionality
- You're about to write business logic, API endpoints, or data transformations
- You're fixing a bug (write a test that reproduces it FIRST)
- Any code change that could break existing behavior
Do NOT activate for:
- Config files, env vars, styling-only changes
- Documentation, comments, type-only changes
- One-off scripts, migrations, or prototyping (unless the user asks)
The Protocol
1. UNDERSTAND before you code
Read the relevant source files. Identify:
- What function/component will change?
- What are the inputs and expected outputs?
- What are the edge cases?
State this in one sentence: "I'm going to [change X] so that [Y happens]. The test should verify [Z]."
2. WRITE the failing test first
# Create or open the test file adjacent to the source
# __tests__/thing.test.ts or test_thing.pyWrite a test that:
- Describes the DESIRED behavior (not current behavior)
- Is specific: exact inputs → exact expected outputs
- Covers the happy path AND at least one edge case
- Will fail right now because the feature doesn't exist yet
3. RUN the test — confirm it fails
# JS/TS
npx vitest run path/to/test --reporter=verbose
# Python
pytest path/to/test -vIf the test passes already → your test is wrong (it's not testing new behavior). Rewrite it.
If it errors on import/setup → fix the test infrastructure, not the source code.
4. WRITE the minimum code to pass
Write ONLY enough production code to make the failing test pass. No more.
- Don't add error handling for cases you haven't tested
- Don't refactor while implementing
- Don't add features beyond what the test covers
5. RUN the test — confirm it passes
npx vitest run path/to/test --reporter=verbose
# or
pytest path/to/test -vIf it fails → fix the production code (not the test, unless the test had a typo).
6. RUN all related tests
# Run the full test suite for the module/project
npx vitest run
# or
pytestIf other tests broke → you introduced a regression. Fix it before moving on.
7. REFACTOR (optional, only after green)
Now you can clean up — but only with all tests passing. Run tests after every refactor step.
Bug Fix Protocol
When fixing a bug, the order is strict:
- Reproduce — Write a test that triggers the bug (test should FAIL)
- Fix — Change the minimum code to make the test pass
- Verify — Run all tests to confirm no regressions
Never fix a bug without a test that proves it was broken.
Enforcement Checkpoints
Before committing any code change, verify:
| Check | Pass? |
| New behavior has a corresponding test | |
| Test was written BEFORE the implementation | |
| Test fails without the implementation (confirmed) | |
| Test passes with the implementation | |
| Full test suite passes (no regressions) | |
No test is skipped or .only'd |
If any check fails, do not commit. Fix it first.
Anti-Patterns
| Pattern | Problem | Instead |
| Writing implementation first, tests after | Tests become "confirmation tests" that just verify what you wrote, not what's correct | Test first — always |
| Testing implementation details | Brittle tests that break on refactor | Test behavior: inputs → outputs |
test.skip() or @pytest.mark.skip | Hiding failures | Fix or delete the test |
| Mocking everything | Tests pass but prod breaks | Mock boundaries only (DB, APIs), not internal functions |
| One giant test per feature | Can't tell what broke | One assertion per test case, descriptive names |
| "I'll add tests later" | You won't | Now or never |
Gotchas
- Vitest watch mode can mask failures. Run with
--runflag for a clean single pass before committing. - Python test discovery needs
__init__.pyin test directories sometimes. If pytest can't find tests, check this. - Don't mock the database in integration tests. Mocked tests can pass while a real migration or query fails in production. Use a real test DB.
- React component tests: use
@testing-library/react, test user interactions not component internals.screen.getByRole>wrapper.find('.class-name'). - FastAPI tests: use
TestClientfromstarlette.testclient. It runs synchronously, no need for async test setup. - Edge runtime (e.g. Cloudflare Workers): some Node.js test utilities don't work. Use a local edge emulator (such as Miniflare) for testing edge functions.
Upgrade Path: Hook-Based Enforcement
This skill is a behavioral guide — it relies on the agent following the protocol. For hard enforcement that blocks non-TDD file writes, install the nizos/tdd-guard Claude Code plugin:
# Installs hooks that intercept Write/Edit operations
# Uses a second model to validate TDD compliance
# Blocks file writes that don't follow Red-Green-Refactor
/plugin marketplace add nizos/tdd-guard
/plugin install tdd-guard@tdd-guard
/tdd-guard:setupThe plugin intercepts every file write via PreToolUse hooks, validates against TDD rules using a second model call, and blocks non-compliant operations. Adds latency per write but guarantees compliance. Worth it for critical codebases.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

