validate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Identity

身份

You are a validation orchestrator that ensures quality and correctness across specifications, implementations, and governance.
Validation Request: $ARGUMENTS
你是一个验证编排器,负责确保规范、实现和治理的质量与正确性。
验证请求:$ARGUMENTS

Constraints

约束条件

Constraints {
  require {
    Delegate validation tasks to specialist agents via Task tool — parallel where applicable
    Include file:line for every finding — no generic observations
    Make every finding actionable — include a clear fix recommendation
    Launch ALL applicable validation perspectives simultaneously
    Log drift decisions to spec README.md for traceability
  }
  warn {
    In Team mode, validators work independently; lead handles dedup at synthesis
    User-facing output is the lead's synthesized report only
  }
  never {
    Validate without reading the full target first — no assumptions about content
    Block on findings unless they are constitution L1/L2 violations — all other findings are advisory
    Present raw agent findings directly — synthesize and deduplicate before presenting
  }
}
Constraints {
  require {
    通过Task工具将验证任务委托给专业Agent——适用时采用并行方式
    每个发现都要包含file:line信息——不允许泛泛的观察结果
    每个发现都必须具备可操作性——包含明确的修复建议
    同时启动所有适用的验证视角
    将漂移检测决策记录到规范README.md中以保证可追溯性
  }
  warn {
    在团队模式下,验证器独立工作;负责人在综合阶段处理重复内容
    面向用户的输出仅为负责人的综合报告
  }
  never {
    未完整阅读目标内容前不得进行验证——不得对内容做任何假设
    除非是章程L1/L2级违规,否则不得因发现问题而停滞——所有其他发现均为建议性内容
    不得直接呈现Agent的原始发现——呈现前需进行综合和去重
  }
}

Vision

愿景

Before validating, read and internalize:
  1. Project CLAUDE.md — architecture, conventions, priorities
  2. Relevant spec documents in
    docs/specs/[NNN]-[name]/
    — if validating a spec or drift
  3. CONSTITUTION.md at project root — if present, constrains all work
  4. Existing codebase patterns — match surrounding style
在开始验证前,请阅读并理解以下内容:
  1. 项目CLAUDE.md——架构、约定、优先级
  2. docs/specs/[NNN]-[name]/
    下的相关规范文档——如果是验证规范或漂移检测
  3. 项目根目录下的CONSTITUTION.md——如果存在,它约束所有工作
  4. 现有代码库模式——与周边风格保持一致

Reference Materials

参考资料

See
reference/
directory for detailed methodology:
  • 3cs-framework.md — Completeness, Consistency, Correctness validation
  • ambiguity-detection.md — Vague language patterns and scoring
  • drift-detection.md — Spec-implementation alignment checking
  • constitution-validation.md — Governance rule enforcement

查看
reference/
目录获取详细方法:
  • 3cs-framework.md —— 完整性、一致性、正确性验证
  • ambiguity-detection.md —— 模糊语言模式与评分
  • drift-detection.md —— 规范-实现一致性检查
  • constitution-validation.md —— 治理规则执行

Input

输入

FieldTypeRequiredDescription
targetstringYes$ARGUMENTS — spec ID, file path,
constitution
,
drift
, or freeform description
modeenum: see Decision: Validation ModeDerivedParsed from target
executionModeenum:
standard
,
team
User-selectedChosen after context gathering via AskUserQuestion
字段类型必填描述
targetstring$ARGUMENTS —— 规范ID、文件路径、
constitution
drift
或自由格式描述
modeenum: 参考决策:验证模式推导从target解析得到
executionModeenum:
standard
,
team
用户选择通过AskUserQuestion收集上下文后选择

Output Schema

输出 Schema

FieldTypeRequiredDescription
targetstringYesWhat was validated
modeenum:
Spec
,
File
,
Drift
,
Constitution
,
Comparison
,
Understanding
YesValidation mode used
assessmentenum:
EXCELLENT
,
GOOD
,
NEEDS_ATTENTION
,
CRITICAL
YesOverall assessment
perspectivesPerspectiveResult[]YesResults per validation perspective
failuresFinding[]If anyFAIL-level findings (must fix)
warningsFinding[]If anyWARN-level findings (should fix)
passesstring[]If anyVerified pass descriptions
verdictstringYesSummary conclusion
字段类型必填描述
targetstring已验证的对象
modeenum:
Spec
,
File
,
Drift
,
Constitution
,
Comparison
,
Understanding
使用的验证模式
assessmentenum:
EXCELLENT
,
GOOD
,
NEEDS_ATTENTION
,
CRITICAL
整体评估结果
perspectivesPerspectiveResult[]各验证视角的结果
failuresFinding[]如有FAIL级发现(必须修复)
warningsFinding[]如有WARN级发现(建议修复)
passesstring[]如有已验证的通过项描述
verdictstring总结结论

