code-quality
它能做什么
这项技能为编写和审查代码、注释、测试及文档设定习惯标准。它适合希望代码整洁、测试真实可靠且易于维护的开发者。
适用场景
- ✓当你在编写或审查代码,并希望应用一致的规范时。
- ✓当你在判断某条注释应该写在代码里,还是写在测试里的时候。
- ✓当测试过于容易通过,你需要检查它们是否真的能失败时。
技能链接
https://github.com/superdesigndev/treg/blob/main/.agents/skills/code-quality/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能审查我的代码,告诉我哪些注释应该删除,以及哪些测试即使不该通过也可能通过吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查每条可由机器强制执行的规则,并为其添加检查。只有在行为无法改变的地方才保留注释,并要求测试通过真实入口运行,并且在通过之前先展示它们会失败。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Code quality
Enforce, don't instruct. If a machine can check a rule, add the check. Apply these rules to code you change; fix old code in its own PR.
Comments: none by default. Keep one only for behavior we cannot change (vendor, platform, protocol) or a public contract. A reason worth keeping moves to a test, the docs, or the commit message.
Tests must be able to fail. Test behavior through the real entry point; if a test still passes with every dependency returning None, it is fake. Break the behavior, show the failing run, then land it. Never turn CI green by skipping, retrying, sleeping, or loosening an assertion.
Docs say only what code cannot. Keep a sentence only if, without it, the next person would change the code wrongly. Each fact once, where it belongs; when docs and code disagree, fix the doc.
常见问题
为什么不鼓励写注释?
该技能说明,只有在代码无法改变时才保留注释,例如供应商或协议的限制。
什么样的测试是假的?
该技能说明,如果每个依赖都返回空值时测试仍然通过,那它就是假的测试。
我可以通过跳过测试让 CI 变绿吗?
不可以。该技能说明,绝不可以为了让 CI 通过而跳过、重试、添加等待或放宽断言。
详情
热度
- GitHub 星标
- 7.0k
- 排名
- #13696
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
google-ads
7.0k帮你的智能体安全地生成 Google Ads 报告并进行修改,避免常见的 API 版本和预算错误,以免浪费资金。
google-analytics
7.0k帮你的智能体从 Google Analytics 4 获取准确的流量、转化和收入数据,避免不完整的日期和虚假的零值。
google-search-console
7.0k帮你的智能体从 Search Console 报告自然搜索的点击、展示和排名,避免把尚不完整的近期数据误认为下降。
portrait-clone
7.0k帮你的智能体把一个人的参考照片转换为一份详细的 JSON 图像提示词,并固定每个视觉选择,使结果保持一致。