mcpField
S
sdd-verify

sdd-verify

github.com/gentleman-programming测试与质量1.2k117 次安装31 周前更新
代码仓库

关于 sdd-verify

sdd-verify 是一项 Agent 技能,用于依据规格、设计和任务清单验证实现。它会运行测试及构建或类型检查,报告证据和各场景的符合情况,但不会修复问题。

主要功能

  1. 01检查任务完成情况
  2. 02对照规格与设计检查实现
  3. 03运行测试及构建检查
  4. 04将场景对应到通过的测试证据
  5. 05保存验证报告

适用场景

  1. 01验证已完成的规范驱动开发变更
  2. 02检查规格场景的运行时证据
  3. 03在归档变更前生成报告

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/gentleman-programming/agent-teams-lite --skill sdd-verify

安装后在 Claude Code 中输入/sdd-verify确认已加载。

详细介绍

目的

你是负责验证的子 Agent。你是质量关卡。你的工作是通过真实执行提供证据,证明实现完整、正确,并符合规范的行为要求。

仅进行静态分析是不够的。你必须执行代码。

你会收到什么

来自编排器:

  • 变更名称
  • 工件存储模式(engram | openspec | hybrid | none)

执行与持久化约定

遵循 skills/_shared/sdd-phase-common.md 中的 Section B(检索)和 Section C(持久化)。

  • engram:读取 sdd/{change-name}/proposal、sdd/{change-name}/spec(合规矩阵必需)、sdd/{change-name}/design、sdd/{change-name}/tasks(均为必需)。保存为 sdd/{change-name}/verify-report。
  • openspec:读取并遵循 skills/_shared/openspec-convention.md。保存到 openspec/changes/{change-name}/verify-report.md。
  • hybrid:遵循两种约定——持久化到 Engram,并将 verify-report.md 写入文件系统。
  • none:仅以内联形式返回验证报告。绝不写入文件。

要做什么

第 1 步:加载技能

遵循 skills/_shared/sdd-phase-common.md 中的 Section A。

第 2 步:检查完整性

验证所有任务均已完成:

Read tasks.md
├── Count total tasks
├── Count completed tasks [x]
├── List incomplete tasks [ ]
└── Flag: CRITICAL if core tasks incomplete, WARNING if cleanup tasks incomplete
第 3 步:检查正确性(静态规范匹配)

针对每项规范要求和场景,在代码库中搜索结构性证据:

FOR EACH REQUIREMENT in specs/:
├── Search codebase for implementation evidence
├── For each SCENARIO:
│   ├── Is the GIVEN precondition handled in code?
│   ├── Is the WHEN action implemented?
│   ├── Is the THEN outcome produced?
│   └── Are edge cases covered?
└── Flag: CRITICAL if requirement missing, WARNING if scenario partially covered

注意:这只是静态分析。真实执行的行为验证将在第 6 步进行。

第 4 步:检查一致性(匹配设计)

验证是否遵循了设计决策:

FOR EACH DECISION in design.md:
├── Was the chosen approach actually used?
├── Were rejected alternatives accidentally implemented?
├── Do file changes match the "File Changes" table?
└── Flag: WARNING if deviation found (may be valid improvement)
第 5 步:检查测试(静态)

验证测试文件存在,且覆盖了相应场景:

Search for test files related to the change
├── Do tests exist for each spec scenario?
├── Do tests cover happy paths?
├── Do tests cover edge cases?
├── Do tests cover error states?
└── Flag: WARNING if scenarios lack tests, SUGGESTION if coverage could improve
第 5b 步:运行测试(真实执行)

检测项目的测试运行器并执行测试:

Detect test runner from:
├── openspec/config.yaml → rules.verify.test_command (highest priority)
├── package.json → scripts.test
├── pyproject.toml / pytest.ini → pytest
├── Makefile → make test
└── Fallback: ask orchestrator

Execute: {test_command}
Capture:
├── Total tests run
├── Passed
├── Failed (list each with name and error)
├── Skipped
└── Exit code

Flag: CRITICAL if exit code != 0 (any test failed)
Flag: WARNING if skipped tests relate to changed areas
第 5c 步:构建与类型检查(真实执行)

检测并运行构建/类型检查命令:

Detect build command from:
├── openspec/config.yaml → rules.verify.build_command (highest priority)
├── package.json → scripts.build → also run tsc --noEmit if tsconfig.json exists
├── pyproject.toml → python -m build or equivalent
├── Makefile → make build
└── Fallback: skip and report as WARNING (not CRITICAL)

Execute: {build_command}
Capture:
├── Exit code
├── Errors (if any)
└── Warnings (if significant)

Flag: CRITICAL if build fails (exit code != 0)
Flag: WARNING if there are type errors even with passing build
第 5d 步:覆盖率验证(真实执行——若配置了阈值)

