Repository navigation
Description
Summary
docs/conventions/hook-observability/README.md gained a third sanctioned systemMessage situation:
a hook that rewrote the user's file content without being asked must name what it changed on the
user channel, bounded by a per-run cap. Its Conformance list now carries:
Every path on which the hook rewrote file content names what it changed on the user channel,
bounded by a per-run cap with the remainder reported as a count.
Two plugins conform: typos-format (#1578) and markdown-format (#1589). Every other autofix hook in
the fleet rewrites file content on Write/Edit and reports nothing about it, so the clause landed
with a set of silently non-conformant siblings and nothing tracking them. This issue is that tracker.
Why the clause exists
The harness's only signal for a hook-applied rewrite is a generic "PostToolUse hook modified <file>
after your edit (likely a formatter)" line — no hook name, no diff — and the hooks reference
(https://code.claude.com/docs/en/hooks) documents no file-change channel a hook could use instead.
So a benign reflow and a wrong rewrite arrive identically. typos-format is where that became a real
harm: a dictionary autocorrect rewrote domain terms into unrelated English words across several files
in one session, and no channel ever named the hook.
Candidates to walk
Each of these applies an autofix on Write/Edit:
eol-normalizer— rewrites line endings, and is extension-unscoped liketypos-formatwas.ruff-formatbash-formatgo-formatpowershell-formatbiome-format
What the walk should decide per plugin
The clause is about content the user did not request, and the cost of over-applying it is real: a
systemMessage on every edit that touched trailing whitespace is noise, and the convention already
names over-application a conformance defect. So the per-plugin question is not "add a message" but:
- Does the tool report what it changed, or only that it changed something? Report what there is,
and say so when that is only a count —markdown-formatreportsAttempted: N fixesbecause that
is genuinely allmarkdownlint-cli2offers. - Can a rewrite change meaning rather than only layout? A dictionary word substitution can; a
trailing-whitespace strip cannot. That difference should drive how loud the disclosure is, and if
the answer is "layout only", record that as the reason rather than leaving it implicit. - Is there a no-op path where nothing was written? It must stay silent.
- Is the per-run list capped with the remainder as a count?
An outcome of "this hook's rewrites are purely structural and the agent channel is sufficient" is a
legitimate result — but it should be written down in the plugin and reflected back into the
convention, not left as an unexplained gap.
Related
The two conforming implementations are the reference: plugins/typos-format/hooks/typos-format.sh
(names each rewritten token, its replacement, and its line, capped at ten with the remainder as a
count) and plugins/markdown-format/hooks/markdown-format.sh (reports the fix count, and says
explicitly that a count is all the tool provides).
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Admission gate:
work-class: scoped, feature-shaped (a multi-plugin design walk deciding disclosure treatment per hook, not a like-for-like bug fix) → human-gated per the work-loop lane's admission table (C3 feature-shaped is operator-tightened to human-gated). Routed to human-gated; not dispatched.kyle-sexton commentedon Jul 26, 2026
The clause this issue tracks is now live in
docs/conventions/hook-observability/README.md, landed with #1580, and both reference implementations are merged:plugins/typos-format/hooks/typos-format.sh(fix(typos-format): disclose every applied correction on both channels #1580) — names each rewritten token, its replacement and its line, elided at 60 characters, capped at ten entries with the remainder as a count, and bounded again by a character ceiling against the channel's documented 10,000-character cap.plugins/markdown-format/hooks/markdown-format.sh(fix(markdown-format): bound lint emission and disclose applied fixes #1591) — reports the fix count and says explicitly that a count is allmarkdownlint-cli2offers.Two things learned building those, worth having before the next adopter starts:
markdownlint-cli2reports no per-fix detail, somarkdown-formatreports a count and states that limitation rather than implying more. An honest thin disclosure beats an inferred rich one.The six candidates in the list above are unchanged, and the per-plugin question stays the one this issue already frames: not "add a message" but "can this rewrite change meaning, or only layout" — and if the answer is layout-only, write that down as the reason rather than leaving the gap unexplained.
kyle-sexton commentedon Jul 30, 2026
This issue's premise needs a correction:
markdown-formatdoes not conform to the disclosure clause. An independent agent audit of 0.8.4 found its disclosure path is unreachable in practice, so the conformance list here is carrying a false green.The disclosure never fires
markdown-format.sh:705-712scans the linter's stdout for a line beginningAttempted::The installed
markdownlint-cli2is v0.18.1, and that string does not appear anywhere in the package — not in source, README, or its 46-version changelog. Observed stdout of a real--fixrun that did rewrite the file:So
FIXES_LINEstays empty,SYSMSGis never set, and after a successful--fixthe residual finding count is often zero, leavingCTXempty too.hook::emit_channelsreturns early when both channels are empty — so the hook emits nothing at all on a run that rewrote the user's file. Reproduced three times, including by direct hook invocation.What the user actually saw was Claude Code's own generic
PostToolUse hook modified <path> after your edit (likely a formatter)line. That comes from the harness, not from this plugin.Consequences for the conformance claim:
README.md:14-18states "the count of fixes written is reported to Claude and to you — a run that changed your file never passes unannounced." False as shipped.CHANGELOG.md:146-151states this was fixed and namesAttempted: N fixes in 1 fileas the count "markdownlint-cli2 reports". It does not report it.Why it is a version-dependency defect, not a fictional contract
Upstream check, so the report is accurate:
markdownlint-cli20.23.1 added "Show attempted fix counts after fixing", confirmed present in current source at 0.23.2, emitted viapluralizeand only when the count exceeds zero. So the parse targets a real contract — one that exists only in cli2 ≥ 0.23.1.The plugin resolves cli2 from
PATHand ships no version pin or check. So whether a consumer gets rewrite disclosure is decided by their local install, and the failure mode is silent. That is a more durable defect than a parse bug, and it means conformance here cannot be established by reading the code alone — it depends on the consumer's environment.Two details for whoever fixes it: the hook's
"Attempted: 0 fixes"*branch is unreachable even upstream, because the line only prints when the count is non-zero; andAttempted: N fix(es) in M file(s)is a paraphrase of thepluralizecall rather than the literal output.Suggested fix, which moots the version dependency entirely
Stop parsing the linter's stdout. Hash the file before and after the
--fixcall and report on difference. The hook already usesgit hash-objectfor its finding-digest gate (markdown-format.sh:766), so this needs no new dependency, is immune to the linter's output contract and version, and is what would make the README's existing claim true.Add at least one assertion driven by the real binary. The current test suite stubs
markdownlint-cli2with a script that emits the missing line (markdown-format.test.sh:1480, asserted at 1764 and 1769, with a comment at 1454 describingAttempted: N fixesas "the … line markdownlint-cli2 [emits]"). So the stub encodes a newer version's output contract than the binary the hook runs against, and the suite passes green while the shipped behaviour is silent. That is why this shipped.Related, and the reason this matters beyond disclosure
The same audit found the hook rewrites content outside any repository, because the git-working-tree scope guard sits inside
if [[ -z "${CLAUDE_PROJECT_DIR:-}" ]](lines 100-108) — the branch that does not execute under Claude Code. Proven by A/B with identical payloads on a file in a non-git directory: with the variable unset the file was unchanged; with it set to the session root the file was rewritten, and the hook said nothing.Two content mutations were observed under built-in defaults, in files under
~/.claude/plugins/data/:ul-style, defaultconsistent, fixable) normalised a quoted changelog line's leading plus sign to a hyphen, falsifying a quotation.no-missing-space-atx, fixable) inserted a space into a line-leading issue reference, turning#1426into# 1426— destroying the reference and fabricating a top-level heading, which the hook then reported as MD025 and MD022. It generated two findings by applying a third.Both are the same class: an auto-fixable style rule mutating prose whose first character is markup-significant. A hook cannot distinguish a literal plus or hash in prose from a marker, because at the CommonMark level there is no distinction to make — which is exactly why the opt-in and the disclosure are the load-bearing controls rather than smarter detection. That makes this issue's clause the right lever, and makes the false green here the thing worth fixing first.
Note MD018's trigger is the commonest prose shape in this tracker: a line beginning with an issue number. Anyone drafting issue prose through a tool this hook touches is exposed.
Cheapest fix for the scope half
Adopt this author's own doctrine from the same marketplace:
bash-formatrefuses to run when the repo has no shfmt config, "so the plugin never imposes a style you did not [choose]" (bash-format/0.5.0/README.md:21). Applying that here — no discoverable markdownlint config means report-and-skip, never--fix— closes the quote falsification, the MD018 reference destruction, the unreachable-advice problem, and ~115 unactionable MD013 findings in one change, using machinerycollect_risky_configsalready has.feat(ruff-format): disclose Ruff rewrites on the user channel
feat(powershell-format): disclose formatter rewrites on the user channel
kyle-sexton commentedon Aug 12, 2026
Drain: tracked by open PR #2477 feat(powershell-format): disclose formatter rewrites on the user channel (no duplicate opened).
feat(eol-normalizer): disclose line-ending rewrites on the user channel
feat(bash-format): disclose shfmt rewrites on the user channel
feat(ruff-format): disclose Ruff rewrites on the user channel
feat(go-format): disclose goimports rewrites on the user channel
feat(biome-format): disclose Biome rewrites on the user channel
feat(powershell-format): disclose formatter rewrites on the user channel
13 remaining items
feat(biome-format): disclose Biome rewrites on the user channel
feat(biome-format): disclose Biome rewrites on the user channel (#2474)
feat(eol-normalizer): disclose line-ending rewrites on the user channel
feat(bash-format): disclose shfmt rewrites on the user channel
feat(powershell-format): disclose formatter rewrites on the user channel
feat(bash-format): disclose shfmt rewrites on the user channel (#2471)
feat(powershell-format): disclose formatter rewrites on the user channel
feat(eol-normalizer): disclose line-ending rewrites on the user channel
feat(powershell-format): disclose formatter rewrites on the user chan…
feat(eol-normalizer): disclose line-ending rewrites on the user chann…
kyle-sexton commentedon Aug 12, 2026
Frontier disposition (drain session)
Ruling: promoted to agent-ready. The convention is already codified in docs/conventions/hook-observability (the third sanctioned systemMessage situation with a per-run cap), two plugins already conform as reference implementations, and the remaining work is mechanical adoption across the enumerated autofix hooks. No open design question remains for a human.