用途
verify 是一个验证循环(Verification Loop)技能,用于对代码库执行一系列检查与测试步骤,帮助确认代码质量与功能正确性。其触发关键词包括:verify、run tests、check、lint、typecheck、verification。
主要能力
该技能按固定顺序执行以下步骤:
| 步骤 | 目标 | 安全性 | 缺失时是否跳过 |
|---|---|---|---|
| lint | 检查代码风格(只读) | 只读 | 是 |
| typecheck | 静态类型检查(仅 full 模式) | 只读 | 是 |
| test-unit | 运行单元测试套件 | 只读 | 是 |
| test-integration | 运行集成测试(仅 full 模式) | 只读 | 是 |
| test-e2e | 运行端到端测试(仅 full 模式) | 只读 | 是 |
失败行为为 continue-all:即使某一步失败,仍会运行所有步骤并报告全部结果。
使用方式
第一步:检查运行器脚本
使用 Glob 检查项目根目录下是否存在 .claude/scripts/verify-runner.js。
- 找到 → 运行:node .claude/scripts/verify-runner.js $ARGUMENTS
- 若运行器成功,使用其输出并跳至输出部分。
- 若运行器失败,视为真实的验证失败(不要静默回退)。
- 未找到 → 跳至第二步(不要尝试运行运行器)。
第二步:回退方案(无运行器脚本)
若第一步未找到运行器,则检测项目生态以手动运行各步骤。生态检测通过检查项目根目录的清单文件完成:
| 清单文件 | 生态 | Lint | Typecheck | Test |
|---|---|---|---|---|
| package.json | Node.js | {pm} lint | {pm} typecheck | {pm} test:unit |
| pyproject.toml | Python | ruff check . | mypy . | pytest |
| Cargo.toml | Rust | cargo clippy | (隐式) | cargo test |
| go.mod | Go | golangci-lint run | go vet ./... | go test ./... |
| build.gradle | Java | ./gradlew spotlessCheck | (隐式) | ./gradlew test |
对于 Node.js 项目,会根据锁文件自动检测包管理器。
参数行为:
- $ARGUMENTS == "fast":仅执行 lint + unit。
- 其他情况(full):lint → typecheck → unit → integration → e2e。
各步骤对应的 package.json 脚本及缺失处理:
| 步骤 | package.json 脚本 | 缺失时 |
|---|---|---|
| lint | lint | 跳过并记录 |
| typecheck | typecheck | 跳过并记录 |
| unit | test:unit,回退到 test | 跳过并记录 |
| integration | test:integration | 跳过(需要显式路径) |
| e2e | test:e2e | 跳过(需要显式路径) |
优雅跳过规则:
| 场景 | 行为 |
|---|---|
| 无 lint 脚本 | 跳过,记录 "no lint script — skipped" |
| 无 typecheck 脚本 | 跳过,记录 "no typecheck script — skipped" |
| 无 test:unit 或 test 脚本 | 跳过,记录 "no test script — skipped" |
| 无 package.json | 报告错误,无法运行检查 |
输出格式
fast 模式输出:
Verify (fast)
| Step | Status | Notes |
|---|---|---|
| lint | ✅/❌/⏭️ | |
| unit | ✅/❌/⏭️ |
Overall: ✅ PASS / ❌ FAIL
full 模式输出:
Verify (full)
| Step | Status | Notes |
|---|---|---|
| lint | ✅/❌/⏭️ | |
| typecheck | ✅/❌/⏭️ | |
| unit | ✅/❌/⏭️ | |
| integration | ✅/❌/⏭️ | skipped unless path specified |
| e2e | ✅/❌/⏭️ | skipped unless path specified |
Failures (if any)
- Root cause: <first error>
- Fix: <suggestion>
Overall: ✅ PASS / ❌ FAIL
适用场景
- 需要在提交前或开发过程中对代码库执行完整的验证流程。
- 需要按生态自动识别并运行 lint、类型检查、单元测试、集成测试和端到端测试。
- 需要以只读方式运行检查,不修改代码。
限制
- 不适用于:提交前门禁(应使用 /precommit 或 /precommit-fast)、测试覆盖率审查(应使用 /codex-test-review)、运行单个特定测试(直接运行)。
- 集成测试与端到端测试需要显式指定路径,否则会被跳过。
- 若项目根目录无 package.json,则报告错误,无法运行检查。
- 所有步骤均为只读操作。