跳到正文
cccskills
免费在 GitHub 公开中文介绍

diagnosing-hooks

检查 ZCode 钩子的配置来源、事件、匹配规则、脚本、输出和运行日志,逐步查明未触发、阻止会话或报错的原因,并据此修正。

原文查看原文说明

Use to diagnose and fix ZCode hook configuration problems in the ZCode client. Applies when a hook does not trigger, an event name is wrong, a matcher does not match a tool name, a script is not executable, template variables are not expanded, a timeout unit is mistaken (seconds versus milliseconds), the command and process field styles are mixed, a hook's JSON output fails validation, a hook blocks the session unexpectedly, or configuration-file hooks are not enabled. Provides configuration sources, the hooks.json schema, how to inspect hooks in the client, and a step-by-step localization and repair workflow.

实测评分 未实测

查看安装方法

适用场景

  • 排查钩子未触发的原因
  • 核对事件名称和匹配规则
  • 修复超时或 JSON 校验错误
  • 调查会话意外停止

中文介绍

功能

此技能会排查 ZCode 钩子设置的问题,并将原因落实为具体修正。它会检查配置文件是否启用、事件名称、针对工具名称的条件、脚本执行权限、模板变量、超时时间单位,以及 command 与 process 字段的区别。它还会检查钩子返回的 JSON 格式和退出码,并结合客户端设置界面与运行日志,区分钩子未启动、超时、执行失败和有意阻止操作等情况。检查顺序从确认钩子是否注册开始,再验证事件和条件、手动执行,最后观察实际日志。

适用场景

配置的钩子没有运行、只对某些工具生效,或意外停止会话时,可以使用此技能。它适合结合设置项和日志逐步缩小问题范围。

使用示例

  • “查明这个 ZCode 钩子为什么没有触发。”
  • “检查工具名称匹配规则为什么没有匹配。”
  • “根据日志找出钩子停止会话的原因。”

注意事项

此技能针对 ZCode 客户端的钩子配置。配置文件中的钩子默认处于禁用状态;要运行它们,需设置 hooks.enabled: true。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足资料涉及钩子执行和 chmod,但未充分说明如何确认钩子可信。
安装难易度所需工具和 API 密钥是否少且有说明
A良好资料以 ZCode 客户端为对象,并说明配置钩子的启用设置。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月24日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md9.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Diagnosing Hook Configuration

Goal: reduce any hook problem to a single concrete fix.

Note on trust: plugin hooks execute regardless of the marketplace they came from — third-party plugin hooks run just like built-in ones. Any "diagnostic-only until trusted" wording you may see for marketplace hooks is stale; a plugin's detail view marks each hook as runnable, and that is now true for all hooks.

1. Configuration sources and merging

  • Configuration-file hooks: the top-level hooks key in ~/.zcode/cli/config.json (or the workspace <repo>/.zcode/config.json / zcode.json), shaped as { enabled?, timeoutMs?, maxOutputBytes?, events: { <Event>: [ { matcher?, hooks: [...] } ] } }. These are disabled by default — configuration-file hooks must set hooks.enabled: true to run.
  • Plugin hooks: each plugin's hooks/hooks.json (or its manifest hooks field). Plugin matchers are appended after configuration matchers. When any plugin contributes a hook, the hook runner is enabled automatically.
  • Non-plugin (user or workspace) configuration hooks have no trust gate; with enabled: true they run unconditionally.

2. hooks.json schema

{ "hooks": { "<Event>": [ { "matcher": "...", "hooks": [ { "type": "command"|"process", ... } ] } ] } }