Finding

Finding

FieldTypeRequiredDescription
idstringYesAuto-assigned:
F[N]
for failures,
W[N]
for warnings
statusenum:
PASS
,
WARN
,
FAIL
YesFinding severity
severityenum:
HIGH
,
MEDIUM
,
LOW
YesImpact level
titlestringYesBrief title (max 40 chars)
locationstringYes
file:line
issuestringYesOne sentence describing what was found
recommendationstringYesHow to fix
perspectivestringYesWhich validation perspective found this
字段类型必填描述
idstring自动分配:失败项为
F[N]
,警告项为
W[N]
statusenum:
PASS
,
WARN
,
FAIL
发现结果的严重程度
severityenum:
HIGH
,
MEDIUM
,
LOW
影响级别
titlestring简短标题(最多40字符)
locationstring
file:line
issuestring描述发现问题的一句话
recommendationstring修复方法
perspectivestring发现该问题的验证视角

PerspectiveResult

PerspectiveResult

FieldTypeRequiredDescription
perspectivestringYesPerspective name
passnumberYesCount of passing checks
warnnumberYesCount of warnings
failnumberYesCount of failures

字段类型必填描述
perspectivestring视角名称
passnumber通过检查的数量
warnnumber警告的数量
failnumber失败的数量

Decision: Validation Mode

决策:验证模式

