关于 verification-loop
verification-loop 是用于 Claude Code 的验证技能,可在重大代码变更后或创建 PR 前检查项目质量。它根据技术栈选择构建、类型、Lint、测试、安全和差异检查,并汇总结果。
主要功能
- 01按技术栈选择验证命令
- 02构建与类型检查
- 03执行 Lint 和测试
- 04检查安全问题与密钥
- 05审阅变更文件并生成报告
适用场景
- 01创建 PR 前验证功能
- 02重构后检查质量门槛
- 03长时间编码期间定期运行检查
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ galaxy-dawn/ claude-scholar --skill verification-loop安装后在 Claude Code 中输入/verification-loop确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
examples/example-verification-report.mdreferences/REPORT-TEMPLATE.mdSTACK-DETECTION.md详细介绍
验证循环技能
用于 Claude Code 会话的全面验证系统。
适用场景
在以下情况下调用此技能:
- 完成一项功能或重大代码更改后
- 创建 PR 前
- 想要确保质量门禁通过时
- 重构后
验证阶段
根据当前项目自适应选择命令,不要盲目运行所有示例。如果仓库与下方默认示例不匹配,请使用 references/STACK-DETECTION.md 中适用于该技术栈的命令。
阶段 1:构建验证
# Python projects (uv)
uv build 2>&1 | tail -20
# OR
python -m build 2>&1 | tail -20
# Node.js projects
npm run build 2>&1 | tail -20
# OR
pnpm build 2>&1 | tail -20
如果构建失败,请停止并修复后再继续。
阶段 2:类型检查
# TypeScript projects
npx tsc --noEmit 2>&1 | head -30
# Python projects
pyright . 2>&1 | head -30
报告所有类型错误。继续之前先修复严重错误。
阶段 3:Lint 检查
# JavaScript/TypeScript
npm run lint 2>&1 | head -30
# Python
ruff check . 2>&1 | head -30
阶段 4:测试套件
# Python projects
pytest --cov=src --cov-report=term-missing 2>&1 | tail -50
# Node.js projects
npm run test -- --coverage 2>&1 | tail -50
报告:
- 测试总数:X
- 通过:X
- 失败:X
- 覆盖率:X%
阶段 5:安全扫描
# Python: Check for secrets
grep -rn "sk-" --include="*.py" . 2>/dev/null | head -10
grep -rn "api_key" --include="*.py" . 2>/dev/null | head -10
pip-audit
# Node.js: Check for secrets
grep -rn "sk-" --include="*.ts" --include="*.js" . 2>/dev/null | head -10
grep -rn "api_key" --include="*.ts" --include="*.js" . 2>/dev/null | head -10
# Check for debug statements
grep -rn "print(" --include="*.py" src/ 2>/dev/null | head -10
grep -rn "console.log" --include="*.ts" --include="*.tsx" src/ 2>/dev/null | head -10
阶段 6:差异审查
# Show what changed
git diff --stat
git diff HEAD~1 --name-only
检查每个已更改的文件,确认是否存在:
- 非预期更改
- 缺少错误处理
- 潜在边界情况
输出格式
运行完所有阶段后,生成验证报告:
VERIFICATION REPORT
==================
Build: [PASS/FAIL]
Types: [PASS/FAIL] (X errors)
Lint: [PASS/FAIL] (X warnings)
Tests: [PASS/FAIL] (X/Y passed, Z% coverage)
Security: [PASS/FAIL] (X issues)
Diff: [X files changed]
Overall: [READY/NOT READY] for PR
Issues to Fix:
1. ...
2. ...
持续模式
对于长时间会话,每 15 分钟或在重大更改后运行验证:
Set a mental checkpoint:
- After completing each function
- After finishing a component
- Before moving to next task
Run: /verify
与钩子的集成
此技能可补充 PostToolUse 钩子,提供更深入的验证。 钩子会立即捕获问题;此技能则提供全面审查。
参考文件
仅加载所需内容:
references/STACK-DETECTION.md- 如何为当前仓库选择合适的验证命令集references/REPORT-TEMPLATE.md- 最终验证输出的报告结构examples/example-verification-report.md- 最终报告示例
评论
支持 Markdown