Skip to content

Hook format validation changed in Claude Code v2.1.71 — verify agentlog compatibility #15

@albireo3754

Description

@albireo3754

Background

Claude Code v2.1.71 tightened validation on ~/.claude/settings.json hook entries.
The matcher field now must be a string (glob/regex pattern or empty string "").

The new documented format is:

{
  "UserPromptSubmit": [
    {
      "matcher": "",
      "hooks": [{ "type": "command", "command": "agentlog hook" }]
    }
  ]
}

Hooks with matcher set to an object (old format used by some tools) now produce validation errors like:

Invalid Settings
~/.claude/settings.json
 └ hooks
   ├ PostToolUse
   │ └ 0
   │   └ matcher: Expected string, but received object
   └ PreToolUse
     ├ 0
     │ └ matcher: Expected string, but received object

Hooks use a new format with matchers. Example:
{"PostToolUse": [{"matcher": {"tools": ["BashTool"]}, ...}]}
Learn more: https://code.claude.com/docs/en/hooks

Agentlog Status

agentlog's HOOK_ENTRY (src/claude-settings.ts) currently registers:

export const HOOK_ENTRY = {
  matcher: "",          // ✅ empty string — likely valid
  hooks: [
    { type: "command", command: "agentlog hook" },
  ],
};

matcher: "" is an empty string, which should satisfy the new validation. However, this needs verification against the latest Claude Code release.

Tasks

  • Confirm matcher: "" is accepted by Claude Code 2.1.71+ (run claude doctor after agentlog init)
  • If invalid, update HOOK_ENTRY to match the new required format
  • Add a agentlog doctor check that validates the registered hook passes Claude Code's built-in settings validation
  • Detect and migrate any stale hook entries registered in old formats (future-proofing)

Reference

/cc Affects agentlog init, agentlog uninstall, and the doctor subcommand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions