Skip to main content
skill CX Codex

tdd · pymodel — Claude Code skill: what it does, how to install

A TDD rule guide for AI coding assistants that enforces the red-green-refactor workflow. Helps models write reliable unit tests before touching application code.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add PyModel/react-frontend-skills --skill tdd -a claude-code
Open on GitHub

What tdd does

The skill provides a structured guideline of 42 test-driven development rules grouped into 8 prioritized tiers. It forces the agent to follow the standard cycle: write a failing test, produce the minimum code necessary to pass, and clean up the result right away.

Every rule references a dedicated file under references/<rule-id>.md showing the underlying reason alongside bad versus good code patterns. The collection covers Arrange-Act-Assert structure, factory and builder patterns for data, external dependency stubs, and unit test execution speed without arbitrary sleep delays.

Framework-specific syntax for Vitest or network mocking with MSW is not part of this skill. PyModel delegates those topics to companion skills vitest and msw.

What it helps with

  • enforce strict red-green-refactor steps in AI-generated code
  • isolate unit tests from external dependencies and shared mutable state
  • eliminate arbitrary sleep delays and flaky test logic
  • organize test suites around user behavior instead of class methods

Example prompts for the agent

  • Implement this payment processor feature using TDD, starting with a failing test
  • Review existing unit tests against the rule design-avoid-logic-in-tests
  • Refactor the test fixtures using factories instead of shared global state

How to install tdd

1Skills CLI (Vercel)

npx skills add PyModel/react-frontend-skills --skill tdd -a claude-code

2Manually: put the files in place

~/.claude/skills/tdd/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/tdd/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about tdd

How to install tdd in Claude Code?

Run npx skills add PyModel/react-frontend-skills --skill tdd -a claude-code in your terminal. The configuration file will be placed at ~/.claude/skills/tdd/SKILL.md.

What does the tdd skill do?

It gives your AI agent 42 rules spanning 8 priority tiers, enforcing test-first workflows and clean test design. The model learns to write minimal passing code and avoid test anti-patterns.

Does this skill handle Vitest or MSW mocks?

No, it focuses on general testing architecture and TDD principles. The repository author provides separate companion skills named vitest and msw for runner-specific syntax and API interception.

Source text

SKILL.md · MIT
---
name: tdd
description: Test-driven development with red-green-refactor.
---

# 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

1. **RED**: Write a failing test that defines desired behavior
2. **GREEN**: Write minimal code to make the test pass
3. **REFACTOR**: Clean up code while keeping tests green
4. Repeat for each new behavior

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Red-Green-Refactor Cycle | CRITICAL | `cycle-` |
| 2 | Test Design Principles | CRITICAL | `design-` |
| 3 | Test Isolation & Dependencies | HIGH | `isolate-` |
| 4 | Test Data Management | HIGH | `data-` |
| 5 | Assertions & Verification | MEDIUM | `assert-` |
| 6 | Test Organization & Structure | MEDIUM | `org-` |
| 7 | Test Performance & Reliability | MEDIUM | `perf-` |
| 8 | Test Pyramid & Strategy | LOW | `strat-` |

## Quick Reference

### 1. Red-Green-Refactor Cycle (CRITICAL)

- `cycle-write-test-first` - Write the Test Before the Implementation
- `cycle-minimal-code-to-pass` - Write Only Enough Code to Pass the Test
- `cycle-refactor-after-green` - Refactor Immediately After Green
- `cycle-verify-test-fails-first` - Verify the Test Fails Before Writing Code
- `cycle-small-increments` - Take Small Incremental Steps
- `cycle-maintain-test-list` - Maintain a Test List

### 2. Test Design Principles (CRITICAL)

- `design-test-behavior-not-implementation` - Test Behavior Not Implementation
- `design-one-assertion-per-test` - One Logical Assertion Per Test
- `design-descriptive-test-names` - Use Descriptive Test Names
- `design-aaa-pattern` - Follow the Arrange-Act-Assert Pattern
- `design-test-edge-cases` - Test Edge Cases and Boundaries
- `design-avoid-logic-in-tests` - Avoid Logic in Tests

