1.1k
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill openclaw/skills --skill sw-tdd-expert- _meta.json281 B
- SKILL.md9.1 KB
Overview
This skill is a Test-Driven Development (TDD) expert that guides developers through the red-green-refactor cycle and related patterns. It helps you write failing tests first, implement the minimal code to pass them, and refactor safely. The skill emphasizes practical patterns, mock strategies, and SOLID design outcomes.
How this skill works
It inspects your development scenario and recommends the next TDD step: write a focused failing test, implement the minimal passing code, or perform targeted refactors. It provides checklists, common patterns (triangulation, fake-it, test builders), and guidance for testing external dependencies via mocks or dependency injection. It highlights anti-patterns to avoid and suggests concrete refactor workflows backed by tests.
When to use it
- Implementing new features with clear behavior
- Adding regression tests for bug fixes (write test first)
- Refactoring legacy code with test safety net
- Designing public APIs or complex business logic
- When aiming to adopt SOLID design via tests
Best practices
- Write one behavior per test and ensure it fails for the right reason
- Keep implementations minimal to make tests pass; avoid premature features
- Refactor only when all tests are green; run tests after each small change
- Use test data builders for complex fixtures and to keep tests readable
- Inject dependencies or use interfaces for easy mocking of external systems
Example use cases
- Add a new payment rule: write failing test for expected totals, green minimal code, then refactor
- Hard-to-test legacy function: write tests for current behavior, refactor into smaller functions under test cover
- Implement external integrations: inject a mockable interface and verify behavior without the real service
- Improve design: split a bloated class into SRP-aligned components driven by test boundaries
- Create behavior-driven specs for stakeholders using Given-When-Then style tests
FAQ
Stop and fix the test or environment issue so the failure reflects the intended behavior. A valid red step must fail for the right reason before implementing code.
When is it OK to skip strict TDD?
For throwaway prototypes or exploratory spikes where speed matters, strict TDD can be relaxed. For production, complex logic, or refactors, follow TDD to reduce risk.