@qoder-ai/qodercli 1.1.90 → 1.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,595 @@
1
+ ---
2
+ name: hook-config
3
+ description:
4
+ Guide for creating and configuring hooks. Use when users want to add
5
+ automated behaviors triggered by tool execution, session lifecycle,
6
+ or other events in the CLI hook system.
7
+ allowed-tools: Edit, Write
8
+ ---
9
+
10
+ # Creating Hooks for Qoder CLI
11
+
12
+ This skill guides you through creating hooks — automated behaviors that
13
+ trigger on specific events like tool execution, session lifecycle, file
14
+ changes, and notifications. Hooks are configured in settings.json files.
15
+
16
+ ## When to Use Hooks
17
+
18
+ Use hooks when you need:
19
+
20
+ - **Automated side effects** after tool execution (format, lint, test)
21
+ - **Guardrails** before tool execution (block protected files, detect secrets)
22
+ - **Notifications** when events occur (desktop alerts, webhooks)
23
+ - **Validation gates** that block or allow operations based on conditions
24
+ - **Session automation** at start, end, or compaction
25
+
26
+ **When NOT to use hooks:**
27
+
28
+ - One-off tasks (just do them directly)
29
+ - Complex multi-step workflows (use agents or skills instead)
30
+ - Anything that needs user interaction mid-execution
31
+
32
+ ## Configuration Scopes
33
+
34
+ | Scope | File | Use Case |
35
+ | ----------- | ------------------------------------ | -------------------------------- |
36
+ | **Project** | `${QODER_CONFIG_DIR}/settings.json` | Team-shared, version controlled |
37
+ | **Local** | `${QODER_CONFIG_DIR}/settings.local.json` | Personal, not committed |
38
+ | **User** | `~/${QODER_USER_CONFIG_DIR}/settings.json` | Global across all projects |
39
+
40
+ **Choose project** for team guardrails and standards.
41
+ **Choose local** for personal preferences and notifications.
42
+ **Choose user** for global behaviors across all projects.
43
+
44
+ ## Configuration Format
45
+
46
+ ```jsonc
47
+ {
48
+ "hooks": {
49
+ "<EventName>": [
50
+ {
51
+ "matcher": "<regex>",
52
+ "hooks": [
53
+ {
54
+ "type": "command",
55
+ "command": "${QODER_CONFIG_DIR}/hooks/my-hook.sh",
56
+ "name": "my-hook",
57
+ "timeout": 60
58
+ }
59
+ ]
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ```
65
+
66
+ Each event maps to an array of **hook definitions**. Each definition has:
67
+
68
+ | Field | Required | Description |
69
+ | ------------ | -------- | --------------------------------------------------- |
70
+ | `matcher` | No | Regex filter (matches tool name for tool events) |
71
+ | `hooks` | Yes | Array of hook handlers |
72
+ | `sequential` | No | Run hooks in order instead of parallel |
73
+ | `async` | No | Fire-and-forget, don't block the operation |
74
+
75
+ ### Hook Handler Fields
76
+
77
+ | Field | Required | Description |
78
+ | --------------- | ------------ | ----------------------------------------------------- |
79
+ | `type` | Yes | `command`, `http`, `prompt`, or `agent` |
80
+ | `command` | command type | Shell command to execute (or executable path in exec form, see below) |
81
+ | `args` | No | Optional argv array. When set, the hook runs in **exec form** — `command` is invoked directly without a shell. See "Exec form vs Shell form" below |
82
+ | `url` | http type | Webhook URL to POST to |
83
+ | `prompt` | prompt/agent | LLM prompt text |
84
+ | `if` | No | Per-hook condition: `"ToolName(glob)"` or `"ToolName"` |
85
+ | `name` | No | Display name |
86
+ | `timeout` | No | Seconds before timeout |
87
+ | `statusMessage` | No | Text shown in UI during execution |
88
+ | `async` | No | Run in background without blocking |
89
+ | `asyncRewake` | No | Background hook; exit code 2 wakes model |
90
+ | `rewakeMessage` | No | Override system-reminder prefix when asyncRewake hook blocks (exit 2). Only with `asyncRewake`. |
91
+ | `rewakeSummary` | No | One-line summary (default `Stop hook feedback`) shown to user + model when asyncRewake hook blocks. Whitespace collapsed, capped at 300 chars. Only with `asyncRewake`. |
92
+
93
+ > **One-shot headless mode:** when no persistent consumer exists (e.g.
94
+ > `claude -p "fix bug"` with text output), `asyncRewake` hooks
95
+ > transparently degrade to **synchronous** execution. In this mode
96
+ > exit code 2 is treated as `decision: 'deny'` and `rewakeMessage` /
97
+ > `rewakeSummary` are ignored.
98
+ >
99
+ > SDK streaming (`--input-format stream-json`) and remote worker modes
100
+ > **do** support background asyncRewake — the persistent connection
101
+ > provides a consumer for rewake notifications.
102
+
103
+ Example asyncRewake hook with custom rewake text:
104
+
105
+ ```json
106
+ {
107
+ "PreToolUse": [
108
+ {
109
+ "matcher": "Bash",
110
+ "hooks": [
111
+ {
112
+ "type": "command",
113
+ "command": "bash /opt/security/scan.sh",
114
+ "if": "Bash(git commit:*)",
115
+ "asyncRewake": true,
116
+ "rewakeMessage": "[security-scan] background review:",
117
+ "rewakeSummary": "Commit security review found issues",
118
+ "timeout": 300
119
+ }
120
+ ]
121
+ }
122
+ ]
123
+ }
124
+ ```
125
+
126
+ The hook script must `exit 2` (and write its diagnostic to `stderr` /
127
+ `stdout`) to actually wake the model with the configured prefix + summary.
128
+
129
+ ## Hook Events
130
+
131
+ ### Tool Events (matcher = tool name regex)
132
+
133
+ | Event | When |
134
+ | -------------------- | ------------------------------- |
135
+ | `PreToolUse` | Before tool execution |
136
+ | `PostToolUse` | After successful tool execution |
137
+ | `PostToolUseFailure` | After tool execution fails |
138
+ | `PermissionRequest` | Tool requests user permission |
139
+
140
+ ### Session & Agent Lifecycle
141
+
142
+ | Event | When |
143
+ | --------------- | ------------------------------------------------------------- |
144
+ | `SessionStart` | Session initializes |
145
+ | `SessionEnd` | Session tears down |
146
+ | `SubagentStart` | Sub-agent session begins |
147
+ | `SubagentStop` | Sub-agent session ends |
148
+ | `TeammateIdle` | Teammate attempts to become idle |
149
+ | `Stop` | Agent decides to stop |
150
+ | `QueryEnd` | Top-level request reaches its final outcome (notification-only) |
151
+ | `StopFailure` | Agent encounters fatal error and must stop (notification-only) |
152
+ | `PreCompact` | Before context compaction |
153
+ | `PostCompact` | After context compaction |
154
+
155
+ `TeammateIdle` input includes `teammate_name` and `team_name`. Exit code 2
156
+ uses stderr as feedback. A JSON output with `decision: "deny"` or
157
+ `continue: false` also blocks the idle transition; `reason` or `stopReason`
158
+ provides the feedback text. The feedback is sent to the same teammate as a new
159
+ turn. The teammate is marked idle only after a later `TeammateIdle` evaluation
160
+ allows the transition.
161
+
162
+ ### User, Config & Notification Events
163
+
164
+ | Event | When |
165
+ | -------------------- | ------------------------------- |
166
+ | `UserPromptSubmit` | User submits a prompt |
167
+ | `ConfigChange` | Settings change at runtime |
168
+ | `Notification` | External notification arrives |
169
+ | `InstructionsLoaded` | System instructions loaded |
170
+
171
+ ### File & Workspace Events
172
+
173
+ | Event | When |
174
+ | ---------------- | -------------------------- |
175
+ | `CwdChanged` | Working directory changes |
176
+ | `FileChanged` | Watched file changes |
177
+ | `WorktreeCreate` | Git worktree created |
178
+ | `WorktreeRemove` | Git worktree removed |
179
+
180
+ ### Task Events
181
+
182
+ | Event | When |
183
+ | --------------- | ----------------------------- |
184
+ | `TaskCreated` | Background task created |
185
+ | `TaskCompleted` | Background task completes |
186
+
187
+ ## Handler Types
188
+
189
+ ### Command (`type: "command"`)
190
+
191
+ Executes a shell command. Hook input arrives as JSON on **stdin**.
192
+ Output is parsed from **stdout** as JSON.
193
+
194
+ **Exit code semantics:**
195
+
196
+ | Exit Code | Meaning |
197
+ | --------- | -------------------------------- |
198
+ | 0 | Success — parse stdout as JSON |
199
+ | 2 | Blocking deny — stderr is reason |
200
+ | Other | Non-blocking error, execution continues |
201
+
202
+ **Stdin** receives the full hook input as JSON (fields vary by event):
203
+
204
+ ```json
205
+ {
206
+ "session_id": "abc-123",
207
+ "cwd": "/path/to/project",
208
+ "hook_event_name": "PreToolUse",
209
+ "tool_name": "Edit",
210
+ "tool_input": { "file_path": "src/app.ts", "old_string": "...", "new_string": "..." }
211
+ }
212
+ ```
213
+
214
+ **Stdout** JSON output (all fields optional, but `hookSpecificOutput` requires `hookEventName`):
215
+
216
+ ```json
217
+ {
218
+ "decision": "allow",
219
+ "reason": "Checks passed",
220
+ "hookSpecificOutput": {
221
+ "hookEventName": "PreToolUse",
222
+ "additionalContext": "Message injected into conversation"
223
+ }
224
+ }
225
+ ```
226
+
227
+ Note: outputs whose `hookSpecificOutput` lacks `hookEventName` are rejected with `hookSpecificOutput is missing required field "hookEventName"`. Match `hookEventName` to the event your hook is registered on.
228
+
229
+ **Placeholders and exec form.**
230
+
231
+ Placeholders like `${QODER_PROJECT_DIR}`, `${QODER_PLUGIN_ROOT}`, and `${QODER_PLUGIN_DATA}` are exported as environment variables to the hook subprocess.
232
+
233
+ - Under `bash` shell form, the CLI does **not** pre-substitute placeholders — bash expands them at runtime. Prefer double-quoted form so paths containing spaces or shell metacharacters (`'`, `$`, backticks) parse as a single token:
234
+ - Recommended: `"${QODER_PLUGIN_ROOT}"/scripts/hook.sh`
235
+ - Not recommended (unquoted; subject to field splitting / globbing): `${QODER_PLUGIN_ROOT}/scripts/hook.sh`
236
+ - Under `powershell`, `${QODER_PROJECT_DIR}`, `${QODER_PLUGIN_ROOT}`, and `${QODER_PLUGIN_DATA}` are substituted into the command template before invocation.
237
+ - **Exec form** (`args` is set): `command` is an executable path/name and each `args` element is one literal argv entry. The CLI invokes the binary directly (no shell), so no quoting, splitting, or globbing happens. Use it when `command` or args contain complex shell metacharacters and you don't need pipes/redirection/globs.
238
+
239
+ ```jsonc
240
+ {
241
+ "type": "command",
242
+ "command": "/usr/bin/python3",
243
+ "args": ["${QODER_PLUGIN_ROOT}/scripts/check.py", "--strict"]
244
+ }
245
+ ```
246
+
247
+ Best for: scripts, linters, formatters, external CLI tools.
248
+
249
+ ### HTTP (`type: "http"`)
250
+
251
+ POSTs hook input as JSON to the URL. Response parsed as JSON hook
252
+ output. Headers support `${ENV_VAR}` interpolation.
253
+
254
+ ```jsonc
255
+ {
256
+ "type": "http",
257
+ "url": "https://api.example.com/hooks",
258
+ "headers": { "Authorization": "Bearer ${API_TOKEN}" }
259
+ }
260
+ ```
261
+
262
+ Best for: webhooks, external integrations, CI/CD triggers.
263
+
264
+ ### Prompt (`type: "prompt"`)
265
+
266
+ Isolated single-turn LLM evaluation. The evaluator runs in a fresh LLM
267
+ session — it only receives your `prompt` text plus the current event JSON
268
+ (`tool_name`, `tool_input`, etc.), and returns a structured `{ ok, reason }`
269
+ decision.
270
+
271
+ ```jsonc
272
+ {
273
+ "type": "prompt",
274
+ "prompt": "Check if this commit message follows Conventional Commits (type(scope)?: subject). Return {\"ok\": true} or {\"ok\": false, \"reason\": \"...\"}.",
275
+ "if": "Bash(git commit:*)"
276
+ }
277
+ ```
278
+
279
+ **Context boundary.** The evaluator has **no access to the main conversation**: it cannot see prior tool calls, the main Agent's reasoning, files read earlier, or any state outside the current event. Write conditions that can be decided from the event itself. Rules that depend on conversation history cannot be evaluated reliably here — use a `command` hook with persistent state, or an `agent` hook that re-checks the filesystem.
280
+
281
+ Best for: lightweight semantic checks on the event's own data — e.g.
282
+ classifying a Bash command's intent, judging whether a commit message
283
+ follows Conventional Commits. Not for: rules that need to know what the
284
+ main Agent did earlier, or that require reading other files. For
285
+ deterministic checks (path regex, denylisted command, secret signature),
286
+ prefer `command`.
287
+
288
+ ### Agent (`type: "agent"`)
289
+
290
+ Spawns a sub-agent with tool access (`Read`, `Grep`, `Glob`, optionally
291
+ `Bash`, etc.) to investigate before returning `{ ok, reason }`.
292
+
293
+ ```jsonc
294
+ {
295
+ "type": "agent",
296
+ "prompt": "Verify the edited file passes type checking. $ARGUMENTS",
297
+ "tools": ["Bash", "Read"],
298
+ "maxTurns": 10,
299
+ "timeout": 120
300
+ }
301
+ ```
302
+
303
+ **Context boundary.** Like `prompt`, the sub-agent runs in its own session
304
+ and **does not see the main conversation history**. The advantage over
305
+ `prompt` is tool access: it can read files, grep the codebase, and run
306
+ shell commands to verify real state. Use this when verification depends on
307
+ actual filesystem or test output — not as a way to "remember" what the
308
+ main Agent did earlier.
309
+
310
+ Best for: verification that requires inspecting the real codebase or
311
+ running checks (type-check after edit, run a linter, confirm a file
312
+ matches a pattern). Costs more tokens and time than `prompt`; reach for
313
+ `command` first if a deterministic script can do the job.
314
+
315
+ ## The `if` Condition
316
+
317
+ Narrow when a hook fires within a matched definition:
318
+
319
+ ```jsonc
320
+ { "if": "Edit(*.ts)" } // Only Edit calls on .ts files
321
+ { "if": "Write(src/**)" } // Only Write calls under src/
322
+ { "if": "Bash" } // Any Bash call
323
+ { "if": "Bash(git commit:*)" } // Only `git commit` (with or without args)
324
+ ```
325
+
326
+ Format: `"ToolName(glob_pattern)"` or `"ToolName"`.
327
+ The glob matches the tool's primary argument (typically a file path).
328
+
329
+ A trailing `:*` is treated as a **prefix rule**: `"git commit:*"` matches the
330
+ exact command `git commit` and any command that starts with `git commit `
331
+ (prefix + space + anything). For Bash, compound commands (`VAR=1 git commit`,
332
+ `ls && git commit`) are split via tree-sitter and each sub-command is tested
333
+ against the rule.
334
+
335
+ ## Hook Creation Workflow
336
+
337
+ ### Step 1: Determine the Behavior
338
+
339
+ Understand what the user wants:
340
+
341
+ - What should happen automatically?
342
+ - When should it trigger? (before/after tool use, session event, etc.)
343
+ - Should it block operations or just observe?
344
+ - Who needs it? (team or personal)
345
+
346
+ **Avoid interrogation loops.** Propose a concrete hook config based on
347
+ initial understanding and ask the user to refine.
348
+
349
+ ### Step 2: Choose Event, Matcher, and Handler
350
+
351
+ Map the behavior:
352
+
353
+ | Behavior | Event | Matcher | Handler | Notes |
354
+ | ---------------------- | ------------- | -------------- | ------- | ------------------------------ |
355
+ | Auto-format after edits| `PostToolUse` | `Edit\|Write` | command | `if: "Edit(*.{ts,tsx,js,jsx})"` |
356
+ | Block protected files | `PreToolUse` | `Edit\|Write` | command | — |
357
+ | Secret detection | `PreToolUse` | `Edit\|Write` | command | — |
358
+ | Desktop notifications | `Notification`| — | command | `async: true` |
359
+ | Run tests after changes| `PostToolUse` | `Edit\|Write` | command | — |
360
+ | Commit-message lint | `PreToolUse` | `Bash` | prompt | `if: "Bash(git commit:*)"` |
361
+ | Classify risky Bash | `PreToolUse` | `Bash` | prompt | Narrow with `if` to avoid firing on every shell call |
362
+ | AI code review gate | `PreToolUse` | `Edit\|Write` | agent | — |
363
+ | Type-check verification| `PostToolUse` | `Edit\|Write` | agent | `if: "Edit(*.{ts,tsx})"` |
364
+ | Webhook to CI/CD | `PostToolUse` | `Edit\|Write` | http | — |
365
+ | Dependency guard | `PreToolUse` | `Edit` | command | — |
366
+
367
+ **Choosing between command / prompt / agent.** Default to `command` —
368
+ it is the fastest, cheapest, and most predictable, and a regex or short
369
+ script handles most guardrails (secrets, protected paths, formatters).
370
+ Pick `prompt` only when the decision needs LLM-level semantic judgment
371
+ on the event's own data (e.g. classifying a Bash command's intent),
372
+ and remember the evaluator cannot see the rest of the session. Pick
373
+ `agent` when verification must inspect real files or run checks (type
374
+ check, linter, multi-file review); it has tools but still no
375
+ conversation history.
376
+
377
+ ### Step 3: Choose Scope
378
+
379
+ - **Project** (`${QODER_CONFIG_DIR}/settings.json`): Team standards, check in
380
+ - **Local** (`${QODER_CONFIG_DIR}/settings.local.json`): Personal, not committed
381
+ - **User** (`~/${QODER_USER_CONFIG_DIR}/settings.json`): Global, all projects
382
+
383
+ ### Step 4: Create the Configuration
384
+
385
+ 1. Read the target settings.json (if it exists)
386
+ 2. Merge the new hook into the existing `hooks` object
387
+ 3. Write back the file
388
+
389
+ If no hooks exist yet, create the full structure.
390
+
391
+ ### Step 5: Create Script Files (command type)
392
+
393
+ For command hooks with non-trivial logic, create scripts in
394
+ `${QODER_CONFIG_DIR}/hooks/`:
395
+
396
+ ```bash
397
+ mkdir -p ${QODER_CONFIG_DIR}/hooks
398
+ ```
399
+
400
+ Script requirements:
401
+ - Read JSON from stdin
402
+ - Write JSON to stdout (or nothing for simple success)
403
+ - Exit 0 for success, 2 for blocking deny, other for warning
404
+ - Use stderr for error messages and debug output
405
+ - Make executable: `chmod +x ${QODER_CONFIG_DIR}/hooks/my-hook.sh`
406
+
407
+ Test independently:
408
+
409
+ ```bash
410
+ echo '{"tool_name":"Edit","tool_input":{"file_path":"test.ts"}}' | \
411
+ ${QODER_CONFIG_DIR}/hooks/my-hook.sh
412
+ ```
413
+
414
+ ### Step 6: Verify
415
+
416
+ Tell the user to verify:
417
+
418
+ 1. Restart the session or trigger the relevant event
419
+ 2. Check the hook fires and produces expected output
420
+ 3. Test the blocking path (for PreToolUse guards)
421
+ 4. Confirm `async` hooks don't block the session
422
+
423
+ ## Best Practices
424
+
425
+ 1. **Keep hooks fast** — Target <5s for synchronous hooks
426
+ 2. **Test scripts independently** — Pipe sample JSON stdin, verify output
427
+ 3. **Use `async: true`** for non-blocking side effects (notifications, logging)
428
+ 4. **Scope matchers narrowly** — Don't fire on every tool invocation
429
+ 5. **Prefer `if` conditions** for file-type filtering
430
+ 6. **Log to stderr** — stdout is parsed as JSON; debug output goes to stderr
431
+ 7. **Handle edge cases** — Exit 0 if the condition doesn't apply
432
+ 8. **Use `statusMessage`** for meaningful UI feedback during execution
433
+
434
+ ## Anti-Patterns to Avoid
435
+
436
+ - **Overly broad matchers** — `".*"` on PreToolUse fires on every single tool call
437
+ - **Long synchronous hooks** — Block the entire interactive session
438
+ - **Stdout pollution** — Non-JSON stdout causes parse errors
439
+ - **Missing shebang** — Scripts without `#!/bin/bash` may fail silently
440
+ - **Session-aware conditions in `prompt` hooks** — The prompt evaluator only
441
+ sees the current event and has no access to the conversation history.
442
+ Rules that depend on what the main Agent did earlier cannot be
443
+ evaluated; use `command` with persistent state, or `agent` that
444
+ re-checks the filesystem instead.
445
+ - **`prompt` for jobs `command` can do** — If the rule is a deterministic
446
+ pattern check (regex on a path, denylisted command, secret signature),
447
+ use `command`. It is faster, cheaper, and reproducible.
448
+
449
+ ## Examples
450
+
451
+ ### Auto-Format TypeScript
452
+
453
+ Runs Prettier on TypeScript files after every Edit or Write.
454
+
455
+ **`${QODER_CONFIG_DIR}/settings.json`:**
456
+
457
+ ```jsonc
458
+ {
459
+ "hooks": {
460
+ "PostToolUse": [{
461
+ "matcher": "Edit|Write",
462
+ "hooks": [{
463
+ "type": "command",
464
+ "command": "${QODER_CONFIG_DIR}/hooks/auto-format.sh",
465
+ "if": "Edit(*.{ts,tsx,js,jsx})",
466
+ "name": "auto-format",
467
+ "statusMessage": "Formatting..."
468
+ }]
469
+ }]
470
+ }
471
+ }
472
+ ```
473
+
474
+ **`${QODER_CONFIG_DIR}/hooks/auto-format.sh`:**
475
+
476
+ ```bash
477
+ #!/bin/bash
478
+ INPUT=$(cat)
479
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
480
+ [ -z "$FILE" ] && exit 0
481
+ [ -f "$FILE" ] || exit 0
482
+ npx prettier --write "$FILE" >/dev/null 2>&1
483
+ exit 0
484
+ ```
485
+
486
+ ### Protected File Guard
487
+
488
+ Blocks edits to lock files and CI configuration.
489
+
490
+ **`${QODER_CONFIG_DIR}/settings.json`:**
491
+
492
+ ```jsonc
493
+ {
494
+ "hooks": {
495
+ "PreToolUse": [{
496
+ "matcher": "Edit|Write",
497
+ "hooks": [{
498
+ "type": "command",
499
+ "command": "${QODER_CONFIG_DIR}/hooks/protected-files.sh",
500
+ "name": "protected-file-guard",
501
+ "statusMessage": "Checking file permissions..."
502
+ }]
503
+ }]
504
+ }
505
+ }
506
+ ```
507
+
508
+ **`${QODER_CONFIG_DIR}/hooks/protected-files.sh`:**
509
+
510
+ ```bash
511
+ #!/bin/bash
512
+ INPUT=$(cat)
513
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
514
+ [ -z "$FILE" ] && exit 0
515
+
516
+ PROTECTED_PATTERNS=(
517
+ "package-lock.json"
518
+ "yarn.lock"
519
+ "pnpm-lock.yaml"
520
+ ".github/workflows/*"
521
+ ".gitlab-ci.yml"
522
+ )
523
+
524
+ for PATTERN in "${PROTECTED_PATTERNS[@]}"; do
525
+ if [[ "$FILE" == $PATTERN ]]; then
526
+ echo "Blocked: $FILE is a protected file" >&2
527
+ exit 2
528
+ fi
529
+ done
530
+
531
+ exit 0
532
+ ```
533
+
534
+ ### Desktop Notification
535
+
536
+ Sends a macOS notification when Qoder CLI needs attention.
537
+
538
+ **`${QODER_CONFIG_DIR}/settings.local.json`:**
539
+
540
+ ```jsonc
541
+ {
542
+ "hooks": {
543
+ "Notification": [{
544
+ "hooks": [{
545
+ "type": "command",
546
+ "command": "${QODER_CONFIG_DIR}/hooks/notify.sh",
547
+ "name": "desktop-notify",
548
+ "async": true
549
+ }]
550
+ }]
551
+ }
552
+ }
553
+ ```
554
+
555
+ **`${QODER_CONFIG_DIR}/hooks/notify.sh`:**
556
+
557
+ ```bash
558
+ #!/bin/bash
559
+ INPUT=$(cat)
560
+ TITLE=$(echo "$INPUT" | jq -r --arg product 'Qoder CLI' '.title // $product')
561
+ MSG=$(echo "$INPUT" | jq -r '.message // "Notification"')
562
+
563
+ if command -v osascript &>/dev/null; then
564
+ osascript -e "display notification \"$MSG\" with title \"$TITLE\""
565
+ elif command -v notify-send &>/dev/null; then
566
+ notify-send "$TITLE" "$MSG"
567
+ fi
568
+ exit 0
569
+ ```
570
+
571
+ ### Type-Check Gate
572
+
573
+ Uses an agent to verify TypeScript compiles after edits.
574
+
575
+ **`${QODER_CONFIG_DIR}/settings.json`:**
576
+
577
+ ```jsonc
578
+ {
579
+ "hooks": {
580
+ "PostToolUse": [{
581
+ "matcher": "Edit|Write",
582
+ "hooks": [{
583
+ "type": "agent",
584
+ "prompt": "Run `npx tsc --noEmit` and check for type errors in the edited file. If there are errors, report them. $ARGUMENTS",
585
+ "tools": ["Bash", "Read"],
586
+ "if": "Edit(*.{ts,tsx})",
587
+ "name": "type-check",
588
+ "statusMessage": "Type checking...",
589
+ "maxTurns": 5,
590
+ "timeout": 60
591
+ }]
592
+ }]
593
+ }
594
+ }
595
+ ```