Claude Code Hooks Inventory
而家 wired 緊嘅 hooks:26 個
Folder:~/.claude/hooks/(活住 26 個 .sh/.py) + .archive-2026-05-04/(15 個死碼歸檔)
Settings:~/.claude/settings.json
📥 SessionStart (1)
| Hook | 做啲乜 |
|---|
compact-notify.sh | /compact 完通知 TG「壓縮完成」 |
2026-05-04 殺咗:thedotmack/claude-mem 兩個 SessionStart hook(11 日 0 rows、5 分鐘 timeout、258 MB 廢物)
💬 UserPromptSubmit (6) — 你打字/講嘢
| Hook | 做啲乜 |
|---|
save-last-sid.sh | 儲低 session_id,俾 !restart 知返去邊個 session |
tg-shortcuts.sh | 攔截 TG 嘅 !command(!restart /rename 等) |
tg-source-marker.sh | 標今次 prompt 係 TG 定 Terminal(防 reply 錯 channel) |
session-identity.sh | 認 cc / cc2 / cc3 / team-cc 邊個 session |
tg-thinking.sh | send「🤔 思考中」+ 記低 msg_id |
voice-transcribe.py | 語音訊息 → Groq Whisper 轉文字 |
| Matcher | Hook | 做啲乜 |
|---|
| Bash | block-claude-p.sh | 禁 claude -p、destructive 命令要問 |
* | tg-tool-update.sh | 即時 edit「🤔」訊息加 tool icon + 計數 |
| Agent | tg-agent-start.sh | 記低 spawn 緊邊個 subagent |
| Write|Edit | inline JSON guard | 改 settings/skill 提你規則 |
| Write|Edit | block-secrets-in-json.sh | 禁寫 API key 落 .claude.json(必須去 master.env) |
| Write | enforce-skill-creator-2026.sh | 禁直接寫新 skill,要 /skill-creator-2026 先 |
| TG reply | enforce-qa-before-image-send.sh | send 圖前要 self-QA |
✅ PostToolUse (7) — tool 用完之後檢查
| Matcher | Hook | 做啲乜 |
|---|
| TG reply | tg-reply-clean.sh | reply 加 stats + 刪「🤔」訊息 |
| Bash | salesbot-e2e-test.sh | save-prompt API call 後跑 Playwright E2E |
| Agent | tg-agent-done.sh | 清 subagent state |
| Write|Edit | post-edit-qa.sh | syntax check + 紀錄 changed files |
| Write|Edit | ui-qa-check.sh | UI 檔(html/css/jsx)→ 自動 Playwright 截圖 |
| Write|Edit | semantic-validate-skill.sh | SKILL.md 寫完 → spawn validator 捉語義錯誤 |
| Write|Edit | validate-mcp-references.sh | .md 入面 mcp__xxx__yyy 名校對 |
🛑 Stop (4) — 一輪講完
| Hook | 做啲乜 |
|---|
enforce-tg-reply.sh | 上條 prompt 來自 TG → 必須用 reply tool 至准走 |
stop-qa-gate.sh | whatsapp-ai 改完 → 強制跑 Playwright E2E |
cc-task-callback.sh | bridge task(CC_TASK_UUID 設咗)→ POST result 返 bridge |
stop-bell.sh | SSH Mac → 桌面通知 + Tink 音(VS Code focus 時靜音) |
🤖 SubagentStop (1)
| Hook | 做啲乜 |
|---|
tg-subagent-stop.sh | subagent(fg 或 bg)完 → 清 state,唔再喺「🤔」顯示 |
📊 4 大功能類分配
| 類別 | 數量 | 用途 |
|---|
| 📱 TG plumbing | 10 | 思考中 lifecycle(thinking msg / source / session / agent state / reply clean / shortcut / enforce reply) |
| 🚓 Guard rails | 5 | block / enforce(claude -p、secrets、skill-creator、QA-before-image、TG-reply) |
| 🔬 QA / validation | 6 | syntax / UI 截圖 / SKILL semantic / MCP ref / E2E gate / E2E salesbot |
| 🛠️ 雜項 | 5 | session_id / voice / bell / callback / compact-notify |
🧟 已 archive 嘅死碼(15 個)
~/.claude/hooks/.archive-2026-05-04/
Memory recall 系列(thedotmack/claude-mem 取代)
auto-recall.sh、auto-recall.sh.backup
lancedb-recall.sh、lancedb-save.sh
mem0-recall.sh、neo4j-recall.sh、neo4j-store.sh
parallel-recall.sh、unified-recall.py
TG / 雜項
tg-bg-dashboard.sh、tg-zombie-killer.sh、tg-reply-stats.py
cost-report.sh、cc-task-progress.sh、error-reading-reminder.sh
🌍 同其他 power user 比較(2026-05-04 web research)
| 用家類型 | Hook 數量 | 例子 |
|---|
| 普通 power user | 3-7 | Anthropic 官方 blog 示範 5 個 |
| Production tutorial | 5 | Blake Crosley「format/security/test/notify/lint」 |
| 公開最大 demo | 13 | disler/claude-code-hooks-mastery |
| Steven | 26 | 唯一公開接近係 TG bridge + observability infra 個類 |
Bottom line:唔係 over-engineered。outlier 但合理 —— TG bridge + multi-session(cc/cc2/cc3)+ voice + multi-agent routing 每個 concern 都食 hook。
⚠️ 避免再行錯路
- 未來 plugin 入嚟之前:先睇 SessionStart hook 食 timeout 幾大(thedotmack 食 300s 我哋唔知,因為
2>/dev/null || true 食晒 error)
- 改 settings.json hook 之前:read 一次
reference_hooks_settings.md(memory file)
- Hook 寫完一定要手動 test:
bash -c '<command>' 試一次先存
- 唔好亂加新 hook:每加一個就攞走一個自由度。Workflow 上有重複先加。
🔗 相關文檔
[[TG-Hooks-Watchdog-Architecture]] — TG bridge end-to-end flow(深層次)
[[CC-File-Architecture]] — 整個 CC home folder 架構
- Memory:
reference_hooks_settings.md、reference_tg_hooks_architecture.md