code-comment-guidelines
Skill2 starsChanged 4 months agoMITView on GitHub
代码注释规范——写代码、修改代码、重构、修 bug 时的注释书写纪律。不得在注释中透露修改意图、步骤或元信息,注释如初写,只描述功能与设计理由。适用于所有语言的编码场景。
1 other project uses a version of this.
Adopted by
Most recently taken up by
- loskyertt/agent_skillstheir own version, first seen May 26, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- loskyertt/agent_skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- adr-guidelinesSkill
- c-coding-guidelinesSkill
- doc-writing-guidelinesSkill
- embedded-testing-guidelinesSkill
- file-tool-usage-guidelinesSkill
- git-commit-guidelinesSkill
- git-pr-issue-guidelinesSkill
- godot-2d-guidelinesSkill
- hallucination-control-promptingSkill
- karpathy-guidelinesSkill
- math-formula-guidelinesSkill
- react-guidelinesSkill
- reference-first-codingSkill
- rust-guidelinesSkill
- sci-formula-verifySkill
- scripts-writing-guidelinesSkill
- skill-design-guidelinesSkill
- tauri-guidelinesSkill
- typescript-guidelinesSkill
- web-reference-tracingSkill
The file
Files
代码注释规范
在修改代码时,只允许添加、删除或调整实现逻辑,不得在注释中透露你的修改意图、修改步骤、修改原因或任何与"改动"相关的元信息。
1. 注释内容限定
注释只描述"做什么(What)"和"为什么这样设计(Why)",例如解释一段逻辑的目的、算法思路、边界条件、业务含义等。
2. 注释书写位置
- 单行注释:使用语言特定的单行注释符号(如
//、#),放在该行代码的同行后方。 - 过长的注释:如果注释内容超出合理行宽,改用多行注释,使用语言特定的多行注释块语法(如
/* */、'''、"""等)。
3. 禁止出现的修改痕迹
注释中禁止出现任何修改痕迹,包括但不限于:
- ❌ "修改:将 A 改为 B"
- ❌ "优化:使用流式处理"
- ❌ "之前用 X,现在改为 Y"
- ❌ "根据需求,调整为……"
- ❌ "新增:……" / "移除:……" / "替换:……"
- ❌ 任何带有时间戳、版本号和改动作者的信息
4. 原有注释的处理
如果某个注释在修改前已经存在且功能描述仍然正确,就保留它;如果功能含义变化了,只更新功能描述部分,更新后依然要像原开发者自己写的一样自然。
即使大量重写注释周围的代码,也不得删除或移动该注释——除非注释对应的功能本身已被移除。保持注释的原始位置(行上方 / 行尾)和结构(单行 / 多行)不变。
5. 编写新注释
如果一段代码确实需要结构性解释,可以写全新的功能性注释,但必须假装这是第一次编写,完全不要提及之前版本是什么样的。
6. 核心原则
你可以把代码改得更好,但注释呈现出来时,不应该让读者看出这是一份被修改过的代码。
简单说:代码可以变,注释如初写。
7. 自检要求
输出前逐项检查:
- 新增注释是否只描述"做什么"或"为什么这样设计",无修改痕迹
- 原有正确注释是否保留了原文、原位置、原结构
- 代码块旁的注释是否仅描述功能,不提及前后版本差异
如违反以上任一条,重新输出。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

