verify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/verify -- 7-Phase Verification Pipeline
/verify -- 七阶段验证流水线
What
概述
Runs a sequential, 7-phase verification pipeline that catches issues at every level --
from compiler errors to subtle antipatterns to formatting drift. Each phase produces
an explicit PASS, WARN, or FAIL with details. "It looks fine" is not a verification
result; a table of statuses is. Critical failures (Phase 1 build, Phase 4 tests)
short-circuit the pipeline because later phases cannot produce meaningful results
on broken code.
The pipeline answers one question: "Is this code ready for review?"
| Phase | Tool | What It Catches | Critical |
|---|---|---|---|
| 1. Build | | Compilation errors, missing references | Yes |
| 2. Diagnostics | | New analyzer warnings, nullability issues | FAIL on new errors |
| 3. Antipatterns | | async void, sync-over-async, | No |
| 4. Tests | | Failing tests, regressions | Yes |
| 5. Security | | Secrets, SQL injection, missing auth, vulnerable packages | FAIL on critical/high |
| 6. Format | | Style drift, formatting inconsistencies | No |
| 7. Diff Review | | Accidental changes, debug leftovers, TODOs | No |
运行一套按顺序执行的七阶段验证流水线,能够从编译器错误到细微的反模式,再到格式偏差等各个层面发现问题。每个阶段都会生成明确的PASS、WARN或FAIL结果及详细信息。“看起来没问题”不是有效的验证结果,验证结果必须是一份状态表格。关键失败(第1阶段构建、第4阶段测试)会中断流水线,因为损坏的代码无法让后续阶段产生有意义的结果。
流水线旨在回答一个核心问题:“这段代码是否已准备好接受评审?”
| 阶段 | 工具 | 检测内容 | 是否为关键阶段 |
|---|---|---|---|
| 1. 构建 | | 编译错误、缺失引用 | 是 |
| 2. 诊断 | | 新增的分析器警告、可空性问题 | 出现新错误时标记为FAIL |
| 3. 反模式检测 | | async void、同步覆盖异步、 | 否 |
| 4. 测试 | | 测试失败、功能退化 | 是 |
| 5. 安全检查 | | 密钥泄露、SQL注入、缺失认证、存在漏洞的包 | 出现严重/高危问题时标记为FAIL |
| 6. 格式校验 | | 代码风格偏差、格式不一致 | 否 |
| 7. 差异审查 | | 意外变更、调试残留代码、TODO标记 | 否 |
When
适用时机
- After completing a feature, bug fix, or major refactor
- Before creating a pull request -- non-negotiable, full pipeline
- After merging upstream changes or updating dependencies
- When the user says "verify", "check everything", "is this ready", "run all checks"
- As the final step before marking a task complete
- 完成功能开发、Bug修复或重大代码重构之后
- 创建拉取请求(PR)之前——必须运行完整流水线
- 合并上游变更或更新依赖之后
- 用户提及“verify”、“check everything”、“is this ready”、“run all checks”时
- 标记任务完成前的最终步骤
Which Phases to Run
应运行哪些阶段
Full pipeline is the default. For scoped changes, run a subset:
| Scenario | Phases | Notes |
|---|---|---|
| Feature complete / Pre-PR / new endpoint | All 7 | No shortcuts |
| Bug fix | 1, 2, 4 | Add a test first if none covers it |
| After refactor | 1, 2, 3, 4 | Correctness focus; add 5-7 if security-sensitive |
| Dependency update | 1, 4, 5 | Build, tests, vulnerability scan |
| Config or test-only change | 1, 4 | Build and test |
| Formatting only | 6 | Format check is sufficient |
When in doubt, run all 7. Extra phases cost minutes; a missed security issue costs
days of incident response. Never cherry-pick phases because a change "looks safe".
默认运行完整流水线。针对范围有限的变更,可运行子集:
| 场景 | 阶段 | 说明 |
|---|---|---|
| 功能开发完成 / 预PR / 新增接口 | 全部7个阶段 | 不可省略任何步骤 |
| Bug修复 | 1、2、4 | 若现有测试未覆盖该Bug,需先添加测试 |
| 重构之后 | 1、2、3、4 | 重点关注正确性;若涉及敏感安全内容,需添加5-7阶段 |
| 依赖更新 | 1、4、5 | 构建、测试、漏洞扫描 |
| 仅配置或测试变更 | 1、4 | 构建和测试即可 |
| 仅格式调整 | 6 | 仅需格式校验 |
若不确定,建议运行全部7个阶段。额外阶段仅需数分钟,但遗漏安全问题可能导致数天的事件响应工作。切勿因“看起来安全”而随意挑选阶段。
How
执行方式
Phase 1: Build (CRITICAL -- short-circuits)
阶段1:构建(关键阶段——失败则中断流水线)
bash
dotnet build --no-restore --verbosity quiet- If the build fails, STOP. Report errors and fix before continuing -- nothing downstream is meaningful on code that does not compile.
- Capture the warning count even on PASS; new warnings are tracked in Phase 2.
- Output: PASS (0 errors) or FAIL (with error list)
bash
dotnet build --no-restore --verbosity quiet- 若构建失败,立即停止。报告错误并修复后再继续——无法编译的代码无法让下游阶段产生有意义的结果。
- 即使构建通过,也要捕获警告数量;新增警告会在阶段2中被追踪。
- 输出结果:PASS(0错误)或FAIL(附带错误列表)
Phase 2: Diagnostics
阶段2:诊断检测
Use the Roslyn MCP tool, scoped to changed files/projects
(full solution for cross-cutting changes). Compare against baseline -- flag only
NEW warnings introduced by the current changes. Common findings: CS8600/CS8602
(nullability), CS0219 (unused variable).
get_diagnosticsOutput: PASS (0 new) / WARN (new warnings) / FAIL (new errors). Treat new
warnings as work -- today's CS8600 is next month's production NullReferenceException.
使用Roslyn MCP的工具,针对变更的文件/项目(跨领域变更则针对整个解决方案)。与基线对比——仅标记当前变更引入的新警告。常见问题:CS8600/CS8602(可空性)、CS0219(未使用变量)。
get_diagnostics输出结果:PASS(无新问题)/ WARN(存在新警告)/ FAIL(存在新错误)。将新警告视为待处理任务——今天的CS8600可能就是下个月生产环境中的NullReferenceException。
Phase 3: Antipattern Detection
阶段3:反模式检测
Use the Roslyn MCP tool on changed files (full project for
broad changes). Catches: , sync-over-async (,
), , / instead
of , broad , string interpolation in logging,
missing , EF read queries without .
detect_antipatternsasync void.Result.GetAwaiter().GetResult()new HttpClient()DateTime.NowUtcNowTimeProvidercatch (Exception)CancellationTokenAsNoTrackingOutput: PASS (0 findings) / WARN (findings) / FAIL (critical antipatterns)
对变更的文件(大范围变更则针对整个项目)使用Roslyn MCP的工具。可检测:、同步覆盖异步(、)、、使用/而非、宽泛的、日志中的字符串插值、缺失、EF查询未使用等。
detect_antipatternsasync void.Result.GetAwaiter().GetResult()new HttpClient()DateTime.NowUtcNowTimeProvidercatch (Exception)CancellationTokenAsNoTracking输出结果:PASS(无发现)/ WARN(存在问题)/ FAIL(存在严重反模式)
Phase 4: Tests (CRITICAL -- short-circuits)
阶段4:测试(关键阶段——失败则中断流水线)
bash
dotnet test --no-build --verbosity quiet- Full suite, or scoped to affected test projects for large solutions.
- Any failing test is a FAIL -- no exceptions. Stop and fix before later phases.
- If no test project exists: SKIP with a recommendation to add tests.
Output: PASS (all green) or FAIL (failing test names + error messages)
bash
dotnet test --no-build --verbosity quiet- 运行完整测试套件,大型解决方案可针对受影响的测试项目运行。
- 任何测试失败均标记为FAIL——无例外情况。停止并修复后再进入后续阶段。
- 若不存在测试项目:标记为SKIP,并建议添加测试。
输出结果:PASS(全部通过)或FAIL(失败测试名称 + 错误信息)
Phase 5: Security Scan
阶段5:安全扫描
bash
dotnet list package --vulnerable --include-transitiveThen review changed files for: hardcoded secrets/connection strings/API keys,
SQL injection (raw SQL without parameterization), missing on
endpoints that need it, permissive CORS, missing input validation, disabled
HTTPS or certificate validation.
[Authorize]Output: PASS / WARN (medium/low findings) / FAIL (critical/high vulnerabilities)
bash
dotnet list package --vulnerable --include-transitive随后检查变更文件是否存在:硬编码密钥/连接字符串/API密钥、SQL注入(未参数化的原生SQL)、需要认证的接口缺失标记、宽松的CORS配置、缺失输入验证、HTTPS或证书验证被禁用等问题。
[Authorize]输出结果:PASS / WARN(中/低危问题)/ FAIL(严重/高危漏洞)
Phase 6: Format Check
阶段6:格式校验
bash
dotnet format --verify-no-changes --verbosity quietReports drift without auto-fixing. To resolve, run and include
the changes in the commit. If no exists, note it as a recommendation.
dotnet format.editorconfigOutput: PASS / WARN (with file list)
bash
dotnet format --verify-no-changes --verbosity quiet报告格式偏差但不自动修复。如需解决,运行并将变更纳入提交。若不存在文件,需记录为改进建议。
dotnet format.editorconfig输出结果:PASS / WARN(附带文件列表)
Phase 7: Diff Review
阶段7:差异审查
Analyze and (staged + unstaged) for:
git diff --statgit diff- Accidental or unrelated file changes (,
.vs/,bin/,obj/, secrets).env - Debug leftovers (,
Console.WriteLinein production paths)#if DEBUG - Unresolved TODO/HACK/FIXME markers
- Scope mismatch -- changes must match the task/PR description
Output: PASS (clean, matches intent) / WARN (with findings)
分析和(已暂存 + 未暂存)内容,检查:
git diff --statgit diff- 意外或无关文件变更(、
.vs/、bin/、obj/、密钥文件).env - 调试残留代码(、生产路径中的
Console.WriteLine)#if DEBUG - 未解决的TODO/HACK/FIXME标记
- 范围不匹配——变更内容必须与任务/PR描述一致
输出结果:PASS(干净且符合预期)/ WARN(存在问题)
Fix-and-Retry Loop
修复重试循环
A single pass rarely produces all-green. The loop is the point:
- IDENTIFY -- which phase failed, and the specific error
- FIX -- make the minimal change that resolves it
- RE-RUN -- from Phase 1 if the fix changed code; otherwise from the failed phase
- REPEAT -- until all phases pass, or an issue needs user input
单次运行很少能全绿通过,循环迭代才是关键:
- 识别——哪个阶段失败,具体错误是什么
- 修复——做出最小化的变更以解决问题
- 重新运行——若修改了代码则从阶段1开始;否则从失败阶段开始
- 重复——直到所有阶段通过,或需要用户输入处理问题
Final Summary
最终总结
undefinedundefinedVerification Results
验证结果
| Phase | Result | Details |
|---|---|---|
| 1. Build | PASS | 0 errors, 0 warnings |
| 2. Diagnostics | PASS | 0 new diagnostics |
| 3. Antipatterns | WARN | 1 missing CancellationToken |
| 4. Tests | PASS | 47 passed, 0 failed |
| 5. Security | PASS | No findings |
| 6. Format | PASS | Clean |
| 7. Diff Review | WARN | 1 TODO marker found |
Verdict: READY FOR REVIEW (with 2 non-blocking warnings)
Verdicts: **READY FOR REVIEW** (all PASS, or only non-blocking WARNs) or
**NEEDS FIXES** (any FAIL, with specific remediation steps). For pre-PR runs,
include the verification report in the PR description.| 阶段 | 结果 | 详情 |
|---|---|---|
| 1. 构建 | PASS | 0错误,0警告 |
| 2. 诊断 | PASS | 0新增诊断问题 |
| 3. 反模式检测 | WARN | 1处缺失CancellationToken |
| 4. 测试 | PASS | 47通过,0失败 |
| 5. 安全检查 | PASS | 无问题 |
| 6. 格式校验 | PASS | 格式规范 |
| 7. 差异审查 | WARN | 发现1个TODO标记 |
结论:已准备好接受评审(存在2个非阻塞警告)
结论分为两种:**已准备好接受评审**(全部通过,或仅存在非阻塞警告)或**需修复问题**(存在任何失败,附带具体修复步骤)。预PR运行时,需将验证报告纳入PR描述中。Example
示例
User: /verify
Claude: Running 7-phase verification pipeline...
Phase 1: Build ............ PASS (0 errors)
Phase 2: Diagnostics ...... PASS (0 new warnings)
Phase 3: Antipatterns ..... WARN
- src/Features/Orders/CreateOrder.cs:42 -- DateTime.Now usage, use TimeProvider
Phase 4: Tests ............ PASS (23 passed, 0 failed, 0 skipped)
Phase 5: Security ......... PASS
Phase 6: Format ........... PASS
Phase 7: Diff Review ...... PASS
Verdict: READY FOR REVIEW (1 non-blocking warning)
Recommendation: Replace DateTime.Now with TimeProvider on line 42 before
merging. Not blocking, but it will fail the antipattern check in CI.用户: /verify
Claude: 正在运行七阶段验证流水线...
阶段1:构建 ............ PASS(0错误)
阶段2:诊断检测 ...... PASS(0新增警告)
阶段3:反模式检测 ..... WARN
- src/Features/Orders/CreateOrder.cs:42 -- 使用了DateTime.Now,建议改用TimeProvider
阶段4:测试 ............ PASS(23通过,0失败,0跳过)
阶段5:安全检查 ......... PASS
阶段6:格式校验 ........... PASS
阶段7:差异审查 ...... PASS
结论:已准备好接受评审(存在1个非阻塞警告)
建议:合并前将第42行的DateTime.Now替换为TimeProvider。该问题不会阻塞PR,但会在CI中触发反模式检测失败。Related
相关命令
- -- Auto-fix build errors when Phase 1 fails
/build-fix - -- Multi-dimensional review once verification passes
/code-review - -- Whole-project graded assessment (beyond this change set)
/health-check
- -- 当阶段1构建失败时自动修复构建错误
/build-fix - -- 验证通过后进行多维度代码评审
/code-review - -- 针对整个项目的分级评估(超出当前变更范围)
/health-check