writing-comments
БесплатноБез исполняемых скриптовНе проверенHow to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or…
от withastro★ 64 390 звёзд на GitHubОб этом скилле
Writing Comments
Purpose
Comments in this repository are read by contributors, months or years after they were written, with none of the context you have right now. This skill defines who that reader is, what each kind of comment is for, and which patterns are banned.
Scope Boundary
This skill governs contributor-facing comments in the TypeScript/JavaScript source. It does not apply to end-user documentation:
- JSDoc blocks tagged
@docsinpackages/astro/src/types/public/config.tsandpackages/runtime/src/internal/core/errors/errors-data.tsare scraped by an externaldocgentool and published to the Astro docs website. Followpackages/astro/src/core/errors/README.mdfor those, and get docs-team review — CI regenerates the reference whentypes/public/**changes. - Other JSDoc across
types/public/**is surfaced to users through editor IntelliSense. Write it for Astro users building a site, not for contributors reading the source.
Everything below is about the source a contributor reads at HEAD.
The Reader
Write for an Astro contributor who is competent in TypeScript but has no access to your current context: not this conversation, not the pull request, not the issue, not the diff. They see only the repository at HEAD.
Two consequences follow directly:
- Never narrate change history. Words like "now", "previously", "no
longer", "the new approach" are meaningless at HEAD, where only one approach
exists. State how the code works, not how it came to be. (A
@deprecatednotice is the exception — see Conventions — because it describes the contract's future, which the reader needs.) - Never address the reviewer. A comment that argues your change is correct ("this properly handles X") belongs in the PR description, not in the source. The comment must justify the code as it stands, permanently.
Three Kinds of Comments, Three Different Jobs
| Kind | Syntax | Job | Contains |
|---|---|---|---|
| File / module overview | /** */ at the top of the file |
Explanation | Why the module exists, the concepts and terms it defines, how the pieces relate, design rationale |
| Item docs | /** */ directly above a declaration |
Reference | The contract: behavior, parameters, return value, thrown errors, invariants. Neutral and factual |
| Inline comments | // inside a body |
Rationale | Only what the code cannot say: constraints, workarounds (with issue links), non-obvious coupling |
Do not mix the jobs. Implementation details do not belong in the /** */
contract — put them as // comments inside the body. The contract does not
belong scattered across inline comments — put it on the declaration.
Behavior Documentation
When item documentation is warranted, write the contract for a human reader, not as a translation of the implementation. This does not require JSDoc for every function; names, types, and structure should carry straightforward behavior on their own.
- Start with a plain-language description of what the function returns or accomplishes.
- Use short or medium-length sentences with one main idea each.
- Avoid internal Astro jargon when callers do not need it. If a technical term is necessary, explain it in the same paragraph.
- Describe caller-visible caveats that can be surprising: fallback behavior,
work limits, ambiguous results, overload ordering, side effects, and the
conditions that return
undefined,null, an empty result, or another indeterminate value. - Document thrown errors when callers are expected to distinguish or recover from them.
- Do not describe implementation details unless callers need them to understand the behavior or use the API safely.
Add an example when behavior depends on a relationship the signature cannot show clearly. Common Astro and TypeScript cases include:
- which overload is selected;
- how arguments map to optional or rest parameters;
- which public Astro entrypoint exposes a symbol that is implemented or re-exported elsewhere;
- fallback behavior for ambiguous routes, incomplete configuration, or missing content;
- a result whose meaning is not obvious from its type.
Introduce the example in prose before the code block. State what it demonstrates and what result is expected. Keep snippets minimal, self-contained, and written from the perspective of an Astro user or the internal caller
Установить writing-comments в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл writing-comments?
How to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or editing comments in .ts/.js source, including comments added incidentally while fixing bugs or building features. Does not cover the @docs-generated config/error reference.
Как установить скилл writing-comments?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл writing-comments запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic