# CC hook for comments

> Source: <https://gist.github.com/mariusv/689d1b30c57a49a6412703e35ad21096>
> Published: 2026-08-18 20:47:23+00:00

`comment-cop.py`

enforces a why-only comment policy for Claude Code and Codex.

It blocks newly added change-history comments, obvious code narration, comment blocks longer than two lines, and comment-heavy changes. Directives, short TODOs, generated-code notices, and commented configuration are ignored. A per-turn Git baseline keeps the final audit from blaming an agent for pre-existing worktree changes.

Install the script at `~/.claude/hooks/comment-cop.py`

, merge `claude-settings.json`

into `~/.claude/settings.json`

, and install `codex-hooks.json`

as `~/.codex/hooks.json`

. Add `AGENTS.md`

to `~/.codex/AGENTS.md`

so Codex sees the preference before it edits.

Run `python3 ~/.claude/hooks/comment-cop.py --self-test`

to test the checker. Codex requires new or changed command hooks to be reviewed with `/hooks`

before they run.
