--- id: be0bda86-d893-4f86-97c4-0ca4e1073121 type: fix title: "Fix: Claude Code PostToolUse hook correct JSON format" tags: [sba-scouting, rust, claude-code, hooks, configuration, fix] importance: 0.8 confidence: 0.8 created: "2026-03-02T02:08:35.272129+00:00" updated: "2026-03-02T02:08:35.272129+00:00" --- # Claude Code PostToolUse Hook Correct Format ## Problem Claude Code hooks were not firing because the configuration used incorrect field names and structure. ## Root Cause - Used `PostToolCall` instead of `PostToolUse` - Used `matcher` as an object with `tool_name`/`file_glob` fields instead of a plain regex string - File glob filtering is NOT supported in the matcher field — must be done in the shell command itself ## Solution The correct format for `.claude/settings.json`: ```json { "hooks": { "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "if echo \"$TOOL_INPUT\" | grep -q '\\.rs'; then cargo check --message-format=short 2>&1 | grep '^src/' | head -20; fi" } ] } ] } } ``` ## Key Rules - Event key: `PostToolUse` (not `PostToolCall`) - `matcher`: plain regex string matching tool names - `hooks`: array of objects with `type: "command"` and `command` string - File filtering: must be done inside the shell command using `$TOOL_INPUT` env var