test-driven-development
它能做什么
这个技能引导 AI 进行测试驱动开发:先编写能展示问题的测试,然后进行小范围修复。适合希望获得改动有效性证明的开发者。
适用场景
- ✓当你希望以先写测试的方式构建新功能的时候。
- ✓当你需要修复 bug,并先用一个失败的测试来证明修复的时候。
- ✓当你要改变行为,并希望避免破坏现有测试的时候。
技能链接
https://github.com/odysseus-dev/odysseus/blob/dev/resources/skills/general/test-driven-development/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请修复搜索结果为空时页面崩溃的 bug。先写一个失败的测试,再进行修复。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 阅读现有代码和测试,编写能展示预期行为的最小测试,并确认它失败。然后它做出能让测试通过的最小改动,并审阅差异。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
When to Use
Use when implementing a feature, fixing a bug, or changing behavior where a regression test can define the expected result. Prefer this workflow for parser, routing, agent-loop, and UI behavior changes.
Procedure
- Inspect the relevant code, existing tests, and local conventions before editing.
- Write the smallest regression test that demonstrates the requested behavior or reproduces the bug.
- Run that test and confirm it fails for the expected reason, not because the test setup is broken.
- Make the smallest production change that makes the test pass.
- Run the focused test again, then run the surrounding module suite.
- Review the diff for unrelated changes, brittle assertions, hidden state, and missing error paths.
- Report the tests run and any remaining coverage or environment limits.
Pitfalls
- Do not write a test that only mirrors the implementation; assert the user-visible contract.
- Do not weaken an assertion just to make a failing test pass.
- Do not skip the focused failing-test step when the behavior is observable in a local test.
- Keep network, filesystem, and model calls deterministic with fakes or fixtures unless the integration itself is under test.
Verification
- The new regression test fails before the fix and passes after it.
- The relevant focused suite passes.
- The broader suite passes or its failure is explained with evidence.
- The final diff contains the test and the production change needed for the same behavior.
常见问题
为什么测试必须先失败?
该技能说明,失败的测试可以证明该测试确实检查了这一行为,而不是偶然通过。
它会为了让测试通过而削弱测试吗?
不会。该技能说明,不要为了让失败的测试通过而减弱断言。
测试中的网络调用如何处理?
该技能会用伪造对象或测试夹具(fixtures)保持它们的可预测性,除非被测的正是连接本身。
详情
热度
- GitHub 星标
- 95k
- 排名
- #1315
- 许可证
- AGPL-3.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
odysseus
95k让你的智能体通过限定范围的令牌,读取并更新你的 Odysseus 数据,例如待办事项、邮件、日历、记忆和文档。
odysseus
95k让你的智能体通过 Codex Agent 令牌,读取并更新你的 Odysseus 数据,例如待办事项、邮件、日历、记忆和文档。
artifact-completion
95k帮你的智能体尽早产出所需的文件或文档,根据实际输出进行完善,并在宣布完成前进行检查。
terminal-recovery
95k帮你的智能体从失败的终端命令中恢复,读取错误信息,找出可能的原因,并尝试一次有针对性的修复。