用测试驱动开发流程编写新功能、修复缺陷并安全重构代码。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "tdd-workflow" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/tdd-workflow/SKILL.md 2. 保存为 ~/.claude/skills/tdd-workflow/SKILL.md 3. 装好后重载技能,告诉我可以用了
请用 TDD 流程实现“用户可按标签筛选任务”功能。先列出验收标准,再编写单元测试、集成测试和 E2E 测试,最后给出最小实现代码,目标测试覆盖率不低于 80%。
先产出需求拆解与测试用例,再给出通过测试的最小实现代码及覆盖率建议。
我有一个缺陷:购物车在数量为 0 时仍显示总价。请按 TDD 流程处理:先写能复现问题的失败测试,再给出修复方案、补充回归测试,并说明如何验证覆盖率达到 80% 以上。
包含复现缺陷的测试、修复后的代码、回归测试以及覆盖率检查步骤。
请帮助我重构这段旧代码,并严格遵循 TDD。先识别现有行为并补齐特征测试,再提出重构步骤,逐步优化结构,同时保留单元、集成和端到端测试覆盖。
输出当前行为测试、分步重构计划、优化后的代码与测试完整性说明。
This skill ensures all code development follows TDD principles with comprehensive test coverage.
ALWAYS write tests first, then implement code to make tests pass.
HEAD on the active branch and belongs to the current task sequenceAs 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.
For each user journey, create comprehensive test cases:
describe('Semantic Search', () => {
it('returns relevant markets for query', async () => {
// Test implementation
})
it('handles empty query gracefully', async () => {
// Test edge case
})
it('falls back to substring search when Redis unavailable', async () => {
// Test fallback behavior
})
it('sorts results by similarity score', async () => {
// Test sorting logic
})
})
npm test
# Tests should fail - we haven't implemented yet
This step is mandatory and is the RED gate for all production changes.
Before modifying business logic or other production code, you must verify a valid RED state via one of these paths:
A test that was only written but not compiled and executed does not count as RED.
Do not edit production code until this RED state is confirmed.
If the repository is under Git, create a checkpoint commit immediately after this stage is validated. Recommended commit message format:
test: add reproducer for <feature or bug>…
通过双评审智能体对结果进行对抗式校验,提升输出发布前的可靠性
通过测试驱动开发流程,为新功能、修复和重构生成高覆盖测试与实现方案。