综合验证命令,执行构建、类型、Lint、测试、安全检查
Executes a comprehensive code quality pipeline including build, type checking, linting, testing, and security scans.
/plugin marketplace add xiaobei930/claude-code-best-practices/plugin install claude-code-best-practices@claude-code-best-practices一键执行完整验证流程,确保代码质量。适用于提交前、合并前、发布前的最终检查。
设计理念: 将多个验证步骤整合为一个命令,避免遗漏检查项。
| 场景 | 触发时机 |
|---|---|
| 提交前 | /cc-best:dev 完成后,/cc-best:commit 前 |
| 合并前 | PR 准备合并到主分支前 |
| 发布前 | 版本发布前的最终检查 |
| 问题排查 | 快速定位哪个环节有问题 |
┌─────────────────────────────────────────────────────────────────┐
│ /cc-best:verify 验证流程 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Phase 1: 构建检查 │
│ ├─ 检测项目类型(Node/Python/Go/Java/...) │
│ └─ 执行构建命令 │
│ │
│ Phase 2: 类型检查(如适用) │
│ ├─ TypeScript: tsc --noEmit │
│ ├─ Python: mypy / pyright │
│ └─ 其他语言: 对应类型检查工具 │
│ │
│ Phase 3: Lint 检查 │
│ ├─ ESLint / Biome (JS/TS) │
│ ├─ Ruff / Flake8 (Python) │
│ └─ 其他语言对应 linter │
│ │
│ Phase 4: 测试套件 │
│ ├─ 单元测试 │
│ ├─ 集成测试 │
│ └─ E2E 测试(如有) │
│ │
│ Phase 5: 安全扫描 │
│ ├─ 依赖漏洞检查 │
│ ├─ 敏感信息检查 │
│ └─ 常见安全模式检查 │
│ │
│ Phase 6: Git 状态检查 │
│ ├─ 未提交变更 │
│ ├─ console.log / print 审计 │
│ └─ TODO/FIXME 审计 │
│ │
└─────────────────────────────────────────────────────────────────┘
# 检测项目类型并执行构建
# Node.js
npm run build || yarn build || pnpm build
# Python
python -m py_compile **/*.py
# Go
go build ./...
# Java
mvn compile || gradle build
通过标准: 构建命令返回 0
# TypeScript
npx tsc --noEmit
# Python (如有配置)
mypy . || pyright .
通过标准: 无类型错误
# JS/TS
npx eslint . || npx biome check .
# Python
ruff check . || flake8 .
通过标准: 无 lint 错误(警告可接受)
# Node.js
npm test || yarn test || pnpm test
# Python
pytest
# Go
go test ./...
# Java
mvn test || gradle test
通过标准: 所有测试通过
# Node.js 依赖检查
npm audit --audit-level=high
# Python 依赖检查
pip-audit || safety check
# 敏感信息检查
grep -r "API_KEY\|SECRET\|PASSWORD" --include="*.ts" --include="*.js" --include="*.py" || true
通过标准: 无高危漏洞,无硬编码敏感信息
# 检查未提交变更
git status --porcelain
# console.log 审计
grep -rn "console\.log\|console\.debug" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" src/ || true
# TODO/FIXME 审计
grep -rn "TODO\|FIXME" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.py" src/ || true
通过标准: 了解当前状态(不强制失败)
══════════════════════════════════════════════════════════════════
VERIFICATION REPORT
══════════════════════════════════════════════════════════════════
Phase 1: Build Check
────────────────────────────────────────────────────────────────
[PASS] Build completed successfully
Phase 2: Type Check
────────────────────────────────────────────────────────────────
[PASS] No type errors found
Phase 3: Lint Check
────────────────────────────────────────────────────────────────
[PASS] No lint errors (2 warnings)
Phase 4: Test Suite
────────────────────────────────────────────────────────────────
[PASS] 42 tests passed, 0 failed
Phase 5: Security Scan
────────────────────────────────────────────────────────────────
[PASS] No high/critical vulnerabilities
[WARN] 2 moderate vulnerabilities found
Phase 6: Git Status
────────────────────────────────────────────────────────────────
[INFO] 3 files modified, not committed
[WARN] 5 console.log statements found
[INFO] 2 TODO comments found
══════════════════════════════════════════════════════════════════
VERIFICATION: [PASS/FAIL]
══════════════════════════════════════════════════════════════════
Summary:
- Passed: 4/6 phases
- Warnings: 2
- Action Required: [描述需要处理的问题]
| 状态 | 含义 | 后续动作 |
|---|---|---|
[PASS] | 检查通过 | 可继续 |
[WARN] | 有警告但可接受 | 建议处理 |
[FAIL] | 检查失败 | 必须修复 |
[SKIP] | 跳过(工具不存在) | 无 |
[INFO] | 信息提示 | 仅供参考 |
# 完整验证(默认)
/cc-best:verify
# 快速验证(跳过耗时步骤)
/cc-best:verify --quick
# 仅执行: build + type + lint
# 仅测试
/cc-best:verify --test-only
# 仅安全扫描
/cc-best:verify --security-only
检测逻辑:
├─ package.json 存在 → Node.js 项目
├─ pyproject.toml / setup.py 存在 → Python 项目
├─ go.mod 存在 → Go 项目
├─ pom.xml 存在 → Maven 项目
├─ build.gradle 存在 → Gradle 项目
├─ Cargo.toml 存在 → Rust 项目
└─ 其他 → 通用检查
/cc-best:dev (开发完成)
↓
/cc-best:verify (综合验证) ←── 本命令
↓
├─ PASS → /cc-best:qa (功能验收) → /cc-best:commit
└─ FAIL → 修复问题 → 重新 /cc-best:verify
/cc-best:verify/cc-best:verify/cc-best:verify/cc-best:verify项目可在 package.json 或 pyproject.toml 中配置验证命令:
// package.json
{
"scripts": {
"verify:build": "npm run build",
"verify:type": "tsc --noEmit",
"verify:lint": "eslint .",
"verify:test": "vitest run",
"verify:security": "npm audit"
}
}
如果存在 verify:* 脚本,优先使用项目自定义命令。
遵循 rules/output-style.md,采用结构化报告格式。
══════════════════════════════════
VERIFICATION: PASS ✅
══════════════════════════════════
Phase 1 Build: [PASS]
Phase 2 Type: [PASS]
Phase 3 Lint: [PASS] (2 warnings)
Phase 4 Test: [PASS] 42/42
Phase 5 Security: [PASS]
Phase 6 Git: [INFO] 3 files modified
➡️ 下一步: /cc-best:commit 提交代码
══════════════════════════════════
VERIFICATION: FAIL ❌
══════════════════════════════════
Phase 1 Build: [PASS]
Phase 2 Type: [FAIL] 3 errors
Phase 3 Lint: [SKIP]
Phase 4 Test: [SKIP]
Phase 5 Security: [SKIP]
<details>
<summary>错误详情</summary>
src/user.ts:42 - Type 'string' is not assignable to 'number'
...
</details>
➡️ 下一步: 修复类型错误后重新 /cc-best:verify
开始验证前,确认:
验证完成后:
何时使用:
调用方式:
使用 Task 工具调用 security-reviewer agent:
- subagent_type: "cc-best:security-reviewer"
- prompt: "对 [文件/模块] 进行深度安全审查,检查 OWASP Top 10 漏洞"
与 Phase 5 的关系:
| 检查方式 | 特点 |
|---|---|
| Phase 5 自动扫描 | 快速、依赖工具(npm audit 等)、覆盖依赖漏洞 |
| security-reviewer agent | 深度、AI 分析、覆盖代码逻辑漏洞 |
推荐工作流:
/cc-best:verify Phase 5 (自动安全扫描)
↓
发现问题 or 敏感代码?
↓
security-reviewer (深度审查) ←── Agent 补充检查
↓
修复建议 + 风险评估
↓
/cc-best:commit
Skill vs Agent 选择:
| 需求 | 选择 |
|---|---|
| 需要安全检查清单参考 | security skill |
| 需要自动扫描代码安全 | security-reviewer agent |