Skip to content

posttooluse-shadcn-font-fix.mjs emits top-level additionalContext; Claude Code rejects it #48

@lucianfialho

Description

@lucianfialho

Summary

hooks/posttooluse-shadcn-font-fix.mjs emits { "additionalContext": "..." } at the top level of its JSON output on the Claude Code branch. Claude Code logs the following on every Bash tool call while the plugin is active:

PostToolUse:Bash hook error
JSON validation failed: Hook JSON output validation failed

The commit/run proceeds (non-blocking error), but the noise fires on every Bash invocation because the hook is wired to PreToolUse:Bash with no if matcher filter. Users see two instances of this error per commit during normal workflows.

Root cause

Lines 155–159 of hooks/posttooluse-shadcn-font-fix.mjs (v0.32.5):

const result = platform === "cursor"
  ? { additional_context: message }
  : { additionalContext: message };

console.log(JSON.stringify(result));

The Claude Code branch puts additionalContext at the root of the JSON payload. The Claude Code hook runtime (confirmed against v50.37.3) expects additionalContext to be nested inside hookSpecificOutput for PostToolUse events, matching the same pattern used for PreToolUse. The cursor branch using additional_context at the root is correct for Cursor, but the Claude Code branch is malformed.

Evidence that this is an isolated outlier, not a design decision

The same plugin already does this correctly in other PostToolUse hooks. hooks/posttooluse-bash-chain.mjs (lines 283–290):

if (platform === "cursor") {
  return JSON.stringify({ additional_context: additionalContext });
}
const output = {
  hookSpecificOutput: {
    hookEventName: "PostToolUse",
    additionalContext
  }
};

So the correct pattern is already codified in the codebase — posttooluse-shadcn-font-fix.mjs just didn't get updated to use it.

Proposed fix

Replace lines 155–159 of posttooluse-shadcn-font-fix.mjs with the same pattern used by posttooluse-bash-chain.mjs:

const result = platform === "cursor"
  ? { additional_context: message }
  : {
      hookSpecificOutput: {
        hookEventName: "PostToolUse",
        additionalContext: message
      }
    };

console.log(JSON.stringify(result));

Worth auditing

The hooks directory contains 5 posttooluse-*.mjs files. Grepping hookSpecificOutput shows it appears in posttooluse-bash-chain.mjs and posttooluse-validate.mjs (correct), but not in posttooluse-shadcn-font-fix.mjs, posttooluse-telemetry.mjs, or posttooluse-verification-observe.mjs. Might be worth a one-pass audit to confirm the other two aren't also emitting top-level additionalContext.

Environment

  • Plugin version: 0.32.5
  • Marketplace: claude-plugins-official
  • Claude Code CLI: 50.37.3
  • OS: macOS Darwin 25.3.0
  • Reproduction: install the plugin and run any Bash(...) tool call in a session; the PostToolUse:Bash hook error — JSON validation failed line is logged each time.

Notes

Discovered while building a state-machine enforcement plugin (lucianfialho/atomic-gates) and debugging hook interactions. The error doesn't affect correctness of either plugin — the shadcn-font-fix still detects and patches the shadcn-init-broken CSS in globals.css, and my own hooks run unaffected — but the validation error is noisy enough that it was the first thing I noticed when running smoke tests in a live session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions