axiomantic/spellbook/test-driven-development
Claude Code and agent skill by axiomantic/spellbook
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use when user explicitly requests test-driven development. Triggers: 'TDD', 'write tests first', 'red green refactor', 'test-first', 'start with the test'. Also invoked by develop and executing-plans for implementation tasks. NOT for: full feature work (use develop, which includes TDD internally).
Install
npx vskill@latest install axiomantic/spellbook/test-driven-developmentSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as axiomantic/spellbook/test-driven-development.
Test-Driven Development
<ROLE> Quality Engineer with zero-defect mindset. Reputation depends on shipping code that works, not code that "should work." </ROLE>
Invariant Principles
- Failure Proves Testing - Test passing immediately proves nothing. Only watching failure proves test detects what it claims.
- Order Creates Trust - Tests-first answer "what should this do?" Tests-after answer "what does this do?" Fundamentally different questions.
- Minimal Sufficiency - Write exactly enough code to pass. YAGNI violations compound into untested complexity.
- Deletion Over Adaptation - Code written before tests is contaminated. Keeping "as reference" means testing after. Delete means delete.
Violating the letter of the rules is violating the spirit of the rules.
Inputs
| Input | Required | Description | |
|---|---|---|---|
| Feature/bugfix description | Yes | What behavior to implement or fix | |
| Existing test patterns | No | Project's testing conventions and frameworks | |
| API contracts | No | Expected interface signatures |
Outputs
| Output | Type | Description | |
|---|---|---|---|
| Failing test | File | Test demonstrating missing behavior | |
| Minimal implementation | File | Code passing the test | |
| Test execution evidence | Inline | Observed failure before green |
When to Use
Always: new features, bug fixes, refactoring, behavior changes.
Exceptions (ask human partner; no human available? default: apply TDD):
- Throwaway prototypes
- Generated code
- Configuration files
Thinking "skip TDD just this once"? Stop. That's rationalization.
The Iron Law
Code before test? Delete. Start over. No "reference," no "adapting," no looking at it.
Reasoning Schema
<analysis> Before writing ANY code:
- What behavior needs verification?
- What assertion proves that behavior?
- What's the simplest API shape?
</analysis>
<reflection> After EACH phase:
- RED: Did test fail? Why? Expected failure mode?
- GREEN: Minimal code? No extra features?
- REFACTOR: Still green? Behavior unchanged?
</reflection>
Red-Green-Refactor
RED: Write Failing Test
One behavior. Clear name. Real code (mocks only if unavoidable; unavoidable = external I/O, time, hardware — not laziness).
<Good>
Clear name, tests real behavior, one thing </Good>
<Bad>
Vague name, tests mock not code </Bad>
Verify RED: Watch It Fail
MANDATORY. Never skip.
Confirm:
- Fails (not errors)
- Failure message expected
- Fails because feature missing (not typos)
Test passes? Testing existing behavior. Fix test. Test errors? Fix error, re-run until it fails correctly.
GREEN: Minimal Code
Simplest code to pass. No features, no refactoring, no "improvements."
Load the enforcing-code-quality skill before writing this code. "Minimal" bounds SCOPE, not quality: the prohibited patterns (any types, blanket try-catch, resource leaks, unvalidated non-null assertions) are not licensed by the fact that a test is currently red. A shortcut taken here survives REFACTOR, because REFACTOR only cleans what it recognizes as duplication.
<Good>
Just enough to pass </Good>
<Bad>
Over-engineered </Bad>
Verify GREEN: Watch It Pass
MANDATORY.
Confirm:
- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
Test fails? Fix code, not test. Other tests fail? Fix now.
REFACTOR: Clean Up
After green only. Remove duplication, improve names, extract helpers. Keep tests green. Don't add behavior.
Complete when: duplication removed, names clear, all tests still green, no new behavior added.
Repeat
Next failing test for next feature. The cycle continues until all behavior is implemented.
Good Tests
| Quality | Good | Bad | |
|---|---|---|---|
| Minimal | One thing. "and" in name? Split it. | test('validates email and domain and whitespace') | |
| Clear | Name describes behavior | test('test1') | |
| Shows intent | Demonstrates desired API | Obscures what code should do | |
| Fast | Completes in <1s. No I/O or heavy fixtures in unit tests. | 5-second test with database setup for pure logic | |
| Content-validating | Asserts exact values, full objects, every field | assert len(result) > 0, assert result is not None |
Assertion Quality
<CRITICAL>
The Full Assertion Principle
Every assertion MUST assert exact equality against the COMPLETE expected output. This applies to ALL output -- static, dynamic, or partially dynamic. There are no categories of output exempt from this rule.
ALL output demands complete verification: writers, serializers, formatters, code generators, query builders, template renderers, config builders, functions with dynamic content. For multi-line output, use triple-quoted strings or dedent helpers. Output length is NEVER a justification for partial assertions.
When output contains dynamic values (timestamps, derived strings), construct the complete expected value using the same logic, then assert ==. Do not assert partial membership of the dynamic value.
For mock assertions: assert EVERY call with ALL args, verify call count. mock.ANY is BANNED -- construct the expected argument dynamically if needed.
Normalization is LAST RESORT only -- for truly unknowable values (random UUIDs, OS-assigned PIDs, memory addresses). Never use normalization to avoid constructing a complete expected value. </CRITICAL>
Tests must validate CONTENT, not just EXISTENCE. Every assertion must answer: "If the value was garbage, would this catch it?"
Reference: Read patterns/assertion-quality-standard.md for the full Assertion Strength Ladder, Full Assertion Principle, Bare Substring Problem analysis, and Broken Implementation Test. Every assertion must be Level 4+ on the ladder.
Rules
| Rule | BANNED Pattern | CORRECT Pattern | |
|---|---|---|---|
| No existence-only assertions | assert len(result) > 0 (BANNED Level 1) | assert result == [expected_item_1, expected_item_2] | |
| No count-only assertions | assert len(result) == 3 (BANNED Level 2) | assert result == [item_1, item_2, item_3] | |
| No none-checks without content | assert response is not None (BANNED Level 1) | assert response == expected_response | |
| No file existence-only checks | assert output_file.exists() (BANNED Level 1) | assert output_file.read_text() == "expected content" | |
| No `mock.ANY` ever | assert_called_with(mock.ANY, mock.ANY) (BANNED -- proves nothing) | assert_called_with("expected_arg", expected_obj) (construct dynamically if needed) | |
| Assert every mock call, all args | mock_fn.assert_called() or mock_fn.assert_called_once() (no argument check) | mock_fn.assert_has_calls([call(arg1, arg2), ...]) + verify call_count | |
| No partial checks on any output | assert "key" in result (BANNED Level 2) | assert result == {"key": "expected_value", ...} (construct dynamically for dynamic output) | |
| Every field of every object | assert result.status == "ok" (BANNED Level 3 without justification) | assert result == ExpectedObject(status="ok", data=..., meta=...) | |
| No bare substring on string output | assert "data" in output (BANNED Level 2) | assert output == expected (exact equality) | |
| No multiple partials as substitute | assert "foo" in r and "bar" in r (BANNED: still partial) | assert r == expected_complete_string | |
| No tautological assertions | assert result == func(same_input) (BANNED: tests nothing) | Compute expected value independently |
Pychoir Matchers
Pychoir matchers (including custom subclasses) are the ONE exception to the mock.ANY ban. Use them ONLY when the value genuinely cannot be known ahead of time (timestamps, UUIDs, auto-incremented IDs). Each use requires a stated justification in a comment.
ESCAPE Analysis (Mandatory Per Test Function)
Before marking ANY test function complete, fill in this template:
The MUTATION field is a forcing function: for each assertion in the test, you must name a specific, plausible production code change that would cause that assertion to fail. If you cannot name one, the assertion is too weak and must be strengthened before proceeding. This is the Broken Implementation Test from patterns/assertion-quality-standard.md.
The ESCAPE field must describe a SPECIFIC broken implementation, not a generic statement. "Nothing reasonable" IS valid when justified, but requires explanation of why the assertions are comprehensive enough.
Red flags in ESCAPE analysis:
- ESCAPE field says "none" or "nothing" without justification
- ESCAPE field describes something the test DOES catch (means you didn't think hard enough)
- ESCAPE field is copy-pasted between tests (each test has unique escape paths)
Test Strength Verification (mechanical pre-commit grep)
ESCAPE Analysis is the rigorous version. This is the cheap mechanical version that catches the most common green-mirage patterns at commit time. Run BEFORE any per-task commit:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/test-driven-development/SKILL.md
Popularity
- Repository stars
- 10
- Repository forks
- 6
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/axiomantic/spellbook/test-driven-development)