$npx -y skills add parcadei/Continuous-Claude-v3 --skill hook-developerComplete Claude Code hooks reference - input/output schemas, registration, testing patterns
| 1 | # Hook Developer |
| 2 | |
| 3 | Complete reference for developing Claude Code hooks. Use this to write hooks with correct input/output schemas. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Creating a new hook |
| 8 | - Debugging hook input/output format |
| 9 | - Understanding what fields are available |
| 10 | - Setting up hook registration in settings.json |
| 11 | - Learning what hooks can block vs inject context |
| 12 | |
| 13 | ## Quick Reference |
| 14 | |
| 15 | | Hook | Fires When | Can Block? | Primary Use | |
| 16 | |------|-----------|------------|-------------| |
| 17 | | **PreToolUse** | Before tool executes | YES | Block/modify tool calls | |
| 18 | | **PostToolUse** | After tool completes | Partial | React to tool results | |
| 19 | | **UserPromptSubmit** | User sends prompt | YES | Validate/inject context | |
| 20 | | **PermissionRequest** | Permission dialog shows | YES | Auto-approve/deny | |
| 21 | | **SessionStart** | Session begins | NO | Load context, set env vars | |
| 22 | | **SessionEnd** | Session ends | NO | Cleanup/save state | |
| 23 | | **Stop** | Agent finishes | YES | Force continuation | |
| 24 | | **SubagentStart** | Subagent spawns | NO | Pattern coordination | |
| 25 | | **SubagentStop** | Subagent finishes | YES | Force continuation | |
| 26 | | **PreCompact** | Before compaction | NO | Save state | |
| 27 | | **Notification** | Notification sent | NO | Custom alerts | |
| 28 | |
| 29 | **Hook type options:** `type: "command"` (bash) or `type: "prompt"` (LLM evaluation) |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Hook Input/Output Schemas |
| 34 | |
| 35 | ### PreToolUse |
| 36 | |
| 37 | **Purpose:** Block or modify tool execution before it happens. |
| 38 | |
| 39 | **Input:** |
| 40 | ```json |
| 41 | { |
| 42 | "session_id": "string", |
| 43 | "transcript_path": "string", |
| 44 | "cwd": "string", |
| 45 | "permission_mode": "default|plan|acceptEdits|bypassPermissions", |
| 46 | "hook_event_name": "PreToolUse", |
| 47 | "tool_name": "string", |
| 48 | "tool_input": { |
| 49 | "file_path": "string", |
| 50 | "command": "string" |
| 51 | }, |
| 52 | "tool_use_id": "string" |
| 53 | } |
| 54 | ``` |
| 55 | |
| 56 | **Output (JSON):** |
| 57 | ```json |
| 58 | { |
| 59 | "hookSpecificOutput": { |
| 60 | "hookEventName": "PreToolUse", |
| 61 | "permissionDecision": "allow|deny|ask", |
| 62 | "permissionDecisionReason": "string", |
| 63 | "updatedInput": {} |
| 64 | }, |
| 65 | "continue": true, |
| 66 | "stopReason": "string", |
| 67 | "systemMessage": "string", |
| 68 | "suppressOutput": true |
| 69 | } |
| 70 | ``` |
| 71 | |
| 72 | **Exit code 2:** Blocks tool, stderr shown to Claude. |
| 73 | |
| 74 | **Common matchers:** `Bash`, `Edit|Write`, `Read`, `Task`, `mcp__.*` |
| 75 | |
| 76 | --- |
| 77 | |
| 78 | ### PostToolUse |
| 79 | |
| 80 | **Purpose:** React to tool execution results, provide feedback to Claude. |
| 81 | |
| 82 | **Input:** |
| 83 | ```json |
| 84 | { |
| 85 | "session_id": "string", |
| 86 | "transcript_path": "string", |
| 87 | "cwd": "string", |
| 88 | "permission_mode": "string", |
| 89 | "hook_event_name": "PostToolUse", |
| 90 | "tool_name": "string", |
| 91 | "tool_input": {}, |
| 92 | "tool_response": { |
| 93 | "filePath": "string", |
| 94 | "success": true, |
| 95 | "output": "string", |
| 96 | "exitCode": 0 |
| 97 | }, |
| 98 | "tool_use_id": "string" |
| 99 | } |
| 100 | ``` |
| 101 | |
| 102 | **CRITICAL:** The response field is `tool_response`, NOT `tool_result`. |
| 103 | |
| 104 | **Output (JSON):** |
| 105 | ```json |
| 106 | { |
| 107 | "decision": "block", |
| 108 | "reason": "string", |
| 109 | "hookSpecificOutput": { |
| 110 | "hookEventName": "PostToolUse", |
| 111 | "additionalContext": "string" |
| 112 | }, |
| 113 | "continue": true, |
| 114 | "stopReason": "string", |
| 115 | "suppressOutput": true |
| 116 | } |
| 117 | ``` |
| 118 | |
| 119 | **Blocking:** `"decision": "block"` with `"reason"` prompts Claude to address the issue. |
| 120 | |
| 121 | **Common matchers:** `Edit|Write`, `Bash` |
| 122 | |
| 123 | --- |
| 124 | |
| 125 | ### UserPromptSubmit |
| 126 | |
| 127 | **Purpose:** Validate user prompts, inject context before Claude processes. |
| 128 | |
| 129 | **Input:** |
| 130 | ```json |
| 131 | { |
| 132 | "session_id": "string", |
| 133 | "transcript_path": "string", |
| 134 | "cwd": "string", |
| 135 | "permission_mode": "string", |
| 136 | "hook_event_name": "UserPromptSubmit", |
| 137 | "prompt": "string" |
| 138 | } |
| 139 | ``` |
| 140 | |
| 141 | **Output (Plain text):** |
| 142 | ``` |
| 143 | Any stdout text is added to context for Claude. |
| 144 | ``` |
| 145 | |
| 146 | **Output (JSON):** |
| 147 | ```json |
| 148 | { |
| 149 | "decision": "block", |
| 150 | "reason": "string", |
| 151 | "hookSpecificOutput": { |
| 152 | "hookEventName": "UserPromptSubmit", |
| 153 | "additionalContext": "string" |
| 154 | } |
| 155 | } |
| 156 | ``` |
| 157 | |
| 158 | **Blocking:** `"decision": "block"` erases prompt, shows `"reason"` to user only (not Claude). |
| 159 | |
| 160 | **Exit code 2:** Blocks prompt, shows stderr to user only. |
| 161 | |
| 162 | --- |
| 163 | |
| 164 | ### PermissionRequest |
| 165 | |
| 166 | **Purpose:** Automate permission dialog decisions. |
| 167 | |
| 168 | **Input:** |
| 169 | ```json |
| 170 | { |
| 171 | "session_id": "string", |
| 172 | "transcript_path": "string", |
| 173 | "cwd": "string", |
| 174 | "permission_mode": "string", |
| 175 | "hook_event_name": "PermissionRequest", |
| 176 | "tool_name": "string", |
| 177 | "tool_input": {} |
| 178 | } |
| 179 | ``` |
| 180 | |
| 181 | **Output:** |
| 182 | ```json |
| 183 | { |
| 184 | "hookSpecificOutput": { |
| 185 | "hookEventName": "PermissionRequest", |
| 186 | "decision": { |
| 187 | "behavior": "allow|deny", |
| 188 | "updatedInput": {}, |
| 189 | "message": "string", |
| 190 | "interrupt": false |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | ``` |
| 195 | |
| 196 | --- |
| 197 | |
| 198 | ### SessionStart |
| 199 | |
| 200 | **Purpose:** Initialize session, load context, set environment variables. |
| 201 | |
| 202 | **Input:** |
| 203 | ```json |
| 204 | { |
| 205 | "session_id": "string", |
| 206 | "transcript_path": "string", |
| 207 | "cwd": "string", |
| 208 | "permission_mode": "string", |
| 209 | "hook_event_name": "SessionStart", |
| 210 | "source": "startup|resume|clear|compact" |
| 211 | } |
| 212 | ``` |
| 213 | |
| 214 | **Environment variable:** `CLAUDE_ENV_FILE` - write `export VAR=value` to persist env vars. |
| 215 | |
| 216 | **Output (Plain text or JSON):** |
| 217 | ```json |
| 218 | { |
| 219 | "hookSpecificOutput": { |
| 220 | "hookEventName": "SessionStar |