Skip to content

Document matcher support for command hooks #3820

@torumakabe

Description

@torumakabe

Describe the feature or problem you'd like to solve

The hooks reference does not clearly document matcher support for flat command hooks.

Proposed solution

This makes it hard to use matcher for common cases like running a postToolUse formatter/linter only after file-edit tools. The Copilot CLI v1.0.63 changelog mentions that PostToolUse matchers are honored, and also mentions preToolUse.matcher, but the reference does not make the supported events or matching semantics clear.

Could the docs clarify:

  • Which hook events support matcher on flat command hook entries
  • Whether this includes preToolUse, postToolUse, and postToolUseFailure
  • For camelCase hooks, whether matcher is matched against runtime toolName
  • Whether matching is case-sensitive and full-match/anchored regex
  • How this differs from PascalCase / Claude-format matchers such as Edit|Write

A small example for an edit-only postToolUse hook would be enough, e.g. whether this is the intended form:

{
  "version": 1,
  "hooks": {
    "postToolUse": [
      {
        "type": "command",
        "matcher": "^(?:edit|create|apply_patch)$",
        "bash": "uv run .github/hooks/scripts/post-edit-quality-feedback.py",
        "powershell": "uv run .github/hooks/scripts/post-edit-quality-feedback.py",
        "timeoutSec": 60
      }
    ]
  }
}

It would also help to point to the relevant built-in runtime tool names and argument shapes used by hook payloads. The hooks reference includes a runtime-to-Claude tool name table under PascalCase PreToolUse, but it is not obvious whether that table should be used for camelCase hook matchers.

Related issues I found:

This issue is specifically about documenting command hook matcher support and semantics. The feature is useful for reducing unnecessary hook executions and simplifying hook scripts, but it is currently hard to rely on from the docs alone.

Example prompts or workflows

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions