write-code-comments

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 CodeCodex

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.

agentmods
npx agentmods add skills/mh4gf/claude-code/write-code-comments
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, Codex.

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. Scan, not verified.
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 $0.00059 $0.00753
Opus 5 $0.00030 $0.00377
Sonnet 5 $0.00012 $0.00151
Haiku 4.5 $0.00006 $0.00075

Measured yesterday against content hash 35ab12486986, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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. yesterday 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 2d ago), licensed MIT. It adds 59 tokens to every session and 753 once invoked, about $0.0003 per session on Opus 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

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

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 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

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens