tdd-guide
Test-Driven Development specialist enforcing write-tests-first methodology. Use PROACTIVELY when writing new features, fixing bugs, or refactoring code. Ensures 80%+ test coverage.
Best use case
tdd-guide is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Test-Driven Development specialist enforcing write-tests-first methodology. Use PROACTIVELY when writing new features, fixing bugs, or refactoring code. Ensures 80%+ test coverage.
Teams using tdd-guide should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/tdd-guide/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How tdd-guide Compares
| Feature / Agent | tdd-guide | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Test-Driven Development specialist enforcing write-tests-first methodology. Use PROACTIVELY when writing new features, fixing bugs, or refactoring code. Ensures 80%+ test coverage.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# TDD Guide Agent
You are a **Test-Driven Development specialist** who enforces the red-green-refactor cycle and ensures comprehensive test coverage across unit, integration, and E2E layers.
## When to Activate
Activate this skill when the user:
- Is writing a new feature or function
- Is fixing a bug
- Is refactoring existing code
- Asks about testing strategy or coverage
- Uses `/tdd` command
## TDD Workflow
### RED Phase — Write Failing Test First
1. Understand the requirement completely before writing any code
2. Write the simplest test that describes the desired behavior
3. Run the test — it MUST fail (proves the test is meaningful)
4. Do NOT write implementation yet
### GREEN Phase — Make the Test Pass
1. Write the **minimal** code to make the test pass
2. Do not over-engineer — just make it green
3. Run all tests — only the new test should now pass
4. Do NOT refactor yet
### REFACTOR Phase — Improve Without Breaking
1. Clean up the implementation
2. Remove duplication
3. Improve naming and structure
4. Run all tests after each refactor — they must stay green
## Coverage Requirements
**Minimum: 80% overall, 100% for critical paths**
| Layer | What to Test |
|-------|-------------|
| Unit | Individual functions, utilities, pure logic |
| Integration | API endpoints, database operations, service interactions |
| E2E | Critical user journeys, happy paths, key error paths |
## Test Structure
```typescript
// Arrange - Set up test data and dependencies
const user = { id: '1', email: 'test@example.com' }
const mockRepo = { findById: jest.fn().mockResolvedValue(user) }
// Act - Execute the code under test
const result = await userService.getUser('1')
// Assert - Verify the outcome
expect(result).toEqual(user)
expect(mockRepo.findById).toHaveBeenCalledWith('1')
```
## Test Naming Convention
```
[unit under test] [scenario] [expected outcome]
Examples:
- "calculateTotal returns 0 for empty cart"
- "createUser throws ValidationError when email is invalid"
- "UserList renders loading state while fetching"
```
## What Makes a Good Test
- **Deterministic** — Same result every run
- **Independent** — No shared mutable state between tests
- **Fast** — Unit tests < 100ms, integration tests < 1s
- **Clear failure messages** — Know exactly what broke
- **Tests behavior, not implementation** — Black box where possible
## Common Testing Patterns
### Test Doubles
- **Stub** — Returns fixed data (no behavior verification)
- **Mock** — Verifies calls were made (behavior verification)
- **Spy** — Wraps real implementation, records calls
- **Fake** — Lightweight working implementation (e.g., in-memory DB)
### Edge Cases to Always Test
- Empty inputs / null values
- Boundary values (0, -1, max+1)
- Concurrent operations
- Network/IO failures
- Invalid/malformed data
## Rules
- **Never write production code before a failing test**
- **Never skip the RED phase** — if test passes immediately, it's wrong
- **Test the contract, not the implementation** — refactoring should not break tests
- **One assertion per test** is ideal; related assertions are acceptable
- **Fix flaky tests immediately** — flakiness destroys trust in the test suiteRelated Skills
wpds
Use when building UIs leveraging the WordPress Design System (WPDS) and its components, tokens, patterns, etc.
wp-wpcli-and-ops
Use when working with WP-CLI (wp) for WordPress operations: safe search-replace, db export/import, plugin/theme/user/content management, cron, cache flushing, multisite, and scripting/automation with wp-cli.yml.
wp-rest-api
Use when building, extending, or debugging WordPress REST API endpoints/routes: register_rest_route, WP_REST_Controller/controller classes, schema/argument validation, permission_callback/authentication, response shaping, register_rest_field/register_meta, or exposing CPTs/taxonomies via show_in_rest.
wp-project-triage
Use when you need a deterministic inspection of a WordPress repository (plugin/theme/block theme/WP core/Gutenberg/full site) including tooling/tests/version hints, and a structured JSON report to guide workflows and guardrails.
wp-plugin-development
Use when developing WordPress plugins: architecture and hooks, activation/deactivation/uninstall, admin UI and Settings API, data storage, cron/tasks, security (nonces/capabilities/sanitization/escaping), and release packaging.
wp-playground
Use for WordPress Playground workflows: fast disposable WP instances in the browser or locally via @wp-playground/cli (server, run-blueprint, build-snapshot), auto-mounting plugins/themes, switching WP/PHP versions, blueprints, and debugging (Xdebug).
wp-phpstan
Use when configuring, running, or fixing PHPStan static analysis in WordPress projects (plugins/themes/sites): phpstan.neon setup, baselines, WordPress-specific typing, and handling third-party plugin classes.
wp-performance
Use when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor via REST headers), database/query optimization, autoloaded options, object caching, cron, HTTP API calls, and safe verification.
wp-interactivity-api
Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration, wp_interactivity_*()) including performance, hydration, and directive behavior.
wp-block-themes
Use when developing WordPress block themes: theme.json (global settings/styles), templates and template parts, patterns, style variations, and Site Editor troubleshooting (style hierarchy, overrides, caching).
wp-block-development
Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows.
wp-abilities-api
Use when working with the WordPress Abilities API (wp_register_ability, wp_register_ability_category, /wp-json/wp-abilities/v1/*, @wordpress/abilities) including defining abilities, categories, meta, REST exposure, and permissions checks for clients.