--- 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:20:38.872040+00:00" relations: - target: 62ee21e8-2b56-4d38-a73d-47e2724f08c6 type: BUILDS_ON direction: outgoing strength: 0.78 edge_id: 98dd95aa-3b6e-4b89-aa90-5877eb37e1a2 - target: ba189013-3890-4464-a22d-cdc3d68d8068 type: BUILDS_ON direction: outgoing strength: 0.86 edge_id: 0b72d209-d461-463c-a720-cf8d47ef5fe8 - target: e9e6a15a-bec3-4b62-98c9-4a70a5165348 type: RELATED_TO direction: outgoing strength: 0.81 edge_id: d1f29f3c-3be1-48f8-9ea1-aea48bbacf3a - target: a2d02aea-07fd-4528-8158-f2f42a23a2dd type: RELATED_TO direction: outgoing strength: 0.8 edge_id: ceebc50e-6db0-444e-b31d-36344913dc12 - target: a2d02aea-07fd-4528-8158-f2f42a23a2dd type: SOLVES direction: outgoing strength: 0.95 edge_id: b5623458-9ace-43ae-ae7e-101d465498ee --- # 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