Writing tests after code creates fragile systems that break on refactors. This skill guides you through test-driven development where tests define behavior before implementation, resulting in cleaner code and reliable refactoring.
Download the skill ZIP
Upload in Claude
Go to Settings β Capabilities β Skills β Upload skill
Toggle on and start using
Test it
Using "tdd". Help me build a feature to add items to a shopping cart
Expected outcome:
I'll guide you through TDD for this feature. First question: what should happen when a user adds an item? Should we support quantity? What behavior should be verifiable?
Using "tdd". Write tests for user authentication
Expected outcome:
For auth testing, focus on public interfaces: login, logout, session handling. I recommend integration-style tests over mocking internal auth logic. What external services does your auth use?
Using "tdd". I have tests that break whenever I refactor
Expected outcome:
Your tests are likely coupled to implementation details. Good tests verify behavior through public interfaces. Let's identify which tests break and what they're testing.
Security Audit
SafeAll 48 static findings are false positives. The skill contains educational TDD documentation with code examples. External command flags were triggered by ASCII workflow diagrams (REDβGREEN patterns). Cryptographic algorithm flags were triggered by testing patterns like jest.mock() and StripeClient(). No malicious code or prompt injection detected.
Quality Score
What You Can Build
Building new features with TDD
When starting a new feature, this skill helps write tests first that define expected behavior, then guides minimal implementation to pass those tests.
Fixing bugs with failing tests
When a bug is reported, this skill helps write a failing test that reproduces the bug, then guides fixing the code to make the test pass.
Improving legacy code through refactoring
Before refactoring legacy code, this skill helps write integration tests that capture current behavior, ensuring refactors do not break existing functionality.
Try These Prompts
I need to add [feature] to [module]. Help me use TDD to build this. Start by asking what behaviors to test first.
There's a bug where [description]. Help me write a failing test that reproduces this, then fix it.
I want better tests for [module]. Review my current tests and suggest improvements following TDD principles.
I want to refactor [module]. Help me write tests that capture current behavior first, then guide my refactoring.
Best Practices
- Write one test at a time and only enough code to pass it
- Use public interfaces only; tests should survive internal refactors
- Prefer integration-style tests that verify observable behavior over mocking internal parts
Avoid
- Writing all tests first then all implementation (horizontal slicing)
- Mocking internal collaborators instead of testing through public interfaces
- Writing tests that verify implementation details rather than behavior
Frequently Asked Questions
When should I write tests in TDD?
How many tests should I write at once?
What should I test if I cannot test everything?
Should I mock my own classes or modules?
When should I refactor in TDD?
How do I know if my test is good?
Developer Details
File structure
π deep-modules.md
π interface-design.md
π mocking.md
π refactoring.md
π SKILL.md
π tests.md