本文へ移動
cccskills
無料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.

インストール方法を見る

含まれるファイル(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(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

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

日本語の概要は準備中です。原文の説明を表示しています。

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

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

日本語の概要は準備中です。原文の説明を表示しています。

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

cloudnative-writing-baseline

無料日本語概要

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

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

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

日本語の概要は準備中です。原文の説明を表示しています。

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

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

日本語の概要は準備中です。原文の説明を表示しています。

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

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

日本語の概要は準備中です。原文の説明を表示しています。

cloudnative-co/claude-code-starter-kit1532026年10月8日 更新

cloudnative-co のスキルをすべて見る

このスキルの問題を報告する