跳到正文
Skillpedia
通用编程7.0k · #13696

code-quality

它能做什么

这项技能为编写和审查代码、注释、测试及文档设定习惯标准。它适合希望代码整洁、测试真实可靠且易于维护的开发者。

适用场景

  • ✓当你在编写或审查代码,并希望应用一致的规范时。
  • ✓当你在判断某条注释应该写在代码里,还是写在测试里的时候。
  • ✓当测试过于容易通过,你需要检查它们是否真的能失败时。

技能链接

https://github.com/superdesigndev/treg/blob/main/.agents/skills/code-quality/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/superdesigndev/treg/blob/main/.agents/skills/code-quality/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“你能审查我的代码,告诉我哪些注释应该删除,以及哪些测试即使不该通过也可能通过吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查每条可由机器强制执行的规则,并为其添加检查。只有在行为无法改变的地方才保留注释,并要求测试通过真实入口运行,并且在通过之前先展示它们会失败。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Code quality

  1. 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.

  2. 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.

  3. 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.

  4. 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 通过而跳过、重试、添加等待或放宽断言。

详情

作者的原始描述

Use when writing or reviewing code, comments, tests, or docs.

repo: superdesigndev/treg

热度

GitHub 星标
7.0k
排名
#13696
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能