关于 qe-verification-quality
qe-verification-quality 是用于代码与 Agent 输出质量验证的技能,适合需要自动检查、追踪可靠性并在失败时回滚的开发团队。它结合 Truth Score、统计报告、实时监控和 CI/CD 导出。
主要功能
- 01计算代码、Agent 与任务的 Truth Score
- 02检查正确性、安全性与最佳实践
- 03验证失败时自动回滚
- 04统计趋势与置信区间
- 05支持 JSON、CSV 和 HTML 报告
- 06提供实时仪表板与监控
适用场景
- 01在提交前检查代码质量
- 02在 CI/CD 流程中执行并导出验证结果
- 03持续监控代码变更并自动修复
- 04回滚未通过质量检查的变更
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ proffesor-for-testing/ agentic-qe --skill qe-verification-quality安装后在 Claude Code 中输入/qe-verification-quality确认已加载。
详细介绍
验证与质量保障技能
此技能的功能
此技能提供全面的验证与质量保障系统,通过以下方式确保代码质量和正确性:
- 真实性评分:实时可靠性指标(0.0-1.0),适用于代码、Agent 和任务
- 验证检查:自动验证代码正确性、安全性和最佳实践
- 自动回滚:立即还原未通过验证的更改(默认阈值:0.95)
- 质量指标:通过趋势、置信区间和改进跟踪进行统计分析
- CI/CD 集成:为持续集成流水线提供导出功能
- 实时监控:通过实时仪表板和监视模式持续进行验证
先决条件
- 已安装 Claude Flow(
npx claude-flow@alpha) - Git 仓库(用于回滚功能)
- Node.js 18+(用于仪表板功能)
快速开始
# View current truth scores
npx claude-flow@alpha truth
# Run verification 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
# Rollback last failed verification
npx claude-flow@alpha verify rollback --last-good
完整指南
真实性评分系统
查看真实性指标
显示代码库和 Agent 任务的全面质量与可靠性指标。
基本用法:
# View current truth scores (default: table format)
npx claude-flow@alpha truth
# View scores for specific time period
npx claude-flow@alpha truth --period 7d
# View scores for specific agent
npx claude-flow@alpha truth --agent coder --period 24h
# Find files/tasks below threshold
npx claude-flow@alpha truth --threshold 0.8
输出格式:
# Table format (default)
npx claude-flow@alpha truth --format table
# JSON for programmatic access
npx claude-flow@alpha truth --format json
# CSV for spreadsheet analysis
npx claude-flow@alpha truth --format csv
# HTML report with visualizations
npx claude-flow@alpha truth --format html --export report.html
实时监控:
# Watch mode with live updates
npx claude-flow@alpha truth --watch
# Export metrics automatically
npx claude-flow@alpha truth --export .claude-flow/metrics/truth-$(date +%Y%m%d).json
真实性评分仪表板
仪表板输出示例:
📊 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.0-1.0):
1.0-0.95:优秀 ⭐(可用于生产环境)0.94-0.85:良好 ✅(质量可接受)0.84-0.75:警告 ⚠️(需要关注)<0.75:严重 ❌(需要立即处理)
趋势指示器:
- ↗️ 改进中(趋势为正)
- → 稳定(性能一致)
- ↘️ 下降中(检测到质量回退)
统计数据:
- 平均评分:所有测量结果的平均真实性评分
- 中位数评分:中间值(受异常值影响较小)
- 标准差:评分的一致性(越低 = 越一致)
- 置信区间:测量结果的统计可靠性
验证检查
运行验证
对代码、任务或 Agent 输出执行全面验证检查。
文件验证:
# Verify single file
npx claude-flow@alpha verify check --file src/app.js
# Verify directory recursively
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
# Verify current working directory
npx claude-flow@alpha verify check
任务验证:
# Verify specific task output
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
# Verbose output for debugging
npx claude-flow@alpha verify check --task task-789 --verbose
批量验证:
# Verify multiple files in parallel
npx claude-flow@alpha verify batch --files "*.js" --parallel
# Verify with pattern matching
npx claude-flow@alpha verify batch --pattern "src/**/*.ts"
# Integration test suite
npx claude-flow@alpha verify integration --test-suite full
验证标准
验证系统会评估:
-
代码正确性
- 语法验证
- 类型检查(TypeScript)
- 逻辑流程分析
- 错误处理完整性
-
最佳实践
- 是否遵循代码风格
- SOLID 原则
- 设计模式的使用
- 模块化与可复用性
-
安全性
- 漏洞扫描
- 密钥检测
- 输入验证
- 身份验证/授权检查
-
性能
- 算法复杂度
- 内存使用模式
- 数据库查询优化
- 对打包体积的影响
-
文档
- JSDoc/TypeDoc 完整性
- README 准确性
- API 文档
- 代码注释质量
CI/CD 的 JSON 输出
# Get structured JSON output
npx claude-flow@alpha verify check --json > verification.json
# Example JSON structure:
{
"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": [...]
}
]
}
自动回滚
回滚未通过验证的更改
自动还原未通过验证检查的更改。
基本回滚:
# Rollback to last known good state
npx claude-flow@alpha verify rollback --last-good
# Rollback to specific commit
npx claude-flow@alpha verify rollback --to-commit abc123
# Interactive rollback with preview
npx claude-flow@alpha verify rollback --interactive
智能回滚:
# Rollback only failed files (preserve good changes)
npx claude-flow@alpha verify rollback --selective
# Rollback with automatic backup
npx claude-flow@alpha verify rollback --backup-first
# Dry-run mode (preview without executing)
npx claude-flow@alpha verify rollback --dry-run
回滚性能:
- 基于 Git 的回滚:<1 秒
- 选择性文件回滚:<500ms
- 备份创建:回滚前自动执行
验证报告
生成报告
生成包含指标和可视化内容的详细验证报告。
报告格式:
# JSON report
npx claude-flow@alpha verify report --format json
# HTML report with charts
npx claude-flow@alpha verify report --export metrics.html --format html
# CSV for data analysis
npx claude-flow@alpha verify report --format csv --export metrics.csv
# Markdown summary
npx claude-flow@alpha verify report --format markdown
按时间生成报告:
# Last 24 hours
npx claude-flow@alpha verify report --period 24h
# Last 7 days
npx claude-flow@alpha verify report --period 7d
# Last 30 days with 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
报告内容:
- 总体真实性评分
- 每个 Agent 的性能指标
- 任务完成质量
- 验证通过/失败率
- 回滚频率
- 质量改进趋势
- 统计置信区间
交互式仪表板
启动仪表板
运行支持实时更新的交互式 Web 验证仪表板。
# Launch dashboard on default port (3000)
npx claude-flow@alpha verify dashboard
# Custom port
npx claude-flow@alpha verify dashboard --port 8080
# Export dashboard data
npx claude-flow@alpha verify dashboard --export
# Dashboard with auto-refresh
npx claude-flow@alpha verify dashboard --refresh 5s
仪表板功能:
- 实时更新真实性评分(WebSocket)
- 交互式图表和关系图
- Agent 性能对比
- 任务历史时间线
- 回滚历史查看器
- 导出为 PDF/HTML
- 按时间段/Agent/评分筛选
配置
默认配置
在 .claude-flow/config.json 中设置验证偏好:
{
"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"
}
}
}
阈值配置
调整验证严格程度:
# Strict mode (99% accuracy required)
npx claude-flow@alpha verify check --threshold 0.99
# Lenient mode (90% acceptable)
npx claude-flow@alpha verify check --threshold 0.90
# Set default threshold
npx claude-flow@alpha config set verification.threshold 0.98
按环境设置阈值:
{
"verification": {
"thresholds": {
"production": 0.99,
"staging": 0.95,
"development": 0.90
}
}
}
集成示例
CI/CD 集成
GitHub Actions:
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.json
GitLab CI:
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.json
Swarm 集成
在 Swarm 操作期间自动运行验证:
# Swarm with verification enabled
npx claude-flow@alpha swarm --verify --threshold 0.98
# Hive Mind with auto-rollback
npx claude-flow@alpha hive-mind --verify --rollback-on-fail
# Training pipeline with verification
npx claude-flow@alpha train --verify --threshold 0.99
结对编程集成
在协作开发期间启用实时验证:
# Pair with verification
npx claude-flow@alpha pair --verify --real-time
# Pair with custom threshold
npx claude-flow@alpha pair --verify --threshold 0.97 --auto-fix
高级工作流
持续验证
在开发期间持续监控代码库:
# Watch directory for changes
npx claude-flow@alpha verify watch --directory src/
# Watch with 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
监控集成
将指标发送到外部监控系统:
# Export to Prometheus
npx claude-flow@alpha truth --format json | \
curl -X POST https://pushgateway.example.com/metrics/job/claude-flow \
-d @-
# Send to 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 @-
# Custom webhook
npx claude-flow@alpha truth --format json | \
curl -X POST https://metrics.example.com/api/truth \
-H "Content-Type: application/json" \
-d @-
提交前钩子
在提交前自动进行验证:
# Install pre-commit hook
npx claude-flow@alpha verify install-hook --pre-commit
# .git/hooks/pre-commit example:
#!/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"
性能指标
验证速度:
- 单文件检查:<100ms
- 目录扫描:<500ms(每 100 个文件)
- 完整代码库分析:<5s(典型项目)
- 真实度分数计算:<50ms
回滚速度:
- 基于 Git 的回滚:<1s
- 选择性文件回滚:<500ms
- 创建备份:<2s
仪表板性能:
- 初始加载:<1s
- 实时更新:延迟 <100ms(WebSocket)
- 图表渲染:60 FPS
故障排除
常见问题
真实度分数偏低:
# Get detailed breakdown
npx claude-flow@alpha truth --verbose --threshold 0.0
# Check specific criteria
npx claude-flow@alpha verify check --verbose
# View agent-specific issues
npx claude-flow@alpha truth --agent <agent-name> --format json
回滚失败:
# Check git status
git status
# View rollback history
npx claude-flow@alpha verify rollback --history
# Manual rollback
git reset --hard HEAD~1
验证超时:
# Increase timeout
npx claude-flow@alpha verify check --timeout 60s
# Verify in batches
npx claude-flow@alpha verify batch --batch-size 10
退出代码
验证命令返回标准退出代码:
0:验证通过(分数 ≥ 阈值)1:验证失败(分数 < 阈值)2:验证期间出错(输入无效、系统错误)
相关命令
npx claude-flow@alpha pair- 使用验证进行协作开发npx claude-flow@alpha train- 通过验证反馈进行训练npx claude-flow@alpha swarm- 通过质量检查进行多 Agent 协调npx claude-flow@alpha report- 生成全面的项目报告
最佳实践
- 设置合适的阈值:关键代码使用 0.99,标准代码使用 0.95,实验性代码使用 0.90
- 启用自动回滚:防止不良代码持续存在
- 监控趋势:跟踪长期改进情况,而不只是当前分数
- 集成 CI/CD:将验证纳入流水线
- 使用监视模式:在开发期间获得即时反馈
- 导出指标:在监控系统中跟踪质量指标
- 检查回滚:了解更改被拒绝的原因
- 训练 Agent:利用验证反馈提升 Agent 性能
更多资源
- 真实度评分算法:参见
/docs/truth-scoring.md - 验证标准:参见
/docs/verification-criteria.md - 集成示例:参见
/examples/verification/ - API 参考:参见
/docs/api/verification.md
评论
支持 Markdown