code-comment
3
总安装量
2
周安装量
#61092
全站排名
安装命令
npx skills add https://github.com/homestylew/code-comment --skill code-comment
Agent 安装分布
amp
2
opencode
2
kimi-cli
2
codex
2
github-copilot
2
gemini-cli
2
Skill 文档
Code Comment
Use this skill only when the user’s input indicates they want comments: e.g. “add comments”, “åæ³¨é”, “document this”, “è§£éè¿æ®µä»£ç ”, “comment this”, “è¡¥å æ³¨é”. Do not apply when the user is asking for other changes (refactor, fix bug, etc.) unless they also ask for comments.
Response must follow user input: comment language, detail level (brief vs detailed), and scope (selection vs file) should be inferred from what the user said and what they selected.
Trigger (user input)
- Apply when the user says they want comments: in any language (e.g. å æ³¨é / add comments / document / è§£éä¸ä¸).
- Do not apply when the user did not ask for comments.
Response (follow user input)
Derive these from the user’s message and context:
| What to decide | How to derive |
|---|---|
| Comment language | Prefer the language of the user’s message (e.g. Chinese message â Chinese comments). If unclear, match existing comments in the file. Default to English only if neither applies. |
| Detail level | “ç®åæ³¨é” / “brief” / “ç®è¦” â minimal (file/function summary only). “详绔 / “detailed” / “æ¯è¡” â more inline explanation. No hint â moderate (public API + non-obvious logic). |
| Scope | User selected a range â comment only that range. User said “æ´ä¸ªæä»¶” / “whole file” â whole file. Otherwise infer from selection. |
If the user’s intent is ambiguous, ask once (e.g. “注éç¨ä¸æè¿æ¯è±æï¼” or “è¦ç®å注éè¿æ¯è¯¦ç»æ³¨éï¼”).
Instructions
- Identify language of the target file and open reference.md for that language’s comment format (JSDoc, docstring, Javadoc, etc.). If the language is not listed, use the file’s existing comment style or the language’s common doc format.
- Respect existing style in the file (same delimiter, indentation, line length). Match existing comment language if present.
- Add only comments â do not change any executable code (no rename, refactor, or logic change). Do not add TODO/FIXME unless the user asks.
- Preserve existing comments â if the file already has comments, keep them unless they are clearly outdated or wrong. Merge new comments with existing ones; do not duplicate. If an existing comment is inaccurate, update it in place.
- Comment hierarchy: file/module summary at top (if appropriate), then class/function doc blocks, then critical inline comments for non-obvious logic. Keep line length reasonable (e.g. 80â100 chars); wrap if needed.
- Decorator / annotation placement: place doc comments before decorators or annotations (Python
@decorator, Java@Override, etc.), following each language’s convention. - Mixed-language files: for files with multiple embedded languages (HTML with JS/CSS, Vue SFC, JSX/TSX), use the correct comment syntax for each language section (
<!-- -->for HTML,/* */for CSS,//or/** */for JS). - Avoid: comments that only repeat the code; restating type information already expressed in code (TypeScript types, Python type hints, Java generics â focus on semantics/why instead); secrets (keys, passwords); excessive inline noise. See examples.md for good vs bad.
When to skip or reduce comments
- Minified/bundled code: skip or minimal.
- Generated code: minimal or skip unless user asks.
- Test files with clear
describe/itnames: light comments only. - Config files (JSON, YAML, .env): only brief inline where needed.
- Trivial functions (getters, setters, simple delegation, one-line lambdas): skip or one-line summary only.
Quick reference
- Comment formats per language: reference.md
- Good/bad examples and i18n: examples.md