### 3. Test Isolation & Dependencies (HIGH)

- `isolate-mock-external-dependencies` - Mock External Dependencies
- `isolate-no-shared-state` - Avoid Shared Mutable State Between Tests
- `isolate-deterministic-tests` - Write Deterministic Tests
- `isolate-prefer-stubs-over-mocks` - Prefer Stubs Over Mocks for Queries
- `isolate-use-dependency-injection` - Use Dependency Injection for Testability

### 4. Test Data Management (HIGH)

- `data-use-factories` - Use Factories for Test Data Creation
- `data-minimal-setup` - Keep Test Setup Minimal
- `data-avoid-mystery-guests` - Avoid Mystery Guests
- `data-unique-identifiers` - Use Unique Identifiers Per Test
- `data-builder-pattern` - Use Builder Pattern for Complex Objects

### 5. Assertions & Verification (MEDIUM)

- `assert-specific-assertions` - Use Specific Assertions
- `assert-error-messages` - Assert on Error Messages and Types
- `assert-no-assertions-antipattern` - Every Test Must Have Assertions
- `assert-custom-matchers` - Create Custom Matchers for Domain Assertions
- `assert-snapshot-testing` - Use Snapshot Testing Judiciously

### 6. Test Organization & Structure (MEDIUM)

- `org-group-by-behavior` - Group Tests by Behavior Not Method
- `org-file-structure` - Follow Consistent Test File Structure
- `org-setup-teardown` - Use Setup and Teardown Hooks Appropriately
- `org-test-utilities` - Extract Reusable Test Utilities
- `org-parameterized-tests` - Use Parameterized Tests for Variations

### 7. Test Performance & Reliability (MEDIUM)

- `perf-fast-unit-tests` - Keep unit tests fast enough for continuous feedback
- `perf-avoid-network-calls` - Eliminate Network Calls in Unit Tests
- `perf-fix-flaky-tests` - Fix Flaky Tests Immediately
- `perf-parallelize-tests` - Parallelize Independent Tests
- `perf-avoid-sleep` - Avoid Arbitrary Sleep Calls

### 8. Test Pyramid & Strategy (LOW)

- `strat-test-pyramid` - Follow the Test Pyramid
- `strat-mutation-testing` - Use Mutation Testing to Validate Test Quality
- `strat-coverage-targets` - Set Meaningful Coverage Targets
- `strat-integration-boundaries` - Test Integration at Service Boundaries
- `strat-e2e-critical-paths` - Limit E2E Tests to Critical User Paths

## How to Use

Read `references/<rule-id>.md` for each rule above that matches the task: why it matters, then incorrect vs. correct code.

## Related Skills

- For Vitest framework specifics, see `vitest` skill
- For API mocking with MSW, see `msw` skill

© PyModel · MIT · PyModel/react-frontend-skills

Similar skills

All skills for Testing and QA →

tdd by other authors comes first.

tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. 1,141,062installs tdd backnotprop This skill makes the agent write a failing regression test for a bug before touching production code. It only kicks in when a cheap test path exists. CX Codex +1 5,100installs tdd codewithmukesh Guides a strict red-green-refactor cycle for .NET 10 applications using xUnit v3, WebApplicationFactory, and Testcontainers. CX Codex +1 2,800installs tdd brianlovin Guides agents through a disciplined red-green-refactor loop. It builds features one vertical slice at a time and tests public behavior over implementation details. CX Codex +1 2,800installs tdd parcadei A skill that keeps the agent on a strict red-green-refactor loop: failing test first, minimal code next, then verification. CX Codex +1 470installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. 1,163,035installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. CX Codex +1 678,700installs skill-creator official anthropics Creates and refines skills, then tests them with prompts, evaluations, and performance checks. 414,180installs agent-browser vercel-labs A CLI skill for browser control: it opens pages, fills forms, clicks buttons, and tests web apps. Use it when an agent needs to act inside a website. CX Codex +1 1,200,000installs prototype Matt Pocock Creates throwaway prototypes for checking state logic or exploring UI before committing the decision to the main codebase. 986,201installs

From the same set11

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor