跳到正文
cccskills
免费在 GitHub 公开

code-comments

Write tasteful, load-bearing comments in Apex source. Use when writing or editing code, JSDoc, TODOs, or file headers, or when deciding whether a comment should exist.

中文简介正在准备中。当前显示原文说明。

pensarai/apex星标 321(GitHub 321 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md3.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Code comments

How to comment when working on Apex. Read this before adding or rewriting comments.

This is repository-development guidance for coding agents working on Apex. Keep it in the repo's .agents/skills tree only; do not copy or link it into .claude/skills, .skills, skills, ~/.agents/skills, or ~/.pensar/skills, because Apex scans those locations as runtime skills.

Invariants

  • A comment must carry information the code cannot recover. If a better name or a smaller function would make it unnecessary, do that instead.
  • Comment the why, the why-not, and the invariant. Never narrate the next line.
  • Place a load-bearing comment next to the code it constrains. Distant essays get skipped and do not protect the dangerous line.
  • Stale comments are bugs. If you change behavior a comment describes, update or delete it in the same edit.
  • Write for the next reader who was not in this conversation — human or agent. No session notes, "the user asked for this," or chat residue.
  • Default to one sentence. Two or three lines when the constraint needs them. No multi-paragraph docstrings and no labeled taxonomies (CONTRACT, MUST, ARCHITECTURE).
  • Don't comment-out code; git remembers. Don't add comments to code you did not touch.

Write one when

  • The obvious approach is wrong, and the next editor will "fix" it
  • Correctness depends on order, aliasing, re-entrancy, ownership, or a peer that is not visible here
  • A value, timeout, limit, or encoding looks arbitrary
  • The code works around a platform, SDK, or spec quirk (name the quirk)
  • A public contract is not expressible in the type (single-read streams, processor ordering, "do not route X through Y")
  • You spent real time learning something the next reader will not see
  • A TODO is still justified — say why it is deferred and what "done" means

Do not write one when

  • It restates the identifier, type, or the next statement
  • JSDoc would only echo parameter names and return types
  • The code is unclear and should be renamed or extracted instead
  • You are padding a change so it "looks documented"
  • The file already makes the point at the call site that matters

Agents treat comments as durable memory. A precise invariant next to the line it protects prevents a locally reasonable, globally wrong edit. A paragraph of narration gets skipped or copied. Prefer the former.

House style

Match neighboring Apex comments: natural prose, complete sentences, no banner art except where a test file already uses section rules.

JSDoc is for exported types and methods when the types cannot carry the contract — who must call what, in what order, and what silently breaks. See src/core/observability/active-spans.ts and src/core/api/index.ts.

An empty catch still needs the reason the error is swallowed.

Shape

Narration — delete it:

// Reverse the spans
const spans = [...this.active.entries()].reverse();

Load-bearing — keep this shape:

// Spans start parent-first, so reverse insertion order closes the deepest
// children before their parents. Copy first because span.end() calls onEnd.

Weak JSDoc: /** Tracks active spans. */

Useful JSDoc: states why forceFlush cannot recover open spans, and that this processor must stay first in the provider list.

Before you keep a comment

  1. Can the code say this instead?
  2. Will this still be true after the next obvious refactor?
  3. Is it next to the line it protects?
  4. Would skipping it let someone make a locally reasonable, globally wrong edit?

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Create a new agent skill — global personal, project-personal, or project-team. Surveys existing skills, checks for overlap, handles the .claude/skills/ symlink and .gitignore whitelist for project skills. Use when you want to formalize a workflow or instruction set.

中文简介正在准备中。当前显示原文说明。

pensarai/apex3212026年10月25日 更新

pr

免费

Create, update, format, babysit, resolve conflicts and review findings on, and merge Apex pull requests and PR stacks. Use when the user asks to open or update a PR or merge request, align a stack, get CI green, address review or Bugbot findings, resolve merge conflicts, or merge.

中文简介正在准备中。当前显示原文说明。

pensarai/apex3212026年10月25日 更新

查看 pensarai 的全部技能

报告此技能的问题