tdd
tdd guides you through strict test-driven development using the red-green-refactor cycle: write a failing test, implement minimal code to pass it, then refactor. The skill enforces the discipline of writing tests before production code and provides framework-specific commands for multiple languages.
tdd enforces test-driven development by guiding you through the red-green-refactor cycle to write failing tests first.
AI-generated summary based on this skill's SKILL.md
Install
zereight/gitlab-mcp/tdd · repository language: TypeScript
git clone https://github.com/zereight/gitlab-mcp
cp -r gitlab-mcp/.github/skills/tdd ~/.claude/skills/tddFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is the red green refactor cycle that tdd enforces?
tdd enforces the red-green-refactor cycle as the core TDD workflow. Red means writing a failing test first. Green means implementing minimal code to make that test pass. Refactor means improving the code while keeping tests passing. This cycle repeats for each feature, ensuring tests drive design and maintain coverage throughout development.
How do I write tests first with tdd?
tdd guides you to write failing tests before implementing production code. Start by defining what your code should do as a test case. Run it—it fails (red phase). Then write the minimal implementation to pass it (green phase). Finally, improve the code without breaking tests (refactor phase). This test-first discipline ensures your code is testable and requirements are clear from the start.
What TDD best practices does tdd help me avoid?
tdd teaches TDD best practices by helping you avoid common pitfalls: writing tests after code, skipping the refactor phase, writing overly complex tests, or testing implementation details instead of behavior. The skill enforces atomic test cases as executable specifications, keeping each test focused on one behavior. This prevents brittle tests and ensures your test suite remains maintainable.
Can tdd help me refactor code safely?
Yes. tdd supports safe refactoring by maintaining test coverage throughout the process. Since you've written tests before implementation, your test suite acts as a safety net. You can confidently refactor code knowing that if tests still pass, behavior is preserved. This coverage-first approach eliminates the fear of breaking functionality during improvements.
What framework-specific commands does tdd provide?
tdd provides framework-specific commands for multiple languages to support your TDD workflow. These commands help you run tests, watch for changes, and execute the red-green-refactor cycle efficiently across different tech stacks. The skill adapts to your language and testing framework, making TDD discipline accessible whether you use Jest, pytest, RSpec, or other popular test runners.
How does tdd structure atomic test cases?
tdd structures atomic test cases as executable specifications—each test focuses on a single behavior or requirement. This approach keeps tests small, readable, and maintainable. Atomic tests are easier to debug when they fail, provide clear documentation of expected behavior, and prevent cascading failures. tdd guides you to write these focused specifications so your test suite remains a reliable design tool.
SKILL.md
rendered from the published skill — quoted content, verbatim
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
- Identify the smallest next behavior to implement
- Write a test that describes that behavior as a named
it()/test()/def test_ - Run the test — it MUST FAIL. If it passes, the test is wrong.
- 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
- Write the MINIMUM code to make
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.github/skills/tdd/SKILL.md