AGENT SKILL

代码注释编写与审查

code-comments

编写代码注释时,只注释非显而易见之处,删掉其余注释。在编写或编辑源代码注释、为改动添加解释性注释,或用户要求添加、精简、审查注释时使用。引导生成简短、以意图为中心的注释,避免背景故事、辩解理由或复述代码。

使用场景代码实现
License 许可
MIT
最近更新
2026-10-26
Stars
★ 2
Forks
1

01 前言 Front Matter

name
code-comments
description
Write code comments that comment the non-obvious and delete the rest. Use when writing or editing comments in source code, adding explanatory comments to a change, or when the user asks to add, trim, or review comments. Steers toward brief, intent-focused comments and away from backstory, justification, or restating the code.

03 SKILL.md 正文

Code comments

Comment the non-obvious; delete the rest. A comment is a cost (it rots, it adds noise); it has to buy more than it costs.

A comment earns its place only if it says something the code can't

  • Intent that isn't visible in the code itself
  • A non-obvious decision or trade-off: why here, why this way, not the obvious alternative
  • A constraint, invariant, or gotcha that will bite a later editor
  • A pointer to context the reader needs (spec, ticket) as a link, not a retelling

Never

  • Restate what the code plainly does (// increment i) or echo the function/variable name
  • Narrate the backstory or justify the change: what was broken, what you investigated, why it matters. That's PR / commit / ticket territory, not source.
  • Leave a comment the next edit will quietly make false

The test

Before keeping a comment, ask: does this describe what the code does or why it's here, or is it justifying the change / telling a story? A story or a justification gets cut, or moved to the commit or PR.

Style

  • Usually one line. Say the thing and stop.
  • Match the file's existing comment density and idiom; don't import a different house style.
  • Prefer why over what. The what is in the code and rots fast; the why rots slowly.
  • Rich context (root cause, the investigation, environment-specific findings) belongs in the PR, ticket, or commit message, not the source.

Worked example: trim to the one non-obvious fact

A collectDefaultMetrics() call added to a shared metrics module:

v1 (7 lines): full backstory — idle process serves empty /metrics, looks
              identical to a broken endpoint, makes the partner metric a
              clean signal…                                    → an essay
v2 (2 lines): "…so an idle process still exposes a non-empty /metrics;
              every other metric here is labelled…"            → still justifying the change
v3 (1 line):  "Here, not per-app, so every app importing these metrics
              also gets the process_*/nodejs_* baseline."      → the one non-obvious fact: placement

Each trim drops a layer of justification until only the thing a reader can't infer from the code remains: why the call lives in this shared module.

04 同仓库更多 Skills

SamFleming
SamFleming/dotfiles

宏观视角上下文梳理

zoom-out

让智能体(agent)拉远视角,提供更广泛的上下文或更高层次的视角。当你不熟悉某段代码,或需要理解它如何融入整体大局时使用。

软件开发工程师开发参考
★ 2
SamFleming
SamFleming/dotfiles

测试驱动开发(TDD)

tdd

测试驱动开发。当用户希望以测试优先的方式构建功能或修复缺陷、提到“红-绿-重构”(red-green-refactor),或需要集成测试时使用。

软件开发工程师测试与质量保障
★ 2
SamFleming
SamFleming/dotfiles

代码库架构优化

improve-codebase-architecture

扫描代码库以发现架构深化改进的机会,以可视化 HTML 报告的形式呈现,然后针对你选定的某一项进行深入剖析(严格审视)。

系统架构师设计评审与架构优化
★ 2
SamFleming
SamFleming/dotfiles

会话交接文档生成

handoff

将当前对话精简为一份交接文档,供另一个智能体接手继续工作。

软件开发工程师会话上下文交接
★ 2
SamFleming
SamFleming/dotfiles

方案压力质询

grilling

对用户提出的计划、决策或想法进行不留情面的连续追问。当用户想要压力测试自己的思路,或使用任何'grill'触发短语时使用。

软件开发工程师方案质询与决策压力测试
★ 2
SamFleming
SamFleming/dotfiles

方案质询与文档生成

grill-with-docs

一场不留情面的连续追问式访谈,用于打磨计划或设计,同时在此过程中创建文档(ADR 和术语表)。

软件开发工程师方案质询与决策压力测试
★ 2