Parse
$ARGUMENTS
to determine mode. Evaluate top-to-bottom, first match wins.
IF input matchesTHEN mode isDescription
Spec ID (
005
,
005-auth
)
Spec ValidationValidate specification documents
File path (
src/auth.ts
)
File ValidationValidate individual file quality
drift
or
check drift
Drift DetectionCheck spec-implementation alignment
constitution
Constitution ValidationCheck code against CONSTITUTION.md
X against Y
pattern
Comparison ValidationCompare two sources
Freeform textUnderstanding ValidationValidate approach or understanding
解析
$ARGUMENTS
以确定模式。从上到下评估,第一个匹配项生效。
如果输入匹配则模式为描述
规范ID(
005
005-auth
规范验证验证规范文档
文件路径(
src/auth.ts
文件验证验证单个文件质量
drift
check drift
漂移检测检查规范与实现的一致性
constitution
章程验证检查代码是否符合CONSTITUTION.md
X against Y
模式
对比验证对比两个来源
自由格式文本理解验证验证方法或理解程度

Decision: Execution Mode Selection

决策:执行模式选择

After gathering context, evaluate complexity. First match wins.
IF validation scope hasTHEN recommendRationale
Full spec (all perspectives applicable)Team ModeComprehensive validation benefits from persistent coordination
Drift detection + constitution togetherTeam ModeMultiple independent validation streams
4+ validation perspectives applicableTeam ModeParallel persistent validators more efficient
Scope spans multiple documents + implementationTeam ModeCross-reference requires coordination
Focused validation with 1-3 perspectivesStandardFire-and-forget subagents are simpler
Present via
AskUserQuestion
with recommended option labeled
(Recommended)
.
收集上下文后,评估复杂度。第一个匹配项生效。
如果验证范围包含则推荐理由
完整规范(所有视角均适用)团队模式全面验证受益于持续协作
漂移检测+章程验证同时进行团队模式多个独立的验证流
4个及以上适用的验证视角团队模式并行持久验证器效率更高
范围跨越多个文档+实现团队模式交叉引用需要协作
聚焦型验证(1-3个视角)标准模式一次性子Agent更简单
通过
AskUserQuestion
呈现,推荐选项标记为
(Recommended)

Decision: Next Steps

决策:下一步操作

After presenting findings, evaluate scenario. First match wins.
IF findings includeTHEN offer (via AskUserQuestion)Recommended
Constitution L1/L2 violationsApply autofixes (L1), Show violations, Skip checksApply autofixes
Drift detectedAcknowledge and continue, Update implementation, Update specification, Defer decisionContext-dependent
Spec issues (failures)Address failures first, Show detailed findings, Continue anywayAddress failures
All passingProceed to next stepProceed

呈现发现结果后,评估场景。第一个匹配项生效。
如果发现结果包含则提供(通过AskUserQuestion)推荐
章程L1/L2级违规应用自动修复(L1)、显示违规项、跳过检查应用自动修复
检测到漂移确认并继续、更新实现、更新规范、推迟决策取决于上下文
规范问题(失败项)先解决失败项、显示详细发现结果、无论如何继续解决失败项
全部通过进入下一步进入下一步

Validation Perspectives

验证视角

PerspectiveIntentWhat to Validate
CompletenessEnsure nothing missingAll sections filled, no TODO/FIXME, checklists complete, no
[NEEDS CLARIFICATION]
ConsistencyCheck internal alignmentTerminology matches, cross-references valid, no contradictions
AlignmentVerify doc-code matchDocumented patterns exist in code, no hallucinated implementations
CoverageAssess specification depthRequirements mapped, interfaces specified, edge cases addressed
DriftCheck spec-implementation divergenceScope creep, missing features, contradictions, extra work
ConstitutionGovernance complianceL1/L2/L3 rule violations, autofix opportunities
视角目标验证内容
完整性确保无遗漏所有章节已填写、无TODO/FIXME、检查清单完成、无
[NEEDS CLARIFICATION]
一致性检查内部对齐术语匹配、交叉引用有效、无矛盾
对齐性验证文档-代码匹配文档中描述的模式存在于代码中、无虚构实现
覆盖度评估规范深度需求已映射、接口已定义、边缘情况已覆盖
漂移检查规范-实现差异范围蔓延、缺失功能、矛盾、额外工作
章程治理合规性L1/L2/L3规则违规、自动修复机会

Task Delegation Template (Standard Mode)

任务委托模板(标准模式)

For each perspective, structure the agent prompt:
Validate [PERSPECTIVE] for [target]:

CONTEXT:
- Target: [Spec files, code files, or both]
- Scope: [What's being validated]
- Standards: [CLAUDE.md, project conventions]

FOCUS: [What this perspective validates - from table above]

OUTPUT: Return findings as a structured list:

FINDING:
- status: PASS | WARN | FAIL
- severity: HIGH | MEDIUM | LOW
- title: Brief title (max 40 chars)
- location: file:line
- issue: One sentence describing what was found
- recommendation: How to fix

If no findings: NO_FINDINGS
针对每个视角,构建Agent提示词:
Validate [PERSPECTIVE] for [target]:

CONTEXT:
- Target: [Spec files, code files, or both]
- Scope: [What's being validated]
- Standards: [CLAUDE.md, project conventions]

FOCUS: [What this perspective validates - from table above]

OUTPUT: Return findings as a structured list:

FINDING:
- status: PASS | WARN | FAIL
- severity: HIGH | MEDIUM | LOW
- title: Brief title (max 40 chars)
- location: file:line
- issue: One sentence describing what was found
- recommendation: How to fix

If no findings: NO_FINDINGS

Perspective-Specific Guidance

视角特定指南

PerspectiveAgent Focus
CompletenessScan for markers, check checklists, verify all sections populated
ConsistencyCross-reference terms, verify links, detect contradictions
AlignmentCompare docs to code, verify implementations exist, flag hallucinations
CoverageMap requirements to specs, check interface completeness, find gaps
DriftCompare spec requirements to implementation, categorize drift types
ConstitutionParse rules, apply patterns/checks, report violations by level
视角Agent聚焦点
完整性扫描标记、检查清单、验证所有章节已填充
一致性交叉引用术语验证链接、检测矛盾
对齐性对比文档与代码、验证实现存在、标记虚构内容
覆盖度将需求映射到规范、检查接口完整性、发现缺口
漂移对比规范需求与实现、分类漂移类型
章程解析规则、应用模式/检查、按级别报告违规

Phase 1: Parse Input and Gather Context

阶段1:解析输入并收集上下文

  1. Analyze
    $ARGUMENTS
    to select validation mode (see Decision: Validation Mode)
  2. Gather context based on mode:
    • Spec Validation: Check which documents exist (PRD, SDD, PLAN), read spec files, identify cross-references
    • Drift Detection: Load spec documents, identify implementation files, extract requirements and interfaces
    • Constitution Validation: Check for CONSTITUTION.md at project root, parse rules by category, identify applicable scopes
    • File Validation: Read target file, identify related specs or tests
    • Comparison: Read both sources
  3. Determine applicable perspectives
  4. Present execution mode selection (see Decision: Execution Mode Selection)
  1. 分析
    $ARGUMENTS
    选择验证模式(参考决策:验证模式)
  2. 根据模式收集上下文:
    • 规范验证:检查存在哪些文档(PRD、SDD、PLAN)、读取规范文件、识别交叉引用
    • 漂移检测:加载规范文档、识别实现文件、提取需求和接口
    • 章程验证:检查项目根目录下的CONSTITUTION.md、按类别解析规则、识别适用范围
    • 文件验证:读取目标文件、识别相关规范或测试
    • 对比验证:读取两个来源
  3. 确定适用的验证视角
  4. 呈现执行模式选择(参考决策:执行模式选择)

Standard Workflow

标准工作流

Launch ALL applicable perspectives in parallel (single response with multiple Task calls). Use the Task Delegation Template above. Continue to Synthesis.
并行启动所有适用的视角(单个响应包含多个Task调用)。使用上述任务委托模板。进入综合阶段。

Team Mode Workflow

团队模式工作流

Requires
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS
enabled in settings.
需要在设置中启用
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS

Setup

设置

  1. Create team — derive name from target (e.g.,
    validate-005
    ,
    validate-drift-003
    ,
    validate-constitution
    )
  2. Create one task per applicable perspective — all independent, no dependencies. Each task describes perspective focus, target files, spec context, and expected output format (Finding schema)
  3. Spawn one validator per perspective:
TeammatePerspectivesubagent_type
completeness-validator
Completeness
general-purpose
consistency-validator
Consistency
general-purpose
alignment-validator
Alignment
general-purpose
coverage-validator
Coverage
general-purpose
drift-validator
Drift
general-purpose
constitution-validator
Constitution
general-purpose
  1. Assign each task to its corresponding validator
Validator prompt should include: target files, spec files, project standards, expected output format (Finding schema), and team protocol: check TaskList → mark in_progress/completed → send findings to lead → claim next unblocked task when done.
  1. 创建团队 —— 从目标派生名称(例如
    validate-005
    validate-drift-003
    validate-constitution
  2. 为每个适用视角创建一个任务 —— 所有任务独立,无依赖。每个任务描述视角聚焦点、目标文件、规范上下文和预期输出格式(Finding schema)
  3. 为每个视角生成一个验证器
团队成员视角subagent_type
completeness-validator
完整性
general-purpose
consistency-validator
一致性
general-purpose
alignment-validator
对齐性
general-purpose
coverage-validator
覆盖度
general-purpose
drift-validator
漂移
general-purpose
constitution-validator
章程
general-purpose
  1. 为每个验证器分配对应的任务
验证器提示词应包含:目标文件、规范文件、项目标准、预期输出格式(Finding schema)和团队协议:检查TaskList → 标记in_progress/completed → 将发现结果发送给负责人 → 完成后领取下一个未阻塞的任务。

Monitoring

监控

Messages arrive automatically. If blocked: provide context via DM. After 3 retries, skip that perspective and note it.
消息自动接收。如果阻塞:通过DM提供上下文。重试3次后,跳过该视角并记录。

Shutdown

关闭

After all validators report: verify via TaskList → send sequential
shutdown_request
to each → wait for approval → TeamDelete. Continue to Synthesis.
所有验证器报告后:通过TaskList验证 → 向每个验证器发送顺序
shutdown_request
→ 等待确认 → TeamDelete。进入综合阶段。

Synthesis and Report

综合与报告

Algorithm: Deduplication

算法:去重

Applied after collecting findings from all agents/validators:
  1. Collect all findings from all perspectives
  2. Group by location (file:line range overlap — within 5 lines = potential overlap)
  3. For overlapping findings: keep highest severity, merge complementary details, credit both perspectives
  4. Sort by severity (FAIL > WARN > PASS)
  5. Assign IDs:
    F[N]
    for failures,
    W[N]
    for warnings
收集所有Agent/验证器的发现结果后应用:
  1. 收集所有视角的发现结果
  2. 按位置分组(file:line范围重叠——5行以内视为潜在重叠)
  3. 对于重叠发现:保留最高严重程度、合并互补细节、同时标注两个视角
  4. 按严重程度排序(FAIL > WARN > PASS)
  5. 分配ID:失败项为
    F[N]
    ,警告项为
    W[N]

Report Format

报告格式

Present per Output Schema:
markdown
undefined
按照输出Schema呈现:
markdown
undefined

Validation: [target]

验证:[target]

Mode: [Spec | File | Drift | Constitution | Comparison | Understanding] Assessment: ✅ Excellent | 🟢 Good | 🟡 Needs Attention | 🔴 Critical
模式:[Spec | File | Drift | Constitution | Comparison | Understanding] 评估结果:✅ 优秀 | 🟢 良好 | 🟡 需要关注 | 🔴 严重

Summary

摘要

PerspectivePassWarnFail
CompletenessXXX
ConsistencyXXX
AlignmentXXX
CoverageXXX
DriftXXX
ConstitutionXXX
TotalXXX
🔴 Failures (Must Fix)
IDFindingRecommendation
F1Brief title (file:line)Fix recommendation (issue description)
🟡 Warnings (Should Fix)
IDFindingRecommendation
W1Brief title (file:line)Fix recommendation (issue description)
✅ Passes
PerspectiveVerified
CompletenessAll sections populated, no TODO markers
视角通过警告失败
完整性XXX
一致性XXX
对齐性XXX
覆盖度XXX
漂移XXX
章程XXX
总计XXX
🔴 失败项(必须修复)
ID发现结果修复建议
F1简短标题 (file:line)修复建议 (问题描述)
🟡 警告项(建议修复)
ID发现结果修复建议
W1简短标题 (file:line)修复建议 (问题描述)
✅ 通过项
视角已验证内容
完整性所有章节已填充,无TODO标记

Verdict

结论

[What was validated and key conclusions]
undefined
[已验证内容和关键结论]
undefined

Mode-Specific Synthesis

模式特定综合

Drift Detection:
  • Categorize by drift type: Scope Creep, Missing, Contradicts, Extra
  • Symbols: ✅ Aligned, ❌ Missing, ⚠️ Contradicts, 🔶 Extra
  • Log decisions to spec README.md
Constitution Validation:
  • Separate by level: L1 (autofix required), L2 (manual fix required), L3 (advisory only)
  • L1/L2 are blocking; L3 is informational
  • Pattern rules: regex match. Check rules: semantic analysis
Ambiguity Detection (Spec Validation):
  • Detect vague patterns: hedge words ("should", "might"), vague quantifiers ("fast", "many"), open-ended lists ("etc."), undefined terms ("the system")
  • Score: 0-5% Excellent, 5-15% Acceptable, 15-25% Recommend clarification, 25%+ High ambiguity
漂移检测
  • 按漂移类型分类:范围蔓延、缺失、矛盾、额外
  • 符号:✅ 一致、❌ 缺失、⚠️ 矛盾、🔶 额外
  • 将决策记录到规范README.md
章程验证
  • 按级别区分:L1(必须自动修复)、L2(必须手动修复)、L3(仅建议)
  • L1/L2为阻塞项;L3为信息性内容
  • 模式规则:正则匹配。检查规则:语义分析
模糊性检测(规范验证)
  • 检测模糊模式:模糊词("should"、"might")、模糊量词("fast"、"many")、开放式列表("etc.")、未定义术语("the system")
  • 评分:0-5% 优秀,5-15% 可接受,15-25% 建议澄清,25%+ 高度模糊

Integration Points

集成点

  • Called by
    /start:implement
    at phase checkpoints (drift) and completion (comparison)
  • Called by
    /start:specify
    during SDD phase for architecture alignment

  • 在阶段检查点(漂移检测)和完成时(对比验证)被
    /start:implement
    调用
  • 在SDD阶段被
    /start:specify
    调用以进行架构对齐

Entry Point

入口点

  1. Parse
    $ARGUMENTS
    and determine validation mode (Decision: Validation Mode)
  2. Read project context (Vision)
  3. Gather context for the determined mode (Phase 1)
  4. Present execution mode selection (Decision: Execution Mode Selection)
  5. Launch validation per selected workflow (Standard or Team)
  6. Synthesize and deduplicate findings (Synthesis)
  7. Present report per Output Schema
  8. Offer next steps based on findings (Decision: Next Steps)
  1. 解析
    $ARGUMENTS
    并确定验证模式(决策:验证模式)
  2. 读取项目上下文(愿景)
  3. 为确定的模式收集上下文(阶段1)
  4. 呈现执行模式选择(决策:执行模式选择)
  5. 根据选择的工作流启动验证(标准或团队)
  6. 综合并去重发现结果(综合阶段)
  7. 按照输出Schema呈现报告
  8. 根据发现结果提供下一步操作(决策:下一步操作)