Agent skill
tdd-4meta5-skills
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/tdd-4meta5-skills
SKILL.md
Test-Driven Development
Comprehensive testing workflow: TDD cycle, test suggestions, generation, and property-based testing.
TDD Cycle (RED → GREEN → REFACTOR)
You are not allowed to implement code until the full TDD cycle is followed.
Phase 1: RED (Write Failing Test)
BLOCKED: Cannot proceed until test failure is proven
- Write a test that captures the expected behavior
- Run the test - it MUST fail
- Document the failure output as proof
Phase 1 Checklist:
- Test file created/modified
- Test run completed
- Failure output captured
- Failure is for the RIGHT reason (not syntax error)
Example output:
PHASE 1 - RED ✗
Test: should return user by email
Result: FAILED
Failure: expected undefined to equal { id: 1, email: '[email protected]' }
Proceeding to Phase 2...
Phase 2: GREEN (Make It Pass)
BLOCKED: Cannot proceed until test passes
- Write the MINIMUM code to make the test pass
- No refactoring, no extra features, no "while I'm here" changes
- Run the test - it MUST pass
- Document the pass output as proof
Phase 3: REFACTOR (Clean Up)
Only proceed after Phase 2 is complete
- Review code for improvements (naming, structure, duplication)
- Make changes while keeping tests green
- Run tests after each refactoring change
Blocking Conditions
| Phase | Condition to Proceed |
|---|---|
| RED → GREEN | Test failure output must be shown |
| GREEN → REFACTOR | Test pass output must be shown |
| REFACTOR → Done | Tests must still pass |
If Phase 1 is missing: "BLOCKED: PHASE 1 - RED REQUIRED"
Test Suggestions from Diff
Analyze code changes and recommend test additions.
Procedure
- Get all changes in this branch compared to default
- Identify changed functions, methods, classes
- Prioritize by risk level:
| Risk Level | Triggers |
|---|---|
| HIGH | New code, core logic, missing coverage |
| MEDIUM | Modified parameters, return types, conditionals |
| LOW | Trivial changes with existing coverage |
Output Format
## Risk Level High
**functionName**
- location: src/path/to/file.ts
- change type: modified
- reason: Why this needs tests
- suggested tests:
- Test case 1
- Test case 2
Test Generation
Generate comprehensive tests for functions.
Phases
- Detect: Identify language and testing framework
- Locate: Find existing tests, determine placement
- Analyze: Parse signatures, inputs, outputs, edge cases
- Design: Create minimal set for branch coverage
- Emit: Write tests consistent with framework style
- Validate: Self-check imports, assertions, compilation
- Run: Execute tests, verify they pass
Security-Focused Cases
Include tests for:
- Invalid/tainted inputs
- Injection payloads
- Path traversal
- Overflow/underflow
- Encoding pitfalls
Property-Based Testing
Use for stronger coverage than example-based tests.
When to Use
| Pattern | Property | Priority |
|---|---|---|
| encode/decode pair | Roundtrip | HIGH |
| Pure function | Multiple | HIGH |
| Validator | Valid after normalize | MEDIUM |
| Sorting/ordering | Idempotence + ordering | MEDIUM |
| Normalization | Idempotence | MEDIUM |
Property Catalog
| Property | Formula | When to Use |
|---|---|---|
| Roundtrip | decode(encode(x)) == x |
Serialization pairs |
| Idempotence | f(f(x)) == f(x) |
Normalization, formatting |
| Invariant | Property holds before/after | Any transformation |
| Commutativity | f(a, b) == f(b, a) |
Binary/set operations |
Detection Patterns
Invoke when you detect:
- Serialization pairs: encode/decode, serialize/deserialize, toJSON/fromJSON
- Parsers: URL parsing, config parsing, protocol parsing
- Normalization: normalize, sanitize, clean, canonicalize
- Validators: is_valid, validate, check_*
For detailed patterns, see references/property-patterns.md.
Combined With no-workarounds
When both tdd AND no-workarounds are activated:
- You are BLOCKED from implementing ANY fix until Phase 1 (RED) is complete
- You are BLOCKED from working around the tool failure
- The ONLY valid path: RED → GREEN → REFACTOR → Verify tool works
Rationalizations (All Rejected)
| Excuse | Why It's Wrong | Required Action |
|---|---|---|
| "It's a simple change" | Simple changes still need tests | Write the test |
| "I'll add tests after" | Tests after = not TDD | BLOCKED |
| "Tests are slow" | Speed doesn't override process | Write the test |
| "I know this works" | Confidence ≠ proof | Write the test |
| "Just this once" | That's what you said last time | Write the test |
Reference Files
references/property-patterns.md- Property-based testing patternsreferences/libraries.md- PBT libraries by language
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?