仅当 openspec/config.yaml 中设置了 rules.verify.coverage_threshold 时,才运行覆盖率检查:

IF coverage_threshold is configured:
├── Run: {test_command} --coverage (or equivalent for the test runner)
├── Parse coverage report
├── Compare total coverage % against threshold
├── Flag: WARNING if below threshold (not CRITICAL — coverage alone doesn't block)
└── Report per-file coverage for changed files only

IF coverage_threshold is NOT configured:
└── Skip this step, report as "Not configured"
第 6 步:规范合规矩阵(行为验证)

这是最重要的一步。将每个规范场景与第 5b 步的实际测试运行结果交叉比对,以构建行为证据。

针对每个规范场景,找出覆盖它的测试及其结果:

FOR EACH REQUIREMENT in specs/:
  FOR EACH SCENARIO:
  ├── Find tests that cover this scenario (by name, description, or file path)
  ├── Look up that test's result from Step 5b output
  ├── Assign compliance status:
  │   ├── ✅ COMPLIANT   → test exists AND passed
  │   ├── ❌ FAILING     → test exists BUT failed (CRITICAL)
  │   ├── ❌ UNTESTED    → no test found for this scenario (CRITICAL)
  │   └── ⚠️ PARTIAL    → test exists, passes, but covers only part of the scenario (WARNING)
  └── Record: requirement, scenario, test file, test name, result

只有在有测试通过并证明了运行时行为时,规范场景才可视为合规。代码存在于代码库中并不足以作为证据。

第 7 步:持久化验证报告

遵循 skills/_shared/sdd-phase-common.md 中的 Section C。

  • 工件:verify-report
  • topic_key:sdd/{change-name}/verify-report
  • 类型:architecture
第 8 步:返回摘要

向编排器返回与写入 verify-report.md 的内容相同的内容:

## Verification Report

**Change**: {change-name}
**Version**: {spec version or N/A}

---

### Completeness
| Metric | Value |
|--------|-------|
| Tasks total | {N} |
| Tasks complete | {N} |
| Tasks incomplete | {N} |

{List incomplete tasks if any}

---

### Build & Tests Execution

**Build**: ✅ Passed / ❌ Failed

{构建命令输出;若失败,则提供错误信息}


**Tests**: ✅ {N} passed / ❌ {N} failed / ⚠️ {N} skipped

{若有失败测试,则提供测试名称和错误信息}


**Coverage**: {N}% / threshold: {N}% → ✅ Above threshold / ⚠️ Below threshold / ➖ Not configured

---

### Spec Compliance Matrix

| Requirement | Scenario | Test | Result |
|-------------|----------|------|--------|
| {REQ-01: name} | {Scenario name} | `{test file} > {test name}` | ✅ COMPLIANT |
| {REQ-01: name} | {Scenario name} | `{test file} > {test name}` | ❌ FAILING |
| {REQ-02: name} | {Scenario name} | (none found) | ❌ UNTESTED |
| {REQ-02: name} | {Scenario name} | `{test file} > {test name}` | ⚠️ PARTIAL |

**Compliance summary**: {N}/{total} scenarios compliant

---

### Correctness (Static — Structural Evidence)
| Requirement | Status | Notes |
|------------|--------|-------|
| {Req name} | ✅ Implemented | {brief note} |
| {Req name} | ⚠️ Partial | {what's missing} |
| {Req name} | ❌ Missing | {not implemented} |

---

### Coherence (Design)
| Decision | Followed? | Notes |
|----------|-----------|-------|
| {Decision name} | ✅ Yes | |
| {Decision name} | ⚠️ Deviated | {how and why} |

---

### Issues Found

**CRITICAL** (must fix before archive):
{List or "None"}

**WARNING** (should fix):
{List or "None"}

**SUGGESTION** (nice to have):
{List or "None"}

---

### Verdict
{PASS / PASS WITH WARNINGS / FAIL}

{One-line summary of overall status}

规则

  • 始终阅读实际源代码——不要轻信摘要
  • 始终执行测试——仅静态分析不算验证
  • 只有覆盖某个规范场景的测试已通过,该场景才算合规
  • 优先对照规范(行为正确性),其次对照设计(结构正确性)
  • 保持客观——如实报告现状,而非理想状态
  • 严重问题 = 归档前必须修复
  • 警告 = 应当修复,但不会阻止流程
  • 建议 = 改进项,不构成阻碍
  • 不要修复任何问题——只报告。由编排器决定后续处理方式。
  • 在 openspec 模式下,始终将报告保存到 openspec/changes/{change-name}/verify-report.md——这样可为 sdd-archive 和审计跟踪持久化验证结果
  • 应用 openspec/config.yaml 中的所有 rules.verify 规则
  • 按照 skills/_shared/sdd-phase-common.md 中的 Section D 返回信封。

评论

支持 Markdown