hook-test-kit SKILL.md skillA
hook-test-kit from hanzhangzzz/agent-skills-zh is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
mdr add hanzhangzzz/agent-skills-zh/hook-test-kit@git:20260904.5bc92ebPins git:20260904.5bc92eb in mdr.lock. Pin the fingerprint instead.
- Audit grade
- A, 17 of 17 checks passed
- Kind
- SKILL.md skill
- Repository
- hanzhangzzz/agent-skills-zh
- Path
hook-test-kit/SKILL.md- Versions recorded
- 1
- Latest version
- git:20260904.5bc92eb, committed Sep 4, 2026
- Size
- 3,179 bytes
- Repository stars
- 1
- License
- MIT
为 Claude Code hook 脚本(PreToolUse / SessionStart / UserPromptSubmit 等)生成行为矩阵测试骨架并指导填场景:scratch fixture 隔离、stdin 喂 JSON、EMPTY/!否定/正则断言协议、已知 bash 坑位预修(路径混入子命令、$var 后跟全角字符、case 变量 pattern 不解析交替)。Use when 用户写了或改了 hook 脚本要测试,说 测一下这个 hook、hook 测试、hook-test-kit、给 hook 补测试。.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# hook-test-kit
给 hook 脚本配一套行为矩阵测试。hook 是用户环境里的高频基建,一个静默放行/误报
直接影响每一次会话——它值得和业务代码同等的测试纪律。
## 前置依赖
- `bash`、`git`、`jq`(`which jq` 检查,缺失即停下说明)
- 被测 hook 脚本路径
## 执行步骤
### 1. 生成骨架
```bash
bash <本 SKILL.md 所在目录>/scripts/scaffold.sh <hook 脚本路径> [输出目录]
```
输出 `<输出目录|hook 同目录>/test_<hook名>.sh`,含可运行的 run/assert 协议与 2 个
TODO 场景。骨架已预修以下高频坑,**不要改掉**:
- 辅助函数用 `local d="$1"; shift` 转发参数,不把路径混进子命令
- 输出文本中变量一律 `${var}` 花括号(`$var` 后紧跟全角字符会被 bash 吃进变量名)
- 断言协议:`EMPTY` = 输出必须为空;`!pattern` = 必须不命中;其余 = egrep 必须命中
- `case` 的 pattern 来自变量时不解析 `|` 交替与 `[...]` 字符类——多模式用循环逐个判定
### 2. 按 hook 语义填场景
最小矩阵(每个 hook 至少覆盖):
| 维度 | 场景 |
|------|------|
| 快速门 | 非 hook 目标命令 → 放行/无输出 |
| 主路径放行 | 正常输入 → 预期放行(断言退出码与输出均为空或合法 JSON) |
| 主路径拦截 | 越界输入 → 预期 ask/deny(断言 permissionDecision 与文案) |
| 变异防护 | 每条拦截规则改坏一版(取反/删条件)跑套件必须变红,改回必须复绿 |
PreToolUse 喂 `{"tool_input":{"command":...},"cwd":...}`;SessionStart 喂 `{}`;
UserPromptSubmit 喂 `{"prompt":...,"cwd":...}`。以被测 hook 实际读取的字段为准。
fixture 一律放 scratch 目录(`mktemp -d` + trap 清理),需要 git 仓库就现场 init;
**绝不**指向用户真实目录。
### 3. 收尾:变异实验
套件全绿后,对每条拦截规则做一次变异(取反、删条件、改边界),确认套件**变红**;
改回后**复绿**。不变红的断言是装饰,删掉或写尖锐。这一步没做,测试不算交付。
## 输出格式
…Read the whole file at its exact version.
How to install
mdr add hanzhangzzz/agent-skills-zh/hook-test-kit@sha256:150d06dcd610a17cThe line at the top of this page pins the label git:20260904.5bc92eb, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
[](https://markdownregistry.com/a/art_3zjzwzmbfin4r62y)
2 badge image fetches in 30 days. What the badge shows.
Versions
The registry has recorded 1 version of this file, committed on Sep 4, 2026.
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (3179 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
hanzhangzzz/agent-skills-zh · 1 stars · license MIT · pushed 2026-10-29 · branch main
API
GET https://markdownregistry.com/api/v1/artifacts/art_3zjzwzmbfin4r62y GET https://markdownregistry.com/api/v1/resolve?ref=hanzhangzzz/agent-skills-zh/hook-test-kit GET https://markdownregistry.com/api/v1/blob/150d06dcd610a17c953a8c6ae3955482fbdfb31a57c3b98a19268398166f9866
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.