test-driven-development
Apply Test-Driven Development
Also available from: Cycleaddict,obra,davila7,DMJGilbert,DYAI2025,Cygnusfear,CodingCossack
Writing tests after code leads to false confidence and missed edge cases. This skill enforces the TDD discipline: write a failing test first, then implement just enough code to pass.
Download the skill ZIP
Upload in Claude
Go to Settings โ Capabilities โ Skills โ Upload skill
Toggle on and start using
Test it
Using "test-driven-development". I need to add a function that validates email addresses
Expected outcome:
Let me start with TDD. First, I'll write a failing test:
```typescript
test('rejects invalid email', () => {
expect(validateEmail('invalid')).toBe(false);
});
```
Now I'll run this test to confirm it fails...
Using "test-driven-development". The login function should handle wrong passwords
Expected outcome:
Following TDD, first the test:
```typescript
test('rejects wrong password', async () => {
const result = await login('user@test.com', 'wrongpass');
expect(result.success).toBe(false);
expect(result.error).toBe('Invalid credentials');
});
```
Running test to verify it fails...
Security Audit
SafeThis is a legitimate Test-Driven Development educational skill. The static analyzer detected 73 potential issues, but after semantic evaluation, all findings are FALSE POSITIVES. The 'external_commands' detections are markdown code block delimiters (backticks) in documentation, not actual shell execution. The 'weak cryptographic algorithm' and 'network reconnaissance' detections are similarly false positives triggered by keywords in educational context. No executable malicious code exists in this skill.
Medium Risk Issues (1)
Quality Score
What You Can Build
New Feature Implementation
When building a new feature, write the test first that defines the expected behavior, watch it fail, then implement to make it pass
Bug Fix Workflow
When fixing a bug, first write a test that reproduces the bug, watch it fail, then fix the code to make it pass
Refactoring with Confidence
Before refactoring, ensure tests exist. The tests verify the behavior remains correct after code changes
Try These Prompts
I need to implement [describe feature]. Following TDD, first write a failing test that defines the expected behavior. Don't write implementation code yet.
Run the test I just wrote and confirm it fails for the right reason (feature missing, not due to typos). Show me the exact failure message.
Now write the minimal code needed to make the test pass. Do not add extra features or refactor. Just get the test to pass.
There's a bug where [describe bug]. First write a test that reproduces this bug and fails. Then I'll fix it.
Best Practices
- Write one test at a time - focus on single behavior
- Name tests by the behavior they verify, not by what is being tested
- Always watch the test fail before writing implementation
- Keep implementation minimal - only pass the current test
Avoid
- Writing implementation code before tests (then 'adapting' tests)
- Keeping failed implementation code as 'reference' while writing tests
- Tests that pass immediately - they prove nothing
- Testing mock behavior instead of real component behavior
Frequently Asked Questions
What is Test-Driven Development?
Why write tests before code?
What if the test is hard to write?
Can I skip TDD for simple code?
What if I already wrote the implementation?
Does TDD slow down development?
Developer Details
Author
ZhanlinCuiLicense
MIT
Repository
https://github.com/ZhanlinCui/Ultimate-Agent-Skills-Collection/tree/main/test-driven-developmentRef
main
File structure
๐ SKILL.md