feat: one writing contract for Claude Code and Codex

Replaces public-comms.md and code-comments.md (749 words, ~25 rules,
almost all prohibitions, no examples) with a single writing.md that
leads with worked examples.

The rule is selection, not compression: keep output short by cutting
whole ideas that don't change what the reader does next, then write what
survives as plain sentences. Not by dropping articles or writing
fragments, which Anthropic's Fable 5 guide calls out as the wrong lever.
Prompt style leaks into output style, so the file is written in the
voice it asks for.

Drops the BLUF ask-line rule entirely: everyone on a PR already knows
who reviews and who merges, and read literally it produced openers like
"Ask: reviewers please merge".

Links the contract to ~/.agents/AGENTS.md, which Codex had nothing in at
all, and to the nix module for the NixOS machine.
This commit is contained in:
naps62
2026-08-01 13:06:38 +00:00
parent 17677c18df
commit a1f95a1161
9 changed files with 197 additions and 101 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
"""PostToolUse nudge for code comments: Write / Edit / MultiEdit.
Lints ONLY the newly-added text against the "Code comments" contract in
~/.claude/code-comments.md, so legacy files are not re-flagged on every touch.
~/.claude/writing.md, so legacy files are not re-flagged on every touch.
Exit 0 = silent. Exit 2 = stderr goes back to Claude as feedback; the edit is
already applied, so this is a revise-it nudge, not a block.
@@ -13,7 +13,7 @@ import os
import re
import sys
MAX_COMMENT_RUN = 5 # past this you are teaching an agent that can already read the repo
MAX_COMMENT_RUN = 3 # contract budget; past this you are teaching, not warning
CODE_EXT = {
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".rs", ".go", ".sol",
@@ -157,7 +157,7 @@ def main():
name = os.path.basename(path)
if problems:
lines = [f"Comment contract (~/.claude/code-comments.md) — {name}:", ""]
lines = [f"Comment contract (~/.claude/writing.md) — {name}:", ""]
lines += [f" - {p}" for p in problems + notes]
lines += ["", "Trim what you just wrote, or say why it stays."]
print("\n".join(lines), file=sys.stderr)