mcpField
T
tdd

tdd

github.com/zereightTesting & quality2.1k58 installsUpdated today
Repository

About tdd

A test-driven development skill that enforces a failing-test-first Red-Green-Refactor cycle. It gives stepwise checks, test-naming guidance, framework commands, and fixes for common TDD pitfalls.

Key features

  1. 01Failing test before production code
  2. 02Red-Green-Refactor cycle
  3. 03Run tests after each change
  4. 04Behavior-focused test naming
  5. 05Framework-specific test commands
  6. 06Guidance on common TDD pitfalls

Use cases

  1. 01Starting a feature with a failing behavior test
  2. 02Keeping existing tests green during implementation
  3. 03Writing tests as executable specifications
  4. 04Avoiding over-mocking and multi-behavior tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/zereight/gitlab-mcp --skill tdd

After installing, type/tddin Claude Code to confirm it loaded.

Details

From the project README

TDD — Test-Driven Development

THE IRON LAW: Write the failing test FIRST. Always.

The Red-Green-Refactor Cycle

RED   → Write a failing test for the NEXT behavior
GREEN → Write ONLY enough code to make it pass (no extras)
REFACTOR → Clean up code quality (tests must stay green after every change)
REPEAT

Step-by-Step Protocol

1. RED Phase
  1. Identify the smallest next behavior to implement
  2. Write a test that describes that behavior as a named it() / test() / def test_
  3. Run the test — it MUST FAIL. If it passes, the test is wrong.
  4. Confirm the failure message is the RIGHT failure (not a syntax error)
// Example: RED — test fails because function doesn't exist yet
it('returns an empty array for an empty input', () => {
  const result = parseItems([]);
  expect(result).toEqual([]);  // FAILS: parseItems is not defined
});
2. GREEN Phase
  1. Write the MINIMUM code to make the test pass
  2. Do not add extra logic, default parameters, or "nice-to-haves"
  3. Run ALL tests — the new test must pass; existing tests must not break
// Example: GREEN — just enough to pass
function parseItems(input: string[]): string[] {
  return [];  // only enough for the current test
}
3. REFACTOR Phase
  1. Look at the code — can it be cleaner without changing behavior?
  2. Apply simplification patterns (see /ai-slop-cleaner and /coding-standards)
  3. Run tests after EVERY change. If tests break, undo immediately.

TDD Gate — When to Stop

SituationAction
Code written before testSTOP. Delete production code. Write test first.
Test passes on first run (no prior code)The test is wrong — fix it to fail first.
Multiple behaviors in one testSTOP. One test, one behavior.
Skipping refactor to go fasterGo back. Clean up before next feature.

Naming Tests as Specifications

Tests are executable documentation. Name them as complete sentences:

// BAD
it('test1', ...)
it('works with empty', ...)

// GOOD
it('returns empty array when input is empty', ...)
it('throws ValidationError when email is missing @', ...)
it('sends exactly one email when user registers', ...)

Framework Quick Reference

FrameworkFailing assertionRun single test
Vitestexpect(x).toBe(y)npx vitest run -t "test name"
Jestexpect(x).toBe(y)npx jest -t "test name"
pytestassert x == ypytest -k "test_name"
cargo testassert_eq!(x, y)cargo test test_name
go testt.Errorf(...)go test -run TestName

Common TDD Pitfalls

PitfallFix
Testing implementation detailsTest behavior (outputs), not internals (private methods)
One test for 10 behaviorsSplit into atomic test cases
Mock everything (over-mocking)Mock at system boundaries only (DB, HTTP, filesystem)
No triangulationWrite 2-3 tests that force the correct implementation to emerge
Untriangulated constantsreturn 42 passes one test — add a second test to force real logic

See Also

  • @test-engineer — test strategy, framework detection, coverage gap analysis
  • /ultraqa — QA cycling: test, verify, fix, repeat
  • /verify — evidence-based completion verification

Comments

Markdown supported