(A plugin file uses the outer hooks wrapper; the configuration file uses hooks.events.<Event>. The inner array is the same.)

  • Event names (exactly seven): SessionStart, UserPromptSubmit, PreToolUse, PermissionRequest, PostToolUse, PostToolUseFailure, Stop. Any other name is an unsupported event. (Events such as Notification, SubagentStop, and PreCompact are not supported.)
  • The matcher is a case-sensitive regular expression, tested against the event's match value:
    • SessionStart → one of startup, resume, clear, compact
    • Tool events (PreToolUse, PostToolUse, PermissionRequest, PostToolUseFailure) → the tool name (Bash, Read, Write, Edit, Agent, …), with aliases Task ↔ Agent and Write/Edit ← ApplyPatch
    • UserPromptSubmit → the prompt text; Stop → the response preview
    • An omitted matcher matches everything; an invalid regular expression never matches (silently)
  • type: "command": command (a shell string); optional shell, timeout (in seconds), timeoutMs (in milliseconds, takes precedence), and statusMessage. Note that async currently has no runtime effect.
  • type: "process": command (an executable) plus args[] (an argument vector run without a shell, the most portable choice), timeoutMs (in milliseconds), and statusMessage.
  • Timeout resolution: timeoutMs → timeout × 1000 → the configuration's timeoutMs → a default of 60000 ms.
  • Template variables (expanded in the command and each argument, and also injected as environment variables): ${CLAUDE_PROJECT_DIR} / ${ZCODE_PROJECT_DIR}, ${CLAUDE_SESSION_ID}; and, for plugin hooks only, ${CLAUDE_PLUGIN_ROOT} / ${ZCODE_PLUGIN_ROOT} and the plugin data directory. Note that a skill-directory variable is not valid in a hook and raises an error.
  • Hook output: standard output is parsed as JSON (a strict schema — any extra key fails validation), or you may use exit codes: 0 passes, 2 blocks (a deny for PreToolUse/PermissionRequest), and any other non-zero raises an error. additionalContext is injected into the conversation; PreToolUse may return a permission decision of allow/ask/deny; Stop may request continuation (up to three times).

3. How to inspect hooks

  • In the client: Settings → Plugin Management → open a plugin's detail view to see the hooks it registers and whether each is runnable.
  • As an agent: read the hooks/hooks.json (or the manifest hooks field) for a plugin, and the hooks block of ~/.zcode/cli/config.json / the workspace config for configuration hooks.
  • Execution (fired, timed out, blocked) is recorded in the ZCode log, with the hook's source, matcher, outcome, duration, and a preview of its error stream — enough to distinguish a timeout from a failure from a block.

4. Common pitfalls (symptom → cause → fix)

  1. Configuration-file hooks do not run — you added hooks.events.* but nothing fires. They are disabled by default and are enabled automatically only when a plugin hook is present. → Set "hooks": { "enabled": true, ... } in the configuration.
  2. Wrong event name — the hook never triggers. → Use exactly one of the seven supported events.
  3. Matcher does not match (tool name, case, or regex) — it is registered but never fires for the tool you expect. The matcher is a case-sensitive regular expression; "bash" will not match Bash, and an invalid expression never matches. → Use the exact tool name or a correct expression (for example "Edit|Write"), or omit the matcher to match all. Remember the aliases Task → Agent and Write/Edit → ApplyPatch.
  4. Script is not executable — permission denied, with a failed outcome. The script was installed without the executable bit. → Run chmod +x on it, or invoke it through an interpreter, e.g. {"type":"command","command":"bash \"${CLAUDE_PLUGIN_ROOT}/hooks/x.sh\""}, so the executable bit is irrelevant.
  5. Template variable not expanded — a literal ${...} or an empty path. Only recognized variables are expanded; a skill-directory variable raises an error inside a hook, and ${CLAUDE_PLUGIN_ROOT} is available only for plugin hooks. → Use only supported variables, and ${CLAUDE_PLUGIN_ROOT} for plugin-relative paths.
  6. Timeout unit mistaken — the hook is killed with a timed-out outcome. command's timeout is in seconds; process's timeoutMs is in milliseconds. timeout: 500 means 500 seconds; timeoutMs: 5 means 5 milliseconds. → Use "timeout": <seconds> for a command hook and "timeoutMs": <milliseconds> for a process hook.
  7. Command and process fields mixed — the hook is dropped. A process hook accepts only command, args, and timeoutMs; a command hook accepts command, shell, timeout, and timeoutMs. → Match the fields to the type.
  8. JSON output fails validation — the hook ran but its effect was discarded and the run marked failed. The output was not valid JSON, contained an extra key (the schema is strict), or its event-specific output named the wrong event. → Emit only the recognized keys with the correct event name, or emit nothing (empty output is fine) and rely on exit codes.
  9. Assuming async runs in the background — you set async: true but the session still waits. The async field has no runtime effect and hooks always run inline. → Do not rely on async; for background work, have the script daemonize itself.
  10. Cross-platform failure — it works on one operating system but not another. A command hook runs through a shell, so POSIX syntax fails on Windows. → Prefer a process hook (an argument vector, no shell), or ship a polyglot wrapper script and keep hook scripts extensionless.
  11. A hook blocks the session unexpectedly — a tool is denied or the run halts. The hook returned a block, exited with code 2, or returned a deny decision. → Inspect the block's reason in the log; fix the script's exit code — return 0 to pass and reserve 2 for a deliberate block.
  12. Believing third-party hooks are "diagnostic only" — a third-party plugin hook did not run and you suspect a trust gate. That is not the cause: all plugin hooks are runnable. → Diagnose via pitfalls 2, 3, 4, and 8.

