write-code-comments

write-code-comments is a skill for Claude Code from MH4GF/claude-code. It costs 59 tokens per session (753 once invoked), scanned A, original, MIT.

A procedure for adding comments to code when a project hook normally blocks comment changes. It requires a temporary permission marker, limits comments to useful explanations, and removes the marker afterward.

In plain words
What is it for?
Use it when documenting non-obvious design choices, constraints, warnings, or the purpose of complex code.
Why use it?
It prevents unnecessary or low-quality comments while still allowing explicitly requested comments to pass the project's checks.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Good fit Use it when documenting non-obvious design choices, constraints, warnings, or the purpose of complex code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mh4gf/claude-code/write-code-comments
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add MH4GF/claude-code --skill write-code-comments
Clone the repo
git clone --depth 1 https://github.com/MH4GF/claude-code

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for write-code-comments

README.md
[![agentmods](https://agentmods.dev/badge/skills/mh4gf/claude-code/write-code-comments/github.svg)](https://agentmods.dev/skills/mh4gf/claude-code/write-code-comments)
Your own site
<a href="https://agentmods.dev/skills/mh4gf/claude-code/write-code-comments"><img src="https://agentmods.dev/badge/skills/mh4gf/claude-code/write-code-comments/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for write-code-comments

Your own site · 80×15
<a href="https://agentmods.dev/skills/mh4gf/claude-code/write-code-comments"><img src="https://agentmods.dev/badge/skills/mh4gf/claude-code/write-code-comments.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 753 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00059 $0.00753
Opus 5.5 $0.00024 $0.00301
Sonnet 5.5 $0.00012 $0.00151
Haiku 4.5 $0.00006 $0.00075

Measured 2mo ago against content hash 35ab12486986, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

write-code-comments scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

user-scope-backup-2026-07-04/skills/write-code-comments/SKILL.md · 57 lines

What it actually says

ユーザー指示に従いコードコメントを記述する。comment-guard hook はマーカーファイルが存在する間だけコメント付き編集を許可するため、下記の手順を厳守する。

手順

1. マーカーを作成

最初に、空のマーカーファイルを Write ツールで作成する(カレントディレクトリ基準):

.claude/tmp/.comment-guard-allow

これが無いとコメント付き編集は hook にブロックされる。

2. コメントを記述

$ARGUMENTS の指示に従いコメントを書く。コメントは自己説明的なコードを補助するものであり、悪いコードの言い訳にしない。過度なコメントは可読性を下げるため、必要な箇所に絞る。

鮮度内 (30 分以内) のマーカー下で新規コメントを書くと、コメント本文だけが unslop で lint される。AI 文章クセ (例: 助詞二重・冗長な「することが可能」・prh 用語マッピング違反) を含むと hook が deny する。指摘が返ったらコメント本文を直してから再実行する。

書くべきコメント:

  • なぜそう実装したか — 非自明な判断や理由付け
  • コードを読んでも即座には分からない知見・前提・制約
  • 複雑な箇所や落とし穴への警告
  • 複数の実装案がある中で、その方法を選んだ設計判断の根拠
  • モジュール・クラス・関数冒頭の、目的と全体動作の高レベルな概要

書くべきでないコメント:

  • コードの動作をそのまま言い換える冗長なコメント
  • 読めば分かる当たり前の説明
  • タスク文脈・レビュー経緯・変更の経緯 — これらは git のコミットメッセージに書く
  • 維持できず実態と食い違う恐れのある記述(古いコメントは誤解を招く)

その他:

  • 指示された箇所以外にはコメントを足さない
  • 既存コメントの体裁・言語(日本語/英語)に合わせる
  • TODO は慎重に。残すなら具体的な内容を書く

3. マーカーを削除

作業が完了または中断したら、次のコマンドでマーカーを必ず削除する。

rm -f .claude/tmp/.comment-guard-allow

削除を忘れても 30 分で hook 側が失効扱いにするが、漏れを防ぐため明示的に削除すること。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 57 lines · 59 tokens per session scan A 35ab12486986

Subscribe to this mod's changes

write-code-comments is a skill published in the GitHub repository MH4GF/claude-code (2 stars, last pushed 5d ago), licensed MIT. It adds 59 tokens to every session and 753 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

local-ai-agents

Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…

microsoft/ai-agents-for-beginners · 200 tokens

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

insight-error-page

Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…

vercel/next.js · 83 tokens