Skip to content
cccskills
FreePublished on GitHub

tdd-workflow

Use this skill when the user explicitly asks for TDD or a tests-first workflow, or when developing a new feature with a test coverage requirement. Provides a structured red-green-refactor workflow with unit, integration, and E2E test guidance.

The English summary is being prepared. Showing the original description.

See how to install

Files included (4)

  • SKILL.md4.1 KB
  • references/test-templates.md3.8 KB
  • references/testing-mistakes.md2.3 KB
  • scripts/check-coverage.sh1.3 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Test-Driven Development Workflow

This skill provides a structured TDD workflow for projects that adopt tests-first development.

When to Activate

  • The user explicitly asks for TDD or tests-first development
  • New feature work where test coverage is a stated requirement
  • Adding API endpoints or components under a coverage policy

For routine bug fixes or refactors, add focused tests for the changed behavior instead of invoking this full workflow (the /tdd command and tdd-guide agent remain available when you want it explicitly).

Core Principles

1. Tests BEFORE Code

Within this workflow, the default is to write tests first, then implement code to make tests pass.

2. Coverage Guidance

  • Coverage target follows the project's own standard (e.g., 80% as a common baseline); scale effort with the size of the change
  • Cover relevant edge cases
  • Test error scenarios
  • Verify boundary conditions

3. Test Types

Unit Tests - Individual functions, utilities, component logic, pure functions, helpers.

Integration Tests - API endpoints, database operations, service interactions, external API calls.

E2E Tests (Playwright) - Critical user flows, complete workflows, browser automation, UI interactions. Applies to web UI projects only.

TDD Workflow Steps

Step 1: Write User Journeys

As a [role], I want to [action], so that [benefit]

Example:
As a user, I want to search for markets semantically,
so that I can find relevant markets even without exact keywords.

Step 2: Generate Test Cases

For each user journey, create comprehensive test cases covering happy paths, edge cases, fallback behavior, and sorting/filtering logic.

Step 3: Run Tests (They Should Fail)

Use the project's test runner. Examples:

npm test                      # Node.js
pytest                        # Python
bash tests/run-unit-tests.sh  # shell projects
# Tests should fail - we haven't implemented yet

Step 4: Implement Code

Write minimal code to make tests pass.

Step 5: Run Tests Again

Re-run the same test command (e.g., npm test, pytest):

npm test
# Tests should now pass

Step 6: Refactor

Improve code quality while keeping tests green:

  • Remove duplication
  • Improve naming
  • Optimize performance
  • Enhance readability

Step 7: Verify Coverage

Use the project's coverage tooling. Examples:

npm run test:coverage   # Node.js
pytest --cov            # Python
# Verify coverage meets the project's target

Best Practices

  1. Write Tests First - Always TDD
  2. One Assert Per Test - Focus on single behavior
  3. Descriptive Test Names - Explain what's tested
  4. Arrange-Act-Assert - Clear test structure
  5. Mock External Dependencies - Isolate unit tests
  6. Test Edge Cases - Null, undefined, empty, large
  7. Test Error Paths - Not just happy paths
  8. Keep Tests Fast - Unit tests < 50ms each
  9. Clean Up After Tests - No side effects
  10. Review Coverage Reports - Identify gaps

Success Metrics

  • Coverage target met (per project standard, e.g., 80%)
  • All tests passing (green)
  • No skipped or disabled tests
  • Fast test execution (< 30s for unit tests)
  • E2E tests cover critical user flows
  • Tests catch bugs before production

References

These templates target JavaScript/TypeScript stacks; adapt the structure for other languages.

  • references/test-templates.md - Unit, integration, E2E, and mocking code templates (JS/TS)
  • references/testing-mistakes.md - Common pitfalls, file organization, coverage config, CI setup (JS/TS)

Remember: Give changed behavior a focused test. Tests are the safety net that enables confident refactoring, rapid development, and production reliability.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

日本語の業務文書を作成・修正するときに使用する共通品質基準。事実性、確度、論理、簡潔さ、自然な日本語を守る。提案書、報告、技術説明、議事録、メール、Slack、要約、レビューに適用する。創作、広告コピー、コードや構造化データだけの生成には使用しない。

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

Formal evaluation framework for Claude Code sessions implementing eval-driven development (EDD) principles.

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.

The English summary is being prepared. Showing the original description.

cloudnative-co/claude-code-starter-kit154Updated Oct 12, 2026

See all skills by cloudnative-co

Report a problem with this skill