5. Localization workflow (in order)

  1. Is a runner active? Confirm that either hooks.enabled: true is set in the configuration or at least one plugin contributes a hook; otherwise no runner exists and every hook is skipped.
  2. Enumerate what is registered. In Settings → Plugin Management, open the plugin's detail view and confirm the hook you expect is present and runnable, and that its plugin is enabled. For configuration hooks, read the hooks block directly.
  3. Event name and matcher. Check against the seven events; confirm the match value and the case-sensitive expression; test by omitting the matcher (which matches everything).
  4. Executable and interpreter. Confirm the script has its executable bit, or invoke it explicitly via bash/node.
  5. Run it by hand. Feed a sample hook input to the script and inspect the exit code and output — 0 plus valid JSON is healthy, 2 is a deliberate block, any other non-zero is a failure.
  6. Observe live. Trigger the event and read the hook run records in the log (outcome, duration, error-stream preview) to distinguish a timeout from a failure from a block.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

3d-object

免费有简介

使用three.js创建立体模型,在交互式查看器中从各个角度检查形状和材质,并以OBJ + MTL或GLB格式保存,供其他三维制作软件使用。

  • 创建立体模型并从各个角度检查
  • 制作可在Blender中继续编辑的模型
  • 检查模型轮廓和材质效果
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

action-items

免费有简介

在个人任务清单中记录待办事项、承诺、期限、下一步、待回复对象和阻碍原因,更新进度与依赖关系,合并重复项并归档已结束的任务。

  • 记录有期限的任务与承诺
  • 整理待回复事项及阻碍原因
  • 前置任务完成后更新依赖关系
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

agents

免费

Coordinate a task from a verifiable goal through completion. Handle work directly or split independent tasks across separate agent sessions, track progress, verify results, and arrange pull request merging when included in the goal.

中文简介正在准备中。当前显示英语简介。

  • Split independent tasks across agents
  • Check progress across ongoing tasks
  • Resume a previously started project
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

animated-video

免费有简介

将动画制作成可播放、暂停和定位时间的HTML页面,通过时间轴调整场景时长与速度,并为横屏或竖屏视频导出做好准备。

  • 制作产品操作演示动画
  • 用文字和图形解释内容
  • 制作竖屏动画
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

apple_healthkit

免费有简介

按指定时段查看已同步到Apple Health的步数、心率、睡眠和锻炼记录,了解日常变化,并检查同步状态及记录缺失情况。

  • 查看步数与心率变化
  • 检查睡眠阶段、时长及夜间醒来情况
  • 回顾运动时长、距离与消耗热量
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

artifact_document

免费有简介

创建和编辑Word文档及模板,提取或整理内容、替换图片,并处理修订和批注。使用规范的标题与列表结构,交付前检查所有页面的显示效果。

  • 创建结构规范的Word文档
  • 整理现有文档的内容
  • 替换文档中的图片和文字
asgeirtj/system_prompts_leaks7万2026年10月24日 更新

查看 asgeirtj 的全部技能

报告此技能的问题