Skip to content

fix(hook-development): recognize all five hook handler types#75537

Open
fcarvajalbrown wants to merge 1 commit into
anthropics:mainfrom
fcarvajalbrown:fix/hook-development-five-hook-types
Open

fix(hook-development): recognize all five hook handler types#75537
fcarvajalbrown wants to merge 1 commit into
anthropics:mainfrom
fcarvajalbrown:fix/hook-development-five-hook-types

Conversation

@fcarvajalbrown

Copy link
Copy Markdown

Problem

The plugin-dev hook-development skill teaches plugin authors how to write hooks.json, but it only knew two of the five hook handler types Claude Code actually supports. Both the docs and the bundled validator had drifted from the product:

  • scripts/validate-hook-schema.sh accepted only command and prompt, and reported http, mcp_tool, and agent hooks as errors — even though all three are valid, documented types. So the tool failed valid configs it was meant to certify.
  • SKILL.md's "Hook Types" section documented only 2 of the 5 types (the root cause of the drift).
  • The event allowlist in the validator was missing many valid events.

Verified against the official docs (https://code.claude.com/docs/en/hooks): the five handler types are command, prompt, http, mcp_tool, and agent.

Changes

  • scripts/validate-hook-schema.sh
    • Accept all five handler types instead of erroring on http/mcp_tool/agent.
    • Add per-type required-field validation matching the documented schemas: http -> url, mcp_tool -> server + tool, agent -> prompt.
    • Expand the event allowlist from 9 to the full documented set (adds FileChanged, PostCompact, PermissionRequest, etc.) so valid events are no longer flagged as unknown.
  • SKILL.md — add a five-type overview table plus dedicated subsections for HTTP, MCP-tool, and Agent hooks with required/optional fields and examples.
  • scripts/README.md — list all five types instead of command/prompt.

Testing

Ran the validator against fixtures built from the official docs:

Case Before After
Valid http/mcp_tool/agent config rejected (Invalid type 'http', exit 1) passes, exit 0
http hook missing url (never reached) errors
mcp_tool missing tool (never reached) errors
Genuinely invalid type (webhook) errors errors
Config using FileChanged event "unknown event" warning no warning
Original command/prompt config passes passes (no regression)

The hook-development skill only knew two of the five hook handler
types that Claude Code supports. Both the teaching docs and the
bundled validator were stale, so the validator rejected valid
configs as errors.

- validate-hook-schema.sh: accept command, prompt, http, mcp_tool,
  and agent (previously errored on the last three); add per-type
  required-field checks (http->url, mcp_tool->server+tool,
  agent->prompt); expand the event allowlist to the full documented
  set so events like FileChanged/PostCompact are no longer flagged.
- SKILL.md: document all five types with required/optional fields
  and examples (this omission was the root cause of the drift).
- scripts/README.md: list all five types instead of command/prompt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant