Skip to content

Commit 6c99832

Browse files
authored
feat: add new hook types for tool error and session events in Claude Code settings (SchemaStore#4937)
* feat: add new hook types for tool error and session events in Claude Code settings * feat: add tests for Claude Code settings hooks ToolError, SessionStart, and SessionEnd * refactor: reorganize claude code hook commands for prettier formatting standard
1 parent 87fde51 commit 6c99832

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

src/schemas/json/claude-code-settings.json

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,42 @@
152152
"PreToolUse": {
153153
"type": "array",
154154
"description": "Hooks that run before tool calls",
155-
"items": {
156-
"$ref": "#/$defs/hookMatcher"
157-
}
155+
"items": { "$ref": "#/$defs/hookMatcher" }
158156
},
159157
"PostToolUse": {
160158
"type": "array",
161159
"description": "Hooks that run after tool completion",
162-
"items": {
163-
"$ref": "#/$defs/hookMatcher"
164-
}
160+
"items": { "$ref": "#/$defs/hookMatcher" }
165161
},
166162
"Notification": {
167163
"type": "array",
168164
"description": "Hooks that trigger on notifications",
169-
"items": {
170-
"$ref": "#/$defs/hookMatcher"
171-
}
165+
"items": { "$ref": "#/$defs/hookMatcher" }
172166
},
173167
"Stop": {
174168
"type": "array",
175169
"description": "Hooks that run when agents finish responding",
176-
"items": {
177-
"$ref": "#/$defs/hookMatcher"
178-
}
170+
"items": { "$ref": "#/$defs/hookMatcher" }
179171
},
180172
"SubagentStop": {
181173
"type": "array",
182174
"description": "Hooks that run when subagents finish responding",
183-
"items": {
184-
"$ref": "#/$defs/hookMatcher"
185-
}
175+
"items": { "$ref": "#/$defs/hookMatcher" }
176+
},
177+
"ToolError": {
178+
"type": "array",
179+
"description": "Hooks that run when a tool call fails",
180+
"items": { "$ref": "#/$defs/hookMatcher" }
181+
},
182+
"SessionStart": {
183+
"type": "array",
184+
"description": "Hooks that run when a new session starts",
185+
"items": { "$ref": "#/$defs/hookMatcher" }
186+
},
187+
"SessionEnd": {
188+
"type": "array",
189+
"description": "Hooks that run when a session ends",
190+
"items": { "$ref": "#/$defs/hookMatcher" }
186191
}
187192
}
188193
},

src/test/claude-code-settings/hooks-complete.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@
4242
"matcher": "Bash"
4343
}
4444
],
45+
"SessionEnd": [
46+
{
47+
"hooks": [
48+
{
49+
"command": "echo 'Session ended' >> /tmp/claude-session.log",
50+
"type": "command"
51+
}
52+
]
53+
}
54+
],
55+
"SessionStart": [
56+
{
57+
"hooks": [
58+
{
59+
"command": "echo 'Session started' >> /tmp/claude-session.log",
60+
"type": "command"
61+
}
62+
]
63+
}
64+
],
4565
"Stop": [
4666
{
4767
"hooks": [
@@ -63,6 +83,16 @@
6383
],
6484
"matcher": "Agent"
6585
}
86+
],
87+
"ToolError": [
88+
{
89+
"hooks": [
90+
{
91+
"command": "echo 'Tool error occurred' >> /tmp/claude-error.log",
92+
"type": "command"
93+
}
94+
]
95+
}
6696
]
6797
}
6898
}

0 commit comments

Comments
 (0)