verification-and-quality-assurance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLIBRARY-FIRST PROTOCOL (MANDATORY)
优先使用库协议(强制要求)
Before writing ANY code, you MUST check:
在编写任何代码之前,你必须检查:
Step 1: Library Catalog
步骤1:库目录
- Location:
.claude/library/catalog.json - If match >70%: REUSE or ADAPT
- 位置:
.claude/library/catalog.json - 匹配度>70%:复用或适配
Step 2: Patterns Guide
步骤2:模式指南
- Location:
.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md - If pattern exists: FOLLOW documented approach
- 位置:
.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md - 若模式已存在:遵循文档中记录的方法
Step 3: Existing Projects
步骤3:现有项目
- Location:
D:\Projects\* - If found: EXTRACT and adapt
- 位置:
D:\Projects\* - 若找到:提取并适配
Decision Matrix
决策矩阵
| Match | Action |
|---|---|
| Library >90% | REUSE directly |
| Library 70-90% | ADAPT minimally |
| Pattern exists | FOLLOW pattern |
| In project | EXTRACT |
| No match | BUILD (add to library after) |
| 匹配度 | 操作 |
|---|---|
| 库匹配>90% | 直接复用 |
| 库匹配70-90% | 最小化适配 |
| 模式已存在 | 遵循模式 |
| 存在于项目中 | 提取 |
| 无匹配 | 构建(之后添加到库中) |
When to Use This Skill
何时使用该技能
Use this skill when:
- Code quality issues are detected (violations, smells, anti-patterns)
- Audit requirements mandate systematic review (compliance, release gates)
- Review needs arise (pre-merge, production hardening, refactoring preparation)
- Quality metrics indicate degradation (test coverage drop, complexity increase)
- Theater detection is needed (mock data, stubs, incomplete implementations)
在以下场景使用此技能:
- 检测到代码质量问题(违规、坏味道、反模式)
- 审计要求强制进行系统性审查(合规性、发布闸门)
- 需要进行代码审查(合并前、生产环境加固、重构准备)
- 质量指标显示退化(测试覆盖率下降、复杂度增加)
- 需要检测占位实现(模拟数据、桩代码、不完整实现)
When NOT to Use This Skill
何时不使用该技能
Do NOT use this skill for:
- Simple formatting fixes (use linter/prettier directly)
- Non-code files (documentation, configuration without logic)
- Trivial changes (typo fixes, comment updates)
- Generated code (build artifacts, vendor dependencies)
- Third-party libraries (focus on application code)
以下场景请勿使用此技能:
- 简单格式修复(直接使用linter/prettier)
- 非代码文件(文档、无逻辑的配置文件)
- 微小变更(拼写错误修复、注释更新)
- 生成的代码(构建产物、供应商依赖)
- 第三方库(聚焦于应用代码)
Success Criteria
成功标准
This skill succeeds when:
- Violations Detected: All quality issues found with ZERO false negatives
- False Positive Rate: <5% (95%+ findings are genuine issues)
- Actionable Feedback: Every finding includes file path, line number, and fix guidance
- Root Cause Identified: Issues traced to underlying causes, not just symptoms
- Fix Verification: Proposed fixes validated against codebase constraints
满足以下条件时,该技能生效:
- 违规检测:发现所有质量问题,零漏报
- 误报率:<5%(95%+的发现为真实问题)
- 可操作反馈:每个发现都包含文件路径、行号和修复指导
- 根因识别:追溯问题的根本原因,而非仅表象
- 修复验证:针对代码库约束验证提议的修复方案
Edge Cases and Limitations
边缘情况与限制
Handle these edge cases carefully:
- Empty Files: May trigger false positives - verify intent (stub vs intentional)
- Generated Code: Skip or flag as low priority (auto-generated files)
- Third-Party Libraries: Exclude from analysis (vendor/, node_modules/)
- Domain-Specific Patterns: What looks like violation may be intentional (DSLs)
- Legacy Code: Balance ideal standards with pragmatic technical debt management
请谨慎处理以下边缘情况:
- 空文件:可能触发误报 - 验证意图(桩代码 vs 故意为空)
- 生成的代码:跳过或标记为低优先级(自动生成的文件)
- 第三方库:排除在分析之外(vendor/、node_modules/)
- 领域特定模式:看似违规的内容可能是故意设计的(DSL)
- 遗留代码:在理想标准与务实的技术债务管理之间取得平衡
Quality Analysis Guardrails
质量分析准则
CRITICAL RULES - ALWAYS FOLLOW:
- NEVER approve code without evidence: Require actual execution, not assumptions
- ALWAYS provide line numbers: Every finding MUST include file:line reference
- VALIDATE findings against multiple perspectives: Cross-check with complementary tools
- DISTINGUISH symptoms from root causes: Report underlying issues, not just manifestations
- AVOID false confidence: Flag uncertain findings as "needs manual review"
- PRESERVE context: Show surrounding code (5 lines before/after minimum)
- TRACK false positives: Learn from mistakes to improve detection accuracy
必须遵循的关键规则:
- 无证据绝不批准代码:要求实际执行验证,而非假设
- 始终提供行号:每个发现必须包含文件:行号引用
- 从多维度验证发现:使用互补工具交叉检查
- 区分表象与根因:报告根本问题,而非仅表现症状
- 避免虚假自信:将不确定的发现标记为“需人工审查”
- 保留上下文:显示代码的上下文(至少前后5行)
- 跟踪误报:从错误中学习以提高检测准确性
Evidence-Based Validation
基于证据的验证
Use multiple validation perspectives:
- Static Analysis: Code structure, patterns, metrics (connascence, complexity)
- Dynamic Analysis: Execution behavior, test results, runtime characteristics
- Historical Analysis: Git history, past bug patterns, change frequency
- Peer Review: Cross-validation with other quality skills (functionality-audit, theater-detection)
- Domain Expertise: Leverage .claude/expertise/{domain}.yaml if available
Validation Threshold: Findings require 2+ confirming signals before flagging as violations.
使用多种验证视角:
- 静态分析:代码结构、模式、指标(耦合度、复杂度)
- 动态分析:执行行为、测试结果、运行时特征
- 历史分析:Git历史、过往bug模式、变更频率
- 同行评审:与其他质量技能交叉验证(功能审计、占位实现检测)
- 领域专业知识:如有可用,利用
.claude/expertise/{domain}.yaml
验证阈值:发现需要2个以上确认信号才可标记为违规。
Integration with Quality Pipeline
与质量流水线的集成
This skill integrates with:
- Pre-Phase: Load domain expertise (.claude/expertise/{domain}.yaml)
- Parallel Skills: functionality-audit, theater-detection-audit, style-audit
- Post-Phase: Store findings in Memory MCP with WHO/WHEN/PROJECT/WHY tags
- Feedback Loop: Learnings feed dogfooding-system for continuous improvement
该技能与以下环节集成:
- 前置阶段:加载领域专业知识()
.claude/expertise/{domain}.yaml - 并行技能:functionality-audit、theater-detection-audit、style-audit
- 后置阶段:将发现存储到Memory MCP,并添加WHO/WHEN/PROJECT/WHY标签
- 反馈循环:学习成果反馈到dogfooding-system以持续改进
Verification & Quality Assurance Skill
验证与质量保证技能
What This Skill Does
该技能的作用
This skill provides a comprehensive verification and quality assurance system that ensures code quality and correctness through:
- Truth Scoring: Real-time reliability metrics (0.0-1.0 scale) for code, agents, and tasks
- Verification Checks: Automated code correctness, security, and best practices validation
- Automatic Rollback: Instant reversion of changes that fail verification (default threshold: 0.95)
- Quality Metrics: Statistical analysis with trends, confidence intervals, and improvement tracking
- CI/CD Integration: Export capabilities for continuous integration pipelines
- Real-time Monitoring: Live dashboards and watch modes for ongoing verification
此技能提供全面的验证与质量保证系统,通过以下方式确保代码质量与正确性:
- 真实度评分:针对代码、Agent和任务的实时可靠性指标(0.0-1.0评分范围)
- 验证检查:自动化的代码正确性、安全性与最佳实践验证
- 自动回滚:对未通过验证的变更立即执行回滚(默认阈值:0.95)
- 质量指标:包含趋势、置信区间和改进跟踪的统计分析
- CI/CD集成:支持导出至持续集成流水线
- 实时监控:用于持续验证的实时仪表盘与监视模式
Prerequisites
前置条件
- Claude Flow installed ()
npx claude-flow@alpha - Git repository (for rollback features)
- Node.js 18+ (for dashboard features)
- 已安装Claude Flow()
npx claude-flow@alpha - Git仓库(用于回滚功能)
- Node.js 18+(用于仪表盘功能)
Quick Start
快速开始
bash
undefinedbash
undefinedView current truth scores
查看当前真实度评分
npx claude-flow@alpha truth
npx claude-flow@alpha truth
Run verification check
运行验证检查
npx claude-flow@alpha verify check
npx claude-flow@alpha verify check
Verify specific file with custom threshold
使用自定义阈值验证特定文件
npx claude-flow@alpha verify check --file src/app.js --threshold 0.98
npx claude-flow@alpha verify check --file src/app.js --threshold 0.98
Rollback last failed verification
回滚上次未通过的验证
npx claude-flow@alpha verify rollback --last-good
---npx claude-flow@alpha verify rollback --last-good
---When to Use This Skill
何时使用该技能
Use this skill when:
- Code quality issues are detected (violations, smells, anti-patterns)
- Audit requirements mandate systematic review (compliance, release gates)
- Review needs arise (pre-merge, production hardening, refactoring preparation)
- Quality metrics indicate degradation (test coverage drop, complexity increase)
- Theater detection is needed (mock data, stubs, incomplete implementations)
在以下场景使用此技能:
- 检测到代码质量问题(违规、坏味道、反模式)
- 审计要求强制进行系统性审查(合规性、发布闸门)
- 需要进行代码审查(合并前、生产环境加固、重构准备)
- 质量指标显示退化(测试覆盖率下降、复杂度增加)
- 需要检测占位实现(模拟数据、桩代码、不完整实现)
When NOT to Use This Skill
何时不使用该技能
Do NOT use this skill for:
- Simple formatting fixes (use linter/prettier directly)
- Non-code files (documentation, configuration without logic)
- Trivial changes (typo fixes, comment updates)
- Generated code (build artifacts, vendor dependencies)
- Third-party libraries (focus on application code)
以下场景请勿使用此技能:
- 简单格式修复(直接使用linter/prettier)
- 非代码文件(文档、无逻辑的配置文件)
- 微小变更(拼写错误修复、注释更新)
- 生成的代码(构建产物、供应商依赖)
- 第三方库(聚焦于应用代码)
Success Criteria
成功标准
This skill succeeds when:
- Violations Detected: All quality issues found with ZERO false negatives
- False Positive Rate: <5% (95%+ findings are genuine issues)
- Actionable Feedback: Every finding includes file path, line number, and fix guidance
- Root Cause Identified: Issues traced to underlying causes, not just symptoms
- Fix Verification: Proposed fixes validated against codebase constraints
满足以下条件时,该技能生效:
- 违规检测:发现所有质量问题,零漏报
- 误报率:<5%(95%+的发现为真实问题)
- 可操作反馈:每个发现都包含文件路径、行号和修复指导
- 根因识别:追溯问题的根本原因,而非仅表象
- 修复验证:针对代码库约束验证提议的修复方案
Edge Cases and Limitations
边缘情况与限制
Handle these edge cases carefully:
- Empty Files: May trigger false positives - verify intent (stub vs intentional)
- Generated Code: Skip or flag as low priority (auto-generated files)
- Third-Party Libraries: Exclude from analysis (vendor/, node_modules/)
- Domain-Specific Patterns: What looks like violation may be intentional (DSLs)
- Legacy Code: Balance ideal standards with pragmatic technical debt management
请谨慎处理以下边缘情况:
- 空文件:可能触发误报 - 验证意图(桩代码 vs 故意为空)
- 生成的代码:跳过或标记为低优先级(自动生成的文件)
- 第三方库:排除在分析之外(vendor/、node_modules/)
- 领域特定模式:看似违规的内容可能是故意设计的(DSL)
- 遗留代码:在理想标准与务实的技术债务管理之间取得平衡
Quality Analysis Guardrails
质量分析准则
CRITICAL RULES - ALWAYS FOLLOW:
- NEVER approve code without evidence: Require actual execution, not assumptions
- ALWAYS provide line numbers: Every finding MUST include file:line reference
- VALIDATE findings against multiple perspectives: Cross-check with complementary tools
- DISTINGUISH symptoms from root causes: Report underlying issues, not just manifestations
- AVOID false confidence: Flag uncertain findings as "needs manual review"
- PRESERVE context: Show surrounding code (5 lines before/after minimum)
- TRACK false positives: Learn from mistakes to improve detection accuracy
必须遵循的关键规则:
- 无证据绝不批准代码:要求实际执行验证,而非假设
- 始终提供行号:每个发现必须包含文件:行号引用
- 从多维度验证发现:使用互补工具交叉检查
- 区分表象与根因:报告根本问题,而非仅表现症状
- 避免虚假自信:将不确定的发现标记为“需人工审查”
- 保留上下文:显示代码的上下文(至少前后5行)
- 跟踪误报:从错误中学习以提高检测准确性
Evidence-Based Validation
基于证据的验证
Use multiple validation perspectives:
- Static Analysis: Code structure, patterns, metrics (connascence, complexity)
- Dynamic Analysis: Execution behavior, test results, runtime characteristics
- Historical Analysis: Git history, past bug patterns, change frequency
- Peer Review: Cross-validation with other quality skills (functionality-audit, theater-detection)
- Domain Expertise: Leverage .claude/expertise/{domain}.yaml if available
Validation Threshold: Findings require 2+ confirming signals before flagging as violations.
使用多种验证视角:
- 静态分析:代码结构、模式、指标(耦合度、复杂度)
- 动态分析:执行行为、测试结果、运行时特征
- 历史分析:Git历史、过往bug模式、变更频率
- 同行评审:与其他质量技能交叉验证(功能审计、占位实现检测)
- 领域专业知识:如有可用,利用
.claude/expertise/{domain}.yaml
验证阈值:发现需要2个以上确认信号才可标记为违规。
Integration with Quality Pipeline
与质量流水线的集成
This skill integrates with:
- Pre-Phase: Load domain expertise (.claude/expertise/{domain}.yaml)
- Parallel Skills: functionality-audit, theater-detection-audit, style-audit
- Post-Phase: Store findings in Memory MCP with WHO/WHEN/PROJECT/WHY tags
- Feedback Loop: Learnings feed dogfooding-system for continuous improvement
该技能与以下环节集成:
- 前置阶段:加载领域专业知识()
.claude/expertise/{domain}.yaml - 并行技能:functionality-audit、theater-detection-audit、style-audit
- 后置阶段:将发现存储到Memory MCP,并添加WHO/WHEN/PROJECT/WHY标签
- 反馈循环:学习成果反馈到dogfooding-system以持续改进
Complete Guide
完整指南
Truth Scoring System
真实度评分系统
View Truth Metrics
查看真实度指标
Display comprehensive quality and reliability metrics for your codebase and agent tasks.
Basic Usage:
bash
undefined显示代码库和Agent任务的全面质量与可靠性指标。
基础用法:
bash
undefinedView current truth scores (default: table format)
查看当前真实度评分(默认:表格格式)
npx claude-flow@alpha truth
npx claude-flow@alpha truth
View scores for specific time period
查看特定时间段的评分
npx claude-flow@alpha truth --period 7d
npx claude-flow@alpha truth --period 7d
View scores for specific agent
查看特定Agent的评分
npx claude-flow@alpha truth --agent coder --period 24h
npx claude-flow@alpha truth --agent coder --period 24h
Find files/tasks below threshold
查找低于阈值的文件/任务
npx claude-flow@alpha truth --threshold 0.8
**Output Formats:**
```bashnpx claude-flow@alpha truth --threshold 0.8
**输出格式:**
```bashTable format (default)
表格格式(默认)
npx claude-flow@alpha truth --format table
npx claude-flow@alpha truth --format table
JSON for programmatic access
JSON格式(用于程序化访问)
npx claude-flow@alpha truth --format json
npx claude-flow@alpha truth --format json
CSV for spreadsheet analysis
CSV格式(用于电子表格分析)
npx claude-flow@alpha truth --format csv
npx claude-flow@alpha truth --format csv
HTML report with visualizations
HTML报告(带可视化)
npx claude-flow@alpha truth --format html --export report.html
**Real-time Monitoring:**
```bashnpx claude-flow@alpha truth --format html --export report.html
**实时监控:**
```bashWatch mode with live updates
监视模式(实时更新)
npx claude-flow@alpha truth --watch
npx claude-flow@alpha truth --watch
Export metrics automatically
自动导出指标
npx claude-flow@alpha truth --export .claude-flow/metrics/truth-$(date +%Y%m%d).json
undefinednpx claude-flow@alpha truth --export .claude-flow/metrics/truth-$(date +%Y%m%d).json
undefinedTruth Score Dashboard
真实度评分仪表盘
Example dashboard output:
📊 Truth Metrics Dashboard
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Overall Truth Score: 0.947 ✅
Trend: ↗️ +2.3% (7d)
Top Performers:
verification-agent 0.982 ⭐
code-analyzer 0.971 ⭐
test-generator 0.958 ✅
Needs Attention:
refactor-agent 0.821 ⚠️
docs-generator 0.794 ⚠️
Recent Tasks:
task-456 0.991 ✅ "Implement auth"
task-455 0.967 ✅ "Add tests"
task-454 0.743 ❌ "Refactor API"示例仪表盘输出:
📊 真实度指标仪表盘
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
整体真实度评分:0.947 ✅
趋势:↗️ +2.3%(7天)
表现最佳项:
verification-agent 0.982 ⭐
code-analyzer 0.971 ⭐
test-generator 0.958 ✅
需关注项:
refactor-agent 0.821 ⚠️
docs-generator 0.794 ⚠️
近期任务:
task-456 0.991 ✅ "实现认证功能"
task-455 0.967 ✅ "添加测试"
task-454 0.743 ❌ "重构API"Metrics Explained
指标说明
Truth Scores (0.0-1.0):
- : Excellent ⭐ (production-ready)
1.0-0.95 - : Good ✅ (acceptable quality)
0.94-0.85 - : Warning ⚠️ (needs attention)
0.84-0.75 - : Critical ❌ (requires immediate action)
<0.75
Trend Indicators:
- ↗️ Improving (positive trend)
- → Stable (consistent performance)
- ↘️ Declining (quality regression detected)
Statistics:
- Mean Score: Average truth score across all measurements
- Median Score: Middle value (less affected by outliers)
- Standard Deviation: Consistency of scores (lower = more consistent)
- Confidence Interval: Statistical reliability of measurements
真实度评分(0.0-1.0):
- :优秀 ⭐(可用于生产环境)
1.0-0.95 - :良好 ✅(质量可接受)
0.94-0.85 - :警告 ⚠️(需关注)
0.84-0.75 - :严重 ❌(需立即处理)
<0.75
趋势指标:
- ↗️ 提升中(正向趋势)
- → 稳定(表现一致)
- ↘️ 下降中(检测到质量退化)
统计数据:
- 平均分:所有测量值的平均真实度评分
- 中位数:中间值(受异常值影响较小)
- 标准差:评分的一致性(值越低越一致)
- 置信区间:测量值的统计可靠性
Verification Checks
验证检查
Run Verification
运行验证
Execute comprehensive verification checks on code, tasks, or agent outputs.
File Verification:
bash
undefined对代码、任务或Agent输出执行全面验证检查。
文件验证:
bash
undefinedVerify single file
验证单个文件
npx claude-flow@alpha verify check --file src/app.js
npx claude-flow@alpha verify check --file src/app.js
Verify directory recursively
递归验证目录
npx claude-flow@alpha verify check --directory src/
npx claude-flow@alpha verify check --directory src/
Verify with auto-fix enabled
启用自动修复的验证
npx claude-flow@alpha verify check --file src/utils.js --auto-fix
npx claude-flow@alpha verify check --file src/utils.js --auto-fix
Verify current working directory
验证当前工作目录
npx claude-flow@alpha verify check
**Task Verification:**
```bashnpx claude-flow@alpha verify check
**任务验证:**
```bashVerify specific task output
验证特定任务输出
npx claude-flow@alpha verify check --task task-123
npx claude-flow@alpha verify check --task task-123
Verify with custom threshold
使用自定义阈值验证
npx claude-flow@alpha verify check --task task-456 --threshold 0.99
npx claude-flow@alpha verify check --task task-456 --threshold 0.99
Verbose output for debugging
调试用详细输出
npx claude-flow@alpha verify check --task task-789 --verbose
**Batch Verification:**
```bashnpx claude-flow@alpha verify check --task task-789 --verbose
**批量验证:**
```bashVerify multiple files in parallel
并行验证多个文件
npx claude-flow@alpha verify batch --files "*.js" --parallel
npx claude-flow@alpha verify batch --files "*.js" --parallel
Verify with pattern matching
使用模式匹配验证
npx claude-flow@alpha verify batch --pattern "src/**/*.ts"
npx claude-flow@alpha verify batch --pattern "src/**/*.ts"
Integration test suite
集成测试套件
npx claude-flow@alpha verify integration --test-suite full
undefinednpx claude-flow@alpha verify integration --test-suite full
undefinedVerification Criteria
验证标准
The verification system evaluates:
-
Code Correctness
- Syntax validation
- Type checking (TypeScript)
- Logic flow analysis
- Error handling completeness
-
Best Practices
- Code style adherence
- SOLID principles
- Design patterns usage
- Modularity and reusability
-
Security
- Vulnerability scanning
- Secret detection
- Input validation
- Authentication/authorization checks
-
Performance
- Algorithmic complexity
- Memory usage patterns
- Database query optimization
- Bundle size impact
-
Documentation
- JSDoc/TypeDoc completeness
- README accuracy
- API documentation
- Code comments quality
验证系统评估以下维度:
-
代码正确性
- 语法验证
- 类型检查(TypeScript)
- 逻辑流分析
- 错误处理完整性
-
最佳实践
- 代码风格遵循度
- SOLID原则
- 设计模式使用
- 模块化与复用性
-
安全性
- 漏洞扫描
- 密钥检测
- 输入验证
- 认证/授权检查
-
性能
- 算法复杂度
- 内存使用模式
- 数据库查询优化
- 打包体积影响
-
文档
- JSDoc/TypeDoc完整性
- README准确性
- API文档
- 代码注释质量
JSON Output for CI/CD
用于CI/CD的JSON输出
bash
undefinedbash
undefinedGet structured JSON output
获取结构化JSON输出
npx claude-flow@alpha verify check --json > verification.json
npx claude-flow@alpha verify check --json > verification.json
Example JSON structure:
示例JSON结构:
{
"overallScore": 0.947,
"passed": true,
"threshold": 0.95,
"checks": [
{
"name": "code-correctness",
"score": 0.98,
"passed": true
},
{
"name": "security",
"score": 0.91,
"passed": false,
"issues": [...]
}
]
}
undefined{
"overallScore": 0.947,
"passed": true,
"threshold": 0.95,
"checks": [
{
"name": "code-correctness",
"score": 0.98,
"passed": true
},
{
"name": "security",
"score": 0.91,
"passed": false,
"issues": [...]
}
]
}
undefinedAutomatic Rollback
自动回滚
Rollback Failed Changes
回滚失败的变更
Automatically revert changes that fail verification checks.
Basic Rollback:
bash
undefined自动回滚未通过验证检查的变更。
基础回滚:
bash
undefinedRollback to last known good state
回滚到上一个已知良好状态
npx claude-flow@alpha verify rollback --last-good
npx claude-flow@alpha verify rollback --last-good
Rollback to specific commit
回滚到特定提交
npx claude-flow@alpha verify rollback --to-commit abc123
npx claude-flow@alpha verify rollback --to-commit abc123
Interactive rollback with preview
带预览的交互式回滚
npx claude-flow@alpha verify rollback --interactive
**Smart Rollback:**
```bashnpx claude-flow@alpha verify rollback --interactive
**智能回滚:**
```bashRollback only failed files (preserve good changes)
仅回滚失败的文件(保留良好变更)
npx claude-flow@alpha verify rollback --selective
npx claude-flow@alpha verify rollback --selective
Rollback with automatic backup
自动备份后回滚
npx claude-flow@alpha verify rollback --backup-first
npx claude-flow@alpha verify rollback --backup-first
Dry-run mode (preview without executing)
试运行模式(仅预览不执行)
npx claude-flow@alpha verify rollback --dry-run
**Rollback Performance:**
- Git-based rollback: <1 second
- Selective file rollback: <500ms
- Backup creation: Automatic before rollbacknpx claude-flow@alpha verify rollback --dry-run
**回滚性能:**
- 基于Git的回滚:<1秒
- 选择性文件回滚:<500ms
- 备份创建:回滚前自动执行Verification Reports
验证报告
Generate Reports
生成报告
Create detailed verification reports with metrics and visualizations.
Report Formats:
bash
undefined创建包含指标与可视化的详细验证报告。
报告格式:
bash
undefinedJSON report
JSON报告
npx claude-flow@alpha verify report --format json
npx claude-flow@alpha verify report --format json
HTML report with charts
带图表的HTML报告
npx claude-flow@alpha verify report --export metrics.html --format html
npx claude-flow@alpha verify report --export metrics.html --format html
CSV for data analysis
用于数据分析的CSV
npx claude-flow@alpha verify report --format csv --export metrics.csv
npx claude-flow@alpha verify report --format csv --export metrics.csv
Markdown summary
Markdown摘要
npx claude-flow@alpha verify report --format markdown
**Time-based Reports:**
```bashnpx claude-flow@alpha verify report --format markdown
**基于时间的报告:**
```bashLast 24 hours
最近24小时
npx claude-flow@alpha verify report --period 24h
npx claude-flow@alpha verify report --period 24h
Last 7 days
最近7天
npx claude-flow@alpha verify report --period 7d
npx claude-flow@alpha verify report --period 7d
Last 30 days with trends
最近30天(含趋势)
npx claude-flow@alpha verify report --period 30d --include-trends
npx claude-flow@alpha verify report --period 30d --include-trends
Custom date range
自定义日期范围
npx claude-flow@alpha verify report --from 2025-01-01 --to 2025-01-31
**Report Content:**
- Overall truth scores
- Per-agent performance metrics
- Task completion quality
- Verification pass/fail rates
- Rollback frequency
- Quality improvement trends
- Statistical confidence intervalsnpx claude-flow@alpha verify report --from 2025-01-01 --to 2025-01-31
**报告内容:**
- 整体真实度评分
- 各Agent性能指标
- 任务完成质量
- 验证通过率/失败率
- 回滚频率
- 质量改进趋势
- 统计置信区间Interactive Dashboard
交互式仪表盘
Launch Dashboard
启动仪表盘
Run interactive web-based verification dashboard with real-time updates.
bash
undefined运行基于Web的交互式验证仪表盘,支持实时更新。
bash
undefinedLaunch dashboard on default port (3000)
在默认端口(3000)启动仪表盘
npx claude-flow@alpha verify dashboard
npx claude-flow@alpha verify dashboard
Custom port
自定义端口
npx claude-flow@alpha verify dashboard --port 8080
npx claude-flow@alpha verify dashboard --port 8080
Export dashboard data
导出仪表盘数据
npx claude-flow@alpha verify dashboard --export
npx claude-flow@alpha verify dashboard --export
Dashboard with auto-refresh
带自动刷新的仪表盘
npx claude-flow@alpha verify dashboard --refresh 5s
**Dashboard Features:**
- Real-time truth score updates (WebSocket)
- Interactive charts and graphs
- Agent performance comparison
- Task history timeline
- Rollback history viewer
- Export to PDF/HTML
- Filter by time period/agent/scorenpx claude-flow@alpha verify dashboard --refresh 5s
**仪表盘功能:**
- 真实度评分实时更新(WebSocket)
- 交互式图表
- Agent性能对比
- 任务历史时间线
- 回滚历史查看器
- 导出为PDF/HTML
- 按时间段/Agent/评分筛选Configuration
配置
Default Configuration
默认配置
Set verification preferences in :
.claude-flow/config.jsonjson
{
"verification": {
"threshold": 0.95,
"autoRollback": true,
"gitIntegration": true,
"hooks": {
"preCommit": true,
"preTask": true,
"postEdit": true
},
"checks": {
"codeCorrectness": true,
"security": true,
"performance": true,
"documentation": true,
"bestPractices": true
}
},
"truth": {
"defaultFormat": "table",
"defaultPeriod": "24h",
"warningThreshold": 0.85,
"criticalThreshold": 0.75,
"autoExport": {
"enabled": true,
"path": ".claude-flow/metrics/truth-daily.json"
}
}
}在中设置验证偏好:
.claude-flow/config.jsonjson
{
"verification": {
"threshold": 0.95,
"autoRollback": true,
"gitIntegration": true,
"hooks": {
"preCommit": true,
"preTask": true,
"postEdit": true
},
"checks": {
"codeCorrectness": true,
"security": true,
"performance": true,
"documentation": true,
"bestPractices": true
}
},
"truth": {
"defaultFormat": "table",
"defaultPeriod": "24h",
"warningThreshold": 0.85,
"criticalThreshold": 0.75,
"autoExport": {
"enabled": true,
"path": ".claude-flow/metrics/truth-daily.json"
}
}
}Threshold Configuration
阈值配置
Adjust verification strictness:
bash
undefined调整验证严格度:
bash
undefinedStrict mode (99% accuracy required)
严格模式(要求99%准确率)
npx claude-flow@alpha verify check --threshold 0.99
npx claude-flow@alpha verify check --threshold 0.99
Lenient mode (90% acceptable)
宽松模式(90%即可接受)
npx claude-flow@alpha verify check --threshold 0.90
npx claude-flow@alpha verify check --threshold 0.90
Set default threshold
设置默认阈值
npx claude-flow@alpha config set verification.threshold 0.98
**Per-environment thresholds:**
```json
{
"verification": {
"thresholds": {
"production": 0.99,
"staging": 0.95,
"development": 0.90
}
}
}npx claude-flow@alpha config set verification.threshold 0.98
**按环境设置阈值:**
```json
{
"verification": {
"thresholds": {
"production": 0.99,
"staging": 0.95,
"development": 0.90
}
}
}Integration Examples
集成示例
CI/CD Integration
CI/CD集成
GitHub Actions:
yaml
name: Quality Verification
on: [push, pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: npm install
- name: Run Verification
run: |
npx claude-flow@alpha verify check --json > verification.json
- name: Check Truth Score
run: |
score=$(jq '.overallScore' verification.json)
if (( $(echo "$score < 0.95" | bc -l) )); then
echo "Truth score too low: $score"
exit 1
fi
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: verification-report
path: verification.jsonGitLab CI:
yaml
verify:
stage: test
script:
- npx claude-flow@alpha verify check --threshold 0.95 --json > verification.json
- |
score=$(jq '.overallScore' verification.json)
if [ $(echo "$score < 0.95" | bc) -eq 1 ]; then
echo "Verification failed with score: $score"
exit 1
fi
artifacts:
paths:
- verification.json
reports:
junit: verification.jsonGitHub Actions:
yaml
name: Quality Verification
on: [push, pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: npm install
- name: Run Verification
run: |
npx claude-flow@alpha verify check --json > verification.json
- name: Check Truth Score
run: |
score=$(jq '.overallScore' verification.json)
if (( $(echo "$score < 0.95" | bc -l) )); then
echo "Truth score too low: $score"
exit 1
fi
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: verification-report
path: verification.jsonGitLab CI:
yaml
verify:
stage: test
script:
- npx claude-flow@alpha verify check --threshold 0.95 --json > verification.json
- |
score=$(jq '.overallScore' verification.json)
if [ $(echo "$score < 0.95" | bc) -eq 1 ]; then
echo "Verification failed with score: $score"
exit 1
fi
artifacts:
paths:
- verification.json
reports:
junit: verification.jsonSwarm Integration
Swarm集成
Run verification automatically during swarm operations:
bash
undefined在swarm操作期间自动运行验证:
bash
undefinedSwarm with verification enabled
启用验证的Swarm
npx claude-flow@alpha swarm --verify --threshold 0.98
npx claude-flow@alpha swarm --verify --threshold 0.98
Hive Mind with auto-rollback
带自动回滚的Hive Mind
npx claude-flow@alpha hive-mind --verify --rollback-on-fail
npx claude-flow@alpha hive-mind --verify --rollback-on-fail
Training pipeline with verification
带验证的训练流水线
npx claude-flow@alpha train --verify --threshold 0.99
undefinednpx claude-flow@alpha train --verify --threshold 0.99
undefinedPair Programming Integration
结对编程集成
Enable real-time verification during collaborative development:
bash
undefined在协作开发期间启用实时验证:
bash
undefinedPair with verification
带验证的结对编程
npx claude-flow@alpha pair --verify --real-time
npx claude-flow@alpha pair --verify --real-time
Pair with custom threshold
带自定义阈值的结对编程
npx claude-flow@alpha pair --verify --threshold 0.97 --auto-fix
undefinednpx claude-flow@alpha pair --verify --threshold 0.97 --auto-fix
undefinedAdvanced Workflows
高级工作流
Continuous Verification
持续验证
Monitor codebase continuously during development:
bash
undefined在开发期间持续监控代码库:
bash
undefinedWatch directory for changes
监视目录变更
npx claude-flow@alpha verify watch --directory src/
npx claude-flow@alpha verify watch --directory src/
Watch with auto-fix
带自动修复的监视
npx claude-flow@alpha verify watch --directory src/ --auto-fix
npx claude-flow@alpha verify watch --directory src/ --auto-fix
Watch with notifications
带通知的监视
npx claude-flow@alpha verify watch --notify --threshold 0.95
undefinednpx claude-flow@alpha verify watch --notify --threshold 0.95
undefinedMonitoring Integration
监控集成
Send metrics to external monitoring systems:
bash
undefined将指标发送到外部监控系统:
bash
undefinedExport to Prometheus
导出到Prometheus
npx claude-flow@alpha truth --format json |
curl -X POST https://pushgateway.example.com/metrics/job/claude-flow
-d @-
curl -X POST https://pushgateway.example.com/metrics/job/claude-flow
-d @-
npx claude-flow@alpha truth --format json |
curl -X POST https://pushgateway.example.com/metrics/job/claude-flow
-d @-
curl -X POST https://pushgateway.example.com/metrics/job/claude-flow
-d @-
Send to DataDog
发送到DataDog
npx claude-flow@alpha verify report --format json |
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_API_KEY}"
-H "Content-Type: application/json"
-d @-
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_API_KEY}"
-H "Content-Type: application/json"
-d @-
npx claude-flow@alpha verify report --format json |
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_API_KEY}"
-H "Content-Type: application/json"
-d @-
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_API_KEY}"
-H "Content-Type: application/json"
-d @-
Custom webhook
自定义Webhook
npx claude-flow@alpha truth --format json |
curl -X POST https://metrics.example.com/api/truth
-H "Content-Type: application/json"
-d @-
curl -X POST https://metrics.example.com/api/truth
-H "Content-Type: application/json"
-d @-
undefinednpx claude-flow@alpha truth --format json |
curl -X POST https://metrics.example.com/api/truth
-H "Content-Type: application/json"
-d @-
curl -X POST https://metrics.example.com/api/truth
-H "Content-Type: application/json"
-d @-
undefinedPre-commit Hooks
提交前钩子
Automatically verify before commits:
bash
undefined在提交前自动执行验证:
bash
undefinedInstall pre-commit hook
安装提交前钩子
npx claude-flow@alpha verify install-hook --pre-commit
npx claude-flow@alpha verify install-hook --pre-commit
.git/hooks/pre-commit example:
.git/hooks/pre-commit示例:
#!/bin/bash
npx claude-flow@alpha verify check --threshold 0.95 --json > /tmp/verify.json
score=$(jq '.overallScore' /tmp/verify.json)
if (( $(echo "$score < 0.95" | bc -l) )); then
echo "❌ Verification failed with score: $score"
echo "Run 'npx claude-flow@alpha verify check --verbose' for details"
exit 1
fi
echo "✅ Verification passed with score: $score"
undefined#!/bin/bash
npx claude-flow@alpha verify check --threshold 0.95 --json > /tmp/verify.json
score=$(jq '.overallScore' /tmp/verify.json)
if (( $(echo "$score < 0.95" | bc -l) )); then
echo "❌ Verification failed with score: $score"
echo "Run 'npx claude-flow@alpha verify check --verbose' for details"
exit 1
fi
echo "✅ Verification passed with score: $score"
undefinedPerformance Metrics
性能指标
Verification Speed:
- Single file check: <100ms
- Directory scan: <500ms (per 100 files)
- Full codebase analysis: <5s (typical project)
- Truth score calculation: <50ms
Rollback Speed:
- Git-based rollback: <1s
- Selective file rollback: <500ms
- Backup creation: <2s
Dashboard Performance:
- Initial load: <1s
- Real-time updates: <100ms latency (WebSocket)
- Chart rendering: 60 FPS
验证速度:
- 单个文件检查:<100ms
- 目录扫描:<500ms(每100个文件)
- 全代码库分析:<5s(典型项目)
- 真实度评分计算:<50ms
回滚速度:
- 基于Git的回滚:<1s
- 选择性文件回滚:<500ms
- 备份创建:<2s
仪表盘性能:
- 初始加载:<1s
- 实时更新:<100ms延迟(WebSocket)
- 图表渲染:60 FPS
Troubleshooting
故障排除
Common Issues
常见问题
Low Truth Scores:
bash
undefined低真实度评分:
bash
undefinedGet detailed breakdown
获取详细分解
npx claude-flow@alpha truth --verbose --threshold 0.0
npx claude-flow@alpha truth --verbose --threshold 0.0
Check specific criteria
检查特定标准
npx claude-flow@alpha verify check --verbose
npx claude-flow@alpha verify check --verbose
View agent-specific issues
查看特定Agent的问题
npx claude-flow@alpha truth --agent <agent-name> --format json
**Rollback Failures:**
```bashnpx claude-flow@alpha truth --agent <agent-name> --format json
**回滚失败:**
```bashCheck git status
检查Git状态
git status
git status
View rollback history
查看回滚历史
npx claude-flow@alpha verify rollback --history
npx claude-flow@alpha verify rollback --history
Manual rollback
手动回滚
git reset --hard HEAD~1
**Verification Timeouts:**
```bashgit reset --hard HEAD~1
**验证超时:**
```bashIncrease timeout
增加超时时间
npx claude-flow@alpha verify check --timeout 60s
npx claude-flow@alpha verify check --timeout 60s
Verify in batches
批量验证
npx claude-flow@alpha verify batch --batch-size 10
undefinednpx claude-flow@alpha verify batch --batch-size 10
undefinedExit Codes
退出码
Verification commands return standard exit codes:
- : Verification passed (score ≥ threshold)
0 - : Verification failed (score < threshold)
1 - : Error during verification (invalid input, system error)
2
验证命令返回标准退出码:
- :验证通过(评分≥阈值)
0 - :验证失败(评分<阈值)
1 - :验证期间出错(输入无效、系统错误)
2
Related Commands
相关命令
- - Collaborative development with verification
npx claude-flow@alpha pair - - Training with verification feedback
npx claude-flow@alpha train - - Multi-agent coordination with quality checks
npx claude-flow@alpha swarm - - Generate comprehensive project reports
npx claude-flow@alpha report
- - 带验证的协作开发
npx claude-flow@alpha pair - - 带验证反馈的训练
npx claude-flow@alpha train - - 带质量检查的多Agent协调
npx claude-flow@alpha swarm - - 生成全面的项目报告
npx claude-flow@alpha report
Best Practices
最佳实践
- Set Appropriate Thresholds: Use 0.99 for critical code, 0.95 for standard, 0.90 for experimental
- Enable Auto-rollback: Prevent bad code from persisting
- Monitor Trends: Track improvement over time, not just current scores
- Integrate with CI/CD: Make verification part of your pipeline
- Use Watch Mode: Get immediate feedback during development
- Export Metrics: Track quality metrics in your monitoring system
- Review Rollbacks: Understand why changes were rejected
- Train Agents: Use verification feedback to improve agent performance
- 设置合适的阈值:关键代码使用0.99,标准代码使用0.95,实验性代码使用0.90
- 启用自动回滚:防止低质量代码留存
- 监控趋势:跟踪长期质量改进,而非仅关注当前评分
- 与CI/CD集成:让验证成为流水线的一部分
- 使用监视模式:在开发期间获得即时反馈
- 导出指标:在监控系统中跟踪质量指标
- 审查回滚记录:理解变更被拒绝的原因
- 训练Agent:使用验证反馈提升Agent性能
Additional Resources
额外资源
- Truth Scoring Algorithm: See
/docs/truth-scoring.md - Verification Criteria: See
/docs/verification-criteria.md - Integration Examples: See
/examples/verification/ - API Reference: See
/docs/api/verification.md
- 真实度评分算法:查看
/docs/truth-scoring.md - 验证标准:查看
/docs/verification-criteria.md - 集成示例:查看
/examples/verification/ - API参考:查看
/docs/api/verification.md
Core Principles
核心原则
Verification and Quality Assurance operates on 3 fundamental principles:
验证与质量保证基于3个基本原则:
Principle 1: Quantified Quality Through Truth Scoring
原则1:通过真实度评分实现量化质量
Quality is measurable through statistical reliability metrics that provide objective assessment of code correctness and agent performance.
In practice:
- Truth scores (0.0-1.0 scale) quantify code quality, agent reliability, and task completion accuracy
- Multiple verification perspectives (static analysis, dynamic testing, security scanning) contribute to composite scores
- Statistical confidence intervals indicate reliability of measurements rather than single-point estimates
- Trend analysis tracks quality improvement or degradation over time, not just current state
质量可通过统计可靠性指标衡量,客观评估代码正确性与Agent性能。
实践中:
- 真实度评分(0.0-1.0范围)量化代码质量、Agent可靠性与任务完成准确性
- 多种验证视角(静态分析、动态测试、安全扫描)共同构成综合评分
- 统计置信区间体现测量的可靠性,而非单一估计值
- 趋势分析跟踪质量随时间的改进或退化,而非仅关注当前状态
Principle 2: Automated Quality Gates with Instant Rollback
原则2:带即时回滚的自动化质量闸门
Quality thresholds should be enforced automatically with immediate reversion of changes that fail verification rather than allowing bad code to persist.
In practice:
- Default 0.95 truth score threshold blocks merges of code below quality standards
- Git-based rollback (<1 second) instantly reverts failed changes to last known good state
- Selective rollback preserves good changes while reverting only failed files
- Pre-commit hooks prevent low-quality code from entering version control
应自动执行质量阈值,对未通过验证的变更立即回滚,而非允许低质量代码留存。
实践中:
- 默认0.95真实度评分阈值阻止低于质量标准的代码合并
- 基于Git的回滚(<1秒)立即将失败变更恢复到上一个已知良好状态
- 选择性回滚留存良好变更,仅回滚失败文件
- 提交前钩子防止低质量代码进入版本控制
Principle 3: Continuous Quality Monitoring with Real-Time Feedback
原则3:带实时反馈的持续质量监控
Quality verification is not a one-time gate but a continuous process providing real-time feedback during development.
In practice:
- Watch mode monitors directories for changes and runs verification automatically
- Live dashboards display truth scores, verification status, and quality trends with WebSocket updates
- Integration with CI/CD pipelines ensures every commit undergoes comprehensive verification
- Export capabilities send metrics to external monitoring systems for alerting and long-term trend analysis
质量验证不是一次性闸门,而是在开发期间提供实时反馈的持续过程。
实践中:
- 监视模式监控目录变更并自动运行验证
- 实时仪表盘通过WebSocket更新显示真实度评分、验证状态与质量趋势
- 与CI/CD流水线集成确保每个提交都经过全面验证
- 导出功能将指标发送到外部监控系统,用于告警与长期趋势分析
Common Anti-Patterns
常见反模式
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Manual-Only Verification | Relying on developers to remember to run verification checks before committing | Install pre-commit hooks that automatically verify changes; integrate verification into CI/CD pipeline |
| Ignoring Low Scores | Seeing truth scores below threshold but merging anyway due to deadlines or "it looks fine" | Enforce quality gates strictly; use automatic rollback for failed verification; track exceptions with explicit justification |
| One-Dimensional Quality Metrics | Focusing only on test coverage or only on linting while ignoring security, performance, or documentation | Use comprehensive verification criteria covering correctness, security, performance, best practices, and documentation |
| Late-Stage Verification | Running verification only at PR submission, creating merge delays and context loss | Enable watch mode during development for immediate feedback; run verification continuously, not just at checkpoints |
| Ignoring Quality Trends | Focusing only on current scores without noticing gradual quality degradation | Track trends over time; set alerts for declining quality metrics; review quality reports regularly |
| Overly Lenient Thresholds | Setting thresholds too low (e.g., 0.75) allowing low-quality code to pass | Use strict thresholds (0.95-0.99) for production code; adjust thresholds based on criticality and risk tolerance |
| 反模式 | 问题 | 解决方案 |
|---|---|---|
| 仅手动验证 | 依赖开发者记住在提交前运行验证 | 安装自动验证变更的提交前钩子;将验证集成到CI/CD流水线 |
| 忽略低评分 | 因截止日期或“看起来没问题”而合并低于阈值的代码 | 严格执行质量闸门;对失败验证使用自动回滚;对例外情况记录明确理由 |
| 单一维度质量指标 | 仅关注测试覆盖率或仅关注代码检查,忽略安全性、性能或文档 | 使用涵盖正确性、安全性、性能、最佳实践与文档的全面验证标准 |
| 后期验证 | 仅在PR提交时运行验证,导致合并延迟与上下文丢失 | 在开发期间启用监视模式获取即时反馈;持续运行验证,而非仅在检查点执行 |
| 忽略质量趋势 | 仅关注当前评分,未注意到质量的逐渐退化 | 跟踪长期趋势;为质量指标下降设置告警;定期审查质量报告 |
| 阈值过于宽松 | 设置过低的阈值(如0.75)允许低质量代码通过 | 生产代码使用严格阈值(0.95-0.99);根据重要性与风险容忍度调整阈值 |
Conclusion
结论
Verification and Quality Assurance with truth scoring and automatic rollback transforms code quality from a subjective judgment into an objective, measurable, and enforceable standard. By quantifying quality through statistical reliability metrics and automatically blocking or reverting changes that fall below thresholds, this skill ensures that only high-quality code enters the codebase while providing developers with clear, actionable feedback for improvement.
Use this skill as a continuous quality monitoring system throughout the development lifecycle, not just at release gates. The combination of truth scoring for quantified quality assessment, comprehensive verification checks across multiple dimensions, and instant rollback for failed changes creates a safety net that catches quality issues early while maintaining development velocity. The real-time feedback through watch mode and live dashboards enables developers to fix issues immediately rather than discovering them days later during code review.
The integration with CI/CD pipelines, pre-commit hooks, and external monitoring systems means verification becomes an automatic part of the development workflow rather than a manual step that gets skipped under pressure. When combined with functionality-audit for execution verification, theater-detection for placeholder elimination, and code-review for human oversight, this skill completes a comprehensive quality ecosystem that delivers production-ready code with measurable confidence in its correctness, security, and reliability.
基于真实度评分与自动回滚的验证与质量保证,将代码质量从主观判断转变为客观、可测量且可执行的标准。通过统计可靠性指标量化质量,并自动阻止或回滚低于阈值的变更,该技能确保只有高质量代码进入代码库,同时为开发者提供清晰、可操作的改进反馈。
将此技能作为开发生命周期中的持续质量监控系统,而非仅在发布闸门使用。真实度评分用于量化质量评估、多维度全面验证检查、失败变更即时回滚的组合,构建了一个安全网,可尽早发现质量问题,同时保持开发速度。通过监视模式与实时仪表盘提供的实时反馈,开发者可立即修复问题,而非在数天后的代码审查中才发现。
与CI/CD流水线、提交前钩子和外部监控系统的集成,使验证成为开发工作流的自动环节,而非在压力下被跳过的手动步骤。与用于执行验证的functionality-audit、用于占位实现消除的theater-detection和用于人工监督的code-review结合使用时,该技能构成了一个全面的质量生态系统,可交付具备可测量正确性、安全性与可靠性的生产就绪代码。