tdd-workflows-tdd-green
它能做什么
这个工具可以帮你写出让失败的测试通过所需的最少代码。它专注于解决眼前的问题,让测试重新跑通。
适用场景
- ✓代码测试失败,你需要尽快修复时。
- ✓开始开发一个新功能,第一步是让某个测试通过时。
- ✓只想实现必要功能,让代码按预期运行时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflows-tdd-green/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的商品列表测试失败了,请生成最小代码让它通过。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会分析能让失败测试通过的最小代码改动。它会实施这个小修复,并检查测试是否已经通过,同时避免添加不必要的复杂度。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Green Phase: Simple function
def product_list(request): products = Product.objects.all() return JsonResponse({'products': list(products.values())})
Refactor: Class-based view
class ProductListView(View): def get(self, request): products = Product.objects.all() return JsonResponse({'products': list(products.values())})
Refactor: Generic view
class ProductListView(ListView): model = Product context_object_name = 'products'
### Express Patterns
**Inline → Middleware → Service Layer:**
```javascript
// Green Phase: Inline logic
app.post('/api/users', (req, res) => {
const user = { id: Date.now(), ...req.body };
users.push(user);
res.json(user);
});
// Refactor: Extract middleware
app.post('/api/users', validateUser, (req, res) => {
const user = userService.create(req.body);
res.json(user);
});
// Refactor: Full layering
app.post('/api/users',
validateUser,
asyncHandler(userController.create)
);
Use this skill when
- Moving from red to green in a TDD cycle
- Implementing minimal behavior to satisfy tests
- You want to keep implementation intentionally simple
Do not use this skill when
- You are refactoring for design or performance
- Tests are already passing and you need new requirements
- You need a full architectural redesign
Instructions
- Review failing tests and identify the smallest fix.
- Implement the minimal change to pass the next test.
- Run tests after each change to confirm progress.
- Record shortcuts or debt for the refactor phase.
Safety
- Avoid bypassing tests to make them pass.
- Keep changes scoped to the failing behavior only.
Resources
resources/implementation-playbook.mdfor detailed patterns and examples.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题
TDD 中的“绿色阶段”是什么意思?
在 TDD(测试驱动开发)中,“绿色阶段”指的是所有代码测试都已通过的状态。
为什么要只写最少的代码?
只写最少的代码可以避免不必要的复杂度,确保你解决的是测试指出的那个具体问题,这样以后也更容易维护。
什么时候应该停止使用这个工具?
当测试已经通过,并且你需要添加新功能时,或者当你的目标是改进整体代码设计,而不只是修复某个测试时,就应该停止使用。
详情
作者的原始描述
Implement the minimal code needed to make failing tests pass in the TDD green phase.
热度
- GitHub 星标
- 48k
- 排名
- #5935
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。