Code Comment logo

Code Comment

Community
shokai
code-comment

ソースコード中のコメントを書く時の心得。コメントに何を書き、何を書かないかの判断基準と、置く位置、日本語の文体を定める。 ソースコードのコメントを書く時、直す時、レビューする時に読み込む。

Overview

Publishershokai
Repositoryagent-skills
Skill namecode-comment
Stars
88
Forks
5
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by shokai on GitHub. Read the source before you install it.

Installation

Install the Code Comment AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/shokai/agent-skills/tree/main/plugins/kuden/skills/code-comment
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/shokai/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/plugins/kuden/skills/code-comment .claude/skills/code-comment
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Code Comment in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Code Comment on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Code Comment is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

ソースコード中のコメントを書く時の心得

ソースコードのコメントを書く時、直す時、レビューする時は、以下の基準に従う。

心得1. コードから読めない事だけを書く

コメントに書いてよいのは、コードを読んでも分からない事だけである。非自明な制約、invariant、隠れ仕様、gotcha、特定のbugへのworkaroundがこれに当たる。なぜそうするかという意図も書いてよい。

コードや配置から読み取れる事を、言葉でなぞらない。配置とは、ファイルの位置、関数名、周辺のコードの事である。自明な説明は実装との二重管理になり、コードを変更した時の更新漏れの原因になる。読み手には、コードと違う事を言っているかもしれないと疑う負担をかける。

  • 直下の処理を言い直さない。text.replaceAll('\0', '') の直上に // NULを弾く と書かない
  • 配置が既に表している前置きを書かない。特定の機能専用のディレクトリにある定数に「この機能専用の上限」と書かない。その場所に他の機能の上限があるはずがない
  • 意図を書く前に、その動機がコードの式から読めないか確かめる。読めるなら書かない。書き残すなら、commit messageかPR概要欄に置く。メールの件名に (test ...) を付けるコードは、その式だけで、test送信を区別する意図が読める

書いてよいコメントの例を挙げる。

  • // TextDecoderが既定でBOMを除去する
  • // 上流APIの制約で、書き込みはPAT認証のみ
  • // .trim()ではなく末尾改行のみ除去する。先頭空白は保持したい

心得2. 意図の説明に見えても、書かない物がある

  • defaultの帰結に、理由を書かない。理由が要るのは、defaultから逸脱した時だけである。APIレスポンス等の元データに無いfieldを持たせないのは当然の帰結で、理由は要らない。元データに無いfieldをあえて合成して持たせる時に、理由を書く
  • 経緯や履歴を書かない。「これはbugだった」「Aを試したがBにした」は、commit messageやPR概要欄に書く。コードは最終形態だけを表す

心得3. mergeされた後に、そのファイルだけを読む人に向けて書く

コード内のコメントの読者は、pull requestのレビュアーだけでなく、merge後の未来のコントリビューターも含まれる。「従来は」「今までは」のように相対的な時点を参照すると、mergeされた後に基準の時点が失われ、意味を持たなくなる。「matchする文字列は変わらない」のように、比べる相手がmerge後のコードに存在しなくなる文も同じで、何を指すのか後から意味不明になる。「〜のまま」「〜なくなった」「〜ようになった」にも、変更前との比較が隠れている事がある。コメントは現在のコードの意図だけを述べる。pull requestのレビュアーだけに向けた説明には、GitHubのコメント機能を使う。

  • 変更前との比較を、今のコードの性質として言い直す。「matchする文字列は変わらない」ではなく「matchする文字列は狭めない」と書く。testのコメントも同じで、「先読みが外れると」ではなく「先読みが無いと」と書く
  • 仕組みの説明より、読む人が検索できるテクニカルタームと、守るべき制約を書く。// 先読みはReDoS対策。後ろのpatternを変える時は先読みも合わせる のように書く
  • 書き終えたら、PR概要欄やcommit messageを見ずに、そのファイルだけを開いた人として読み直す

心得4. 公開されるコードに、非公開の実装を書かない

公開されるrepositoryやpackageのコメントに、非公開のコードの実装の機構を書かない。file path、関数名、middleware名がこれに当たる。

外から観測できる仕様を根拠にした理由は、書いてよい。「URLのタイトル部分に生の / が来ると、サーバーが拒否するので、ここで正規化する」は観測できる仕様で、サーバーのどの関数が何をしているかは実装の機構である。

心得5. 削る事を目的にしない

読み手が実装を読む時に要る情報は書く。既存のコメントを点検した結果、大半が正当な意図の説明で、現状維持になる事もある。

  • 日時等の整形関数には、返す文字列の実例を書く。// 2026/09/12 05:03:21 UTCという形式を返す のように書く。整形のオプションの羅列から、出力の形は読み取れない
  • 高階関数の使用例は残してよい。// 使用例: rateLimit({ cost: 1 }).or(fallbackHandler) のように書く。関数の冒頭にvalidationやsetupがあり、返り値が更にchainできる事が定義から分かりにくい時に役立つ
  • 特定のオプション値にまつわるgotchaは、関数の上にまとめず、該当する行の行末に置く

心得6. 日本語のコメントの文体

文体はkuden:writing skillの基準に従う。コメントでは、さらに次の2点を守る。

  • 行コメントの文末に 。 を付けない。複数の文を区切る途中の 。 は残す
  • 折り返さず1行にまとめる

Frequently asked questions

What does the Code Comment AI skill do?

ソースコード中のコメントを書く時の心得。コメントに何を書き、何を書かないかの判断基準と、置く位置、日本語の文体を定める。 ソースコードのコメントを書く時、直す時、レビューする時に読み込む。

Why use Code Comment on TypingMind?

Because you install it once and use it with any model. Code Comment is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Code Comment in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/shokai/agent-skills/tree/main/plugins/kuden/skills/code-comment. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Code Comment?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Code Comment?

As many as you like. As long as a model supports skills, you can use Code Comment with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Code Comment AI skill free?

Yes. It is published on GitHub by shokai under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