360 Secure SkillHub
360 安全技能中心

TDD Workflow

核心功能:严格执行红-绿-重构流程,生成单元、集成、E2E测试用例,确保80%+综合代码覆盖率,引导从测试编写到重构的完整TDD周期。典型场景:新功能开发、bug修复、代码重构,用户说“write tests”“add specs”等词时激活。输入为用户需求描述,输出为结构化测试用例、代码实现步骤及覆盖率验证指引。

djc00p
djc00p
热度 65.02
最近更新 2026-05-11 17:40:29
分类:开发依赖:代码执行应用场景:代码生成 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add tdd-workflow
Metadata
name
tdd-workflow
description
Test-driven development workflow enforcing 80%+ code coverage with unit, integration, and E2E tests. Write tests first, validate RED state, implement minimally, validate GREEN, then refactor. Use when writing features, fixing bugs, or refactoring. Trigger phrases: write tests, TDD, test-driven, feature implementation, bug fix. Adapted from everything-claude-code by @affaan-m (MIT)
metadata
{"clawdbot":{"emoji":"✅","requires":{"bins":["npm","git"],"env":[]},"os":["darwin","linux","win32"]}}

Test-Driven Development Workflow

Ensure all code development follows TDD principles with 80%+ code coverage.

When to Activate

  • Writing new features or functionality
  • Fixing bugs or issues
  • Refactoring existing code
  • User says "write tests", "add specs", "how should I test this"

Quick Start

  1. Write user journey in acceptance-test format ("As a [role], I want...")
  2. Generate test cases (happy path + edge cases + errors)
  3. Run tests → verify RED state (must fail before implementation)
  4. Implement minimal code to make tests pass → GREEN state
  5. Refactor while keeping tests green
  6. Verify 80%+ coverage achieved

Key Concepts

  • Tests before code — Write tests first, then implementation
  • RED-GREEN-REFACTOR — Fail → Pass → Improve (no exceptions)
  • 80% coverage minimum — Unit, integration, and E2E combined
  • Unit-level isolation — Mock dependencies, test behavior not implementation
  • Independent tests — No test ordering dependencies; each can run solo

Common Usage

Most frequent patterns:

  • Unit tests for functions and components
  • Integration tests for API endpoints and database operations
  • E2E tests for critical user flows
  • Edge case and error path testing
  • Fast execution (unit tests < 50ms each)

References

  • references/workflow-steps.md — Detailed 7-step TDD cycle with git checkpoints
  • references/patterns-and-best-practices.md — Test patterns, common mistakes, success metrics