/testkit:testspec-code-calibratefrom testkit
Calibrates TestSpec artifacts against code: compares implementation snapshots to PRDs, recovers behavioral drafts from legacy code, or tracks changes across production/test/requirement branches via Git diff.
Ships in testkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
铁律:未经产品通过 testspec-update 明确裁决,绝不能把可观察到的代码行为转成 canonical requirement 或 test oracle,也绝不能修改 requirements.md。
TestSpec 代码校准进度:
- [ ] 步骤 1:确认明确授权、代码角色和范围 ⛔ 阻塞
- [ ] 步骤 2:定位 TestSpec change,并选择 comparison/recovery/change-diff 模式 ⚠️ 必需
- [ ] 步骤 3:冻结 canonical revision 和代码快照
- [ ] 步骤 4:提取可观察的实现证据
- [ ] 步骤 5:对发现分类并登记稳定问题
- [ ] 步骤 6:写入并确定性校验校准 artifact ⛔ 阻塞
- [ ] 步骤 7:确认 canonical 文件未变并完成交接
canonical_source_policy=prd-first;代码权威始终是 reference。observed;缺少支撑的解释标记为 inferred 或 unknown。requirements.md、proposal.md、测试点、用例或 TestLib。android-static-app-reverse 请求和静态报告不得隐式触发校准。选择 code_evidence.role 或处理权威冲突前,加载 ../_testspec-shared/references/source-provenance.md。
用于当前 change 已有版本化 requirements.md 或 proposal.md:
<change>/artifacts/code-calibration.json<change>/artifacts/code-calibration.mdJSON 对照 canonical intent 与可观察代码,但不修改 canonical source。
仅用于 TestSpec change 已存在、没有版本化 canonical source,且用户明确要求从遗留代码恢复行为:
<change>/artifacts/code-calibration.json<change>/artifacts/code-calibration.md<change>/artifacts/recovered-prd-draft.md先写 draft 再写 JSON。draft 标题和上下文必须注明“可观察实现草稿——不是 canonical 文档”,并在 JSON 中记录其 SHA-256 和对应代码快照。产品确认前,testspec-update 不得将这些陈述提升到 requirements.md。
仅在 recovery 模式加载 references/recovered-prd-draft-template.md。
用于已有版本化 canonical source,且用户明确要求比较 production、test、requirement、release、staged 或 worktree 状态:
<change>/artifacts/change-snapshot.json,或 v2 每个 source 的 <change>/artifacts/change-snapshot-<source-id>.json<change>/artifacts/code-calibration.json<change>/artifacts/code-calibration.md加载 references/change-diff-workflow.md。Diff 只是变更证据,不是测试结果,也不能证明未变化的需求缺少实现。
记录:
role:reference、verification-baseline 或 change-evidencerepository_labelunavailable 并提供 snapshot_reason. 才表示仓库根目录角色或范围缺失时,在读取代码前停止。拒绝 ..、绝对路径、远程 URL 和未请求的范围扩张。
来源为 Android 反编译输出时,还必须先核对 android-static-app-reverse 交接的 APK/split SHA-256、包名/版本、反编译工具与模式、退出状态、输出根和覆盖缺口。非 Git 输出的 ref/commit 使用 unavailable,snapshot_reason 必须绑定上述冻结身份;scope 与 evidence path 相对于已授权的反编译输出根。混淆、JNI/native、动态加载、RASP、缺失资源或部分反编译阻断的路径不能支持 aligned/conflict,保持 inferred 或 unknown。
若已授权检查仓库但模块范围不明确,加载 references/module-discovery.md,只检查 discovery surface,返回候选并等待用户选择范围后再读取实现正文。
使用 ../_testspec-shared/references/common.md 定位 change:
testspec-newcomparison 和 change-diff 模式必须记录精确的 canonical source_revision、source 名称(requirements.md 或 proposal.md),以及读取代码前计算的 sha256:<digest>。不得增加 revision。
加载 references/code-evidence-extraction.md,只检查授权范围,提取:
每项证据都使用 source_id(schema v2 必需)、仓库相对路径、symbol/locator、行范围和简短观察。路径只在对应 source 的 scope 内解释;不同仓库中的同名相对路径不得合并。依据该 reference 设置 finding 级 evidence_coverage。注释、命名、未证明调用方的导出函数、不可达代码、feature flag 路径或单一前后端层,都不能视为完整产品事实。
只有框架匹配时加载 references/framework-locators.md。change-diff 模式应先收集并校验安全快照;关键词命中仅用于发现候选,再读取临时 hunk 和相连运行时路径形成语义证据。
写 JSON 前加载 references/calibration-contract.md,只使用:
aligned:意图与可观察行为一致conflict:意图与可观察行为冲突code-only:代码存在行为,但 canonical requirement 未记录prd-only:授权范围内未观察到 canonical requirementunknown:证据不足或互相矛盾规则:
conflict、code-only、unknown 必须有稳定 Q-*、措辞可直接交给产品的顶层 open question,并设置 recommended_handoff=product-confirmation。prd-only 不自动代表实现缺陷;报告搜索范围并交给 testspec-analysis。searched_source_ids 覆盖所有已声明 sources 时才能使用 prd-only;单个仓库未观察到必须保持 unknown。aligned 和 conflict 要求 end-to-end 或 enforcement-layer 覆盖;部分路径只能归为 unknown。code-only 和 unknown。OBS-* draft reference;draft 必须包含该 OBS-* 和所有关联 Q-*。references/change-diff-workflow.md 的固定 trace-status 映射;Diff 中没有变化只能是 unknown/not-observed,不能是 prd-only。将 canonical machine output 写入 <change>/artifacts/code-calibration.json。除非用户明确授权替换,否则不得覆盖已有校准 artifact。
Comparison:
python "<testspec-code-calibrate-skill-dir>/scripts/validate_code_calibration.py" \
--input "<change>/artifacts/code-calibration.json" \
--canonical "<change>/<requirements.md-or-proposal.md>"
Recovery:
python "<testspec-code-calibrate-skill-dir>/scripts/validate_code_calibration.py" \
--input "<change>/artifacts/code-calibration.json" \
--draft "<change>/artifacts/recovered-prd-draft.md"
Change-diff:先按 references/change-diff-workflow.md 的命令和安全标签规则,为每个 source 用 scripts/collect_change_snapshot.py --source-id <id> 收集独立 change-snapshot-<id>.json;schema v1 单快照继续兼容。然后逐个执行:
python "<testspec-code-calibrate-skill-dir>/scripts/validate_change_snapshot.py" \
--input "<change>/artifacts/change-snapshot-<source-id>.json"
python "<testspec-code-calibrate-skill-dir>/scripts/validate_code_calibration.py" \
--input "<change>/artifacts/code-calibration.json" \
--canonical "<change>/<requirements.md-or-proposal.md>" \
--snapshot "<change>/artifacts/change-snapshot-<source-id>.json" \
--snapshot "<change>/artifacts/change-snapshot-<other-source-id>.json"
JSON 校验通过后,渲染不含代码片段的 Markdown 视图:
python "<testspec-code-calibrate-skill-dir>/scripts/render_code_calibration.py" \
--input "<change>/artifacts/code-calibration.json" \
--output "<change>/artifacts/code-calibration.md"
修复所有校验错误。comparison 和 change-diff 模式需在校验后重新读取 canonical 文件,并确认 digest 仍等于 _context.canonical_source_digest。
历史 schema v1 artifact 可直接验证。需要升级时仅对已验证 v1 使用 --migrate-v2-output <new-path>;迁移新增稳定 source-1 和对应 evidence/snapshot 引用,不覆盖原文件。change-diff companion snapshot 用 validate_change_snapshot.py --source-id source-1 --migrate-v2-output ... 同步迁移;recovery draft 按 v2 template 补 source 表与前缀后更新 digest。
aligned 或 prd-only → testspec-analysisconflict、code-only 或 unknown → 产品确认testspec-update,再执行 testspec-analysistestspec-update;不得直接进入 points/generatepartial/not-observed/unknown → 产品确认或经明确授权扩大证据范围;不得因 Diff 缺失就声称未实现keep/revise| 反模式 | 必需修正 |
|---|---|
| 因仓库可用就扫描代码 | 要求明确调用、角色和范围 |
| 直接从代码写 REQ/AC | 写 recovery draft 或 code-only finding |
| 把单仓代码缺失当作全产品未实现 | 未覆盖全部 sources 时使用 unknown;全部覆盖才可用 prd-only 并记录 searched_source_ids |
| artifact 使用绝对路径 | 使用仓库相对路径和安全标签 |
| 把注释或死代码当作 observed behavior | 标记为 inferred/unknown 并登记 Q-* |
| 代码冲突未解决就继续生成用例 | 先产品确认并执行 testspec-update |
| 把关键词命中当作实现证据 | 只用于选择临时 hunk,再做语义检查 |
没有变更 hunk 就归为 prd-only | 使用 unknown + not-observed;完整缺失需 comparison 模式证明 |
| 保存真实私有 ref 或原始 Diff | 只存安全角色标签、commit、元数据和相对 locator |
| 自动 fetch、checkout 或切换 two-dot/three-dot 语义 | 只使用本地已有 ref 和明确选择的 Diff 模式 |
| Android 逆向完成后自动校准 | 只交付静态报告;用户显式调用本 skill 后才读取反编译代码 |
unavailable 和具体 snapshot_reason。reference。conflict/code-only/unknown 有稳定 Q-*,且与可直接交给产品的问题对象双向关联。公开 eval 和示例必须完全合成。绝不能复制私有源代码、仓库路径、公司名、工单、URL 或业务数值。
agents/openai.yaml (opens in a new tab)evals/evals.json (opens in a new tab)references/calibration-contract.md (opens in a new tab)references/change-diff-workflow.md (opens in a new tab)references/code-evidence-extraction.md (opens in a new tab)references/framework-locators.md (opens in a new tab)references/module-discovery.md (opens in a new tab)references/recovered-prd-draft-template.md (opens in a new tab)scripts/collect_change_snapshot.py (opens in a new tab)scripts/render_code_calibration.py (opens in a new tab)scripts/validate_change_snapshot.py (opens in a new tab)scripts/validate_code_calibration.py (opens in a new tab)tests/test_change_diff_tools.py (opens in a new tab)tests/test_multisource_calibration_v2.py (opens in a new tab)tests/test_validate_code_calibration.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub winhok/testkit --plugin testkit26 skills in this plugin
/android-static-app-reverseAndroid 应用纯静态逆向分析工作流,支持从 ADB 导出 APK、处理 split APK、使用 JADX/apktool/Vineflower 反编译、盘点静态产物、检测加固、提取 API endpoint 并生成带证据和置信度的报告。当用户要求「用 JADX 逆向」「从手机导出安装包」「查包名并反编译」「提取接口」「检测加固」「分析 APK/JADX 输出」「检查 Retrofit/OkHttp/Volley」「查找静态泄漏」「追踪 Android 调用链」时使用。/api-test-automation基于 HTTP API 定义生成并执行自动化测试,支持 Swagger/OpenAPI 2.0、OpenAPI 3.0/3.1/3.2、YApi、Postman Collection 2.1、受控运行已有 pytest 资产,以及用户明确要求的后端源码静态扫描。适用于「做接口自动化测试」「从 YApi 或 Swagger 生成并运行测试」「导入 Postman Collection」「运行已有 pytest 接口用例」「扫描后端接口」「跑 API smoke」「登录后提取 Token」「串联多接口并传递变量」「执行 setup/cleanup、数据驱动、业务断言、正负向、模糊或状态化测试」「检查接口实现与文档是否一致」以及从接口发现、导入、执行到结果归因的端到端任务。/app-test执行 Android、iOS 与 Web 的真实运行测试,验证页面交互、系统行为和跨端业务旅程,记录实际断言与证据。用户要按已确认用例测试网站、操作手机应用、跑端到端用例或验证 WebView 时使用;没有代码仓库、需要逆向网站并为 TestSpec 建立实现证据时走 web-app-reverse,录屏转缺陷报告走 video-to-issue。Other plugins' skills for the same job