install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/tdd" ~/.claude/skills/comeonoliver-skillshub-tdd-2b9c70 && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/tdd/SKILL.mdsource content
Community Test-Driven Development Best Practices
Comprehensive guide to Test-Driven Development practices, designed for AI agents and LLMs. Contains 42 rules across 8 categories, prioritized by impact to guide test writing, refactoring, and code generation.
When to Apply
Reference these guidelines when:
- Writing new tests using TDD workflow
- Implementing the red-green-refactor cycle
- Designing test structure and organization
- Creating test data and fixtures
- Reviewing or refactoring existing test suites
TDD Workflow
- RED: Write a failing test that defines desired behavior
- GREEN: Write minimal code to make the test pass
- REFACTOR: Clean up code while keeping tests green
- Repeat for each new behavior
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Red-Green-Refactor Cycle | CRITICAL | |
| 2 | Test Design Principles | CRITICAL | |
| 3 | Test Isolation & Dependencies | HIGH | |
| 4 | Test Data Management | HIGH | |
| 5 | Assertions & Verification | MEDIUM | |
| 6 | Test Organization & Structure | MEDIUM | |
| 7 | Test Performance & Reliability | MEDIUM | |
| 8 | Test Pyramid & Strategy | LOW | |
Quick Reference
1. Red-Green-Refactor Cycle (CRITICAL)
- Write the Test Before the Implementationcycle-write-test-first
- Write Only Enough Code to Pass the Testcycle-minimal-code-to-pass
- Refactor Immediately After Greencycle-refactor-after-green
- Verify the Test Fails Before Writing Codecycle-verify-test-fails-first
- Take Small Incremental Stepscycle-small-increments
- Maintain a Test Listcycle-maintain-test-list
2. Test Design Principles (CRITICAL)
- Test Behavior Not Implementationdesign-test-behavior-not-implementation
- One Logical Assertion Per Testdesign-one-assertion-per-test
- Use Descriptive Test Namesdesign-descriptive-test-names
- Follow the Arrange-Act-Assert Patterndesign-aaa-pattern
- Test Edge Cases and Boundariesdesign-test-edge-cases
- Avoid Logic in Testsdesign-avoid-logic-in-tests
3. Test Isolation & Dependencies (HIGH)
- Mock External Dependenciesisolate-mock-external-dependencies
- Avoid Shared Mutable State Between Testsisolate-no-shared-state
- Write Deterministic Testsisolate-deterministic-tests
- Prefer Stubs Over Mocks for Queriesisolate-prefer-stubs-over-mocks
- Use Dependency Injection for Testabilityisolate-use-dependency-injection
4. Test Data Management (HIGH)
- Use Factories for Test Data Creationdata-use-factories
- Keep Test Setup Minimaldata-minimal-setup
- Avoid Mystery Guestsdata-avoid-mystery-guests
- Use Unique Identifiers Per Testdata-unique-identifiers
- Use Builder Pattern for Complex Objectsdata-builder-pattern
5. Assertions & Verification (MEDIUM)
- Use Specific Assertionsassert-specific-assertions
- Assert on Error Messages and Typesassert-error-messages
- Every Test Must Have Assertionsassert-no-assertions-antipattern
- Create Custom Matchers for Domain Assertionsassert-custom-matchers
- Use Snapshot Testing Judiciouslyassert-snapshot-testing
6. Test Organization & Structure (MEDIUM)
- Group Tests by Behavior Not Methodorg-group-by-behavior
- Follow Consistent Test File Structureorg-file-structure
- Use Setup and Teardown Hooks Appropriatelyorg-setup-teardown
- Extract Reusable Test Utilitiesorg-test-utilities
- Use Parameterized Tests for Variationsorg-parameterized-tests
7. Test Performance & Reliability (MEDIUM)
- Keep Unit Tests Under 100msperf-fast-unit-tests
- Eliminate Network Calls in Unit Testsperf-avoid-network-calls
- Fix Flaky Tests Immediatelyperf-fix-flaky-tests
- Parallelize Independent Testsperf-parallelize-tests
- Avoid Arbitrary Sleep Callsperf-avoid-sleep
8. Test Pyramid & Strategy (LOW)
- Follow the Test Pyramidstrat-test-pyramid
- Use Mutation Testing to Validate Test Qualitystrat-mutation-testing
- Set Meaningful Coverage Targetsstrat-coverage-targets
- Test Integration at Service Boundariesstrat-integration-boundaries
- Limit E2E Tests to Critical User Pathsstrat-e2e-critical-paths
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
- cycle-write-test-first - Write the Test Before the Implementation
- design-aaa-pattern - Follow the Arrange-Act-Assert Pattern
Related Skills
- For Vitest framework specifics, see
skillvitest - For API mocking with MSW, see
skillmsw
Full Compiled Document
For the complete guide with all rules expanded:
AGENTS.md