doc-req
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedoc-req
doc-req
Purpose
目的
Create Atomic Requirements (REQ) documents - Layer 7 artifact in the SDD workflow that decomposes system requirements into atomic, implementation-ready requirements using REQ v3.0 format.
Layer: 7
Upstream: BRD (Layer 1), PRD (Layer 2), EARS (Layer 3), BDD (Layer 4), ADR (Layer 5), SYS (Layer 6)
Downstream Artifacts: IMPL (Layer 8), CTR (Layer 9), SPEC (Layer 10), Code (Layer 13)
创建**原子需求(REQ)**文档——SDD工作流中的第7层工件,使用REQ v3.0格式将系统需求分解为原子化、可直接用于实现的需求。
层级: 7
上游工件: BRD(第1层)、PRD(第2层)、EARS(第3层)、BDD(第4层)、ADR(第5层)、SYS(第6层)
下游工件: IMPL(第8层)、CTR(第9层)、SPEC(第10层)、Code(第13层)
Prerequisites
前置条件
Upstream Artifact Verification (CRITICAL)
上游工件验证(CRITICAL)
Before creating this document, you MUST:
-
List existing upstream artifacts:bash
ls docs/01_BRD/ docs/02_PRD/ docs/03_EARS/ docs/04_BDD/ docs/05_ADR/ docs/06_SYS/ docs/07_REQ/ 2>/dev/null -
Reference only existing documents in traceability tags
-
Useonly when upstream artifact type genuinely doesn't exist
null -
NEVER use placeholders likeor
BRD-XXXTBD -
Do NOT create missing upstream artifacts - skip functionality instead
Before creating REQ, read:
- Shared Standards:
.claude/skills/doc-flow/SHARED_CONTENT.md - Upstream SYS: Read system requirements driving this REQ
- Template:
ai_dev_flow/07_REQ/REQ-MVP-TEMPLATE.md - Creation Rules:
ai_dev_flow/07_REQ/REQ_CREATION_RULES.md - Validation Rules:
ai_dev_flow/07_REQ/REQ_VALIDATION_RULES.md - Validation Script:
./ai_dev_flow/scripts/validate_req_template.sh
创建本文档前,您必须:
-
列出已有的上游工件:bash
ls docs/01_BRD/ docs/02_PRD/ docs/03_EARS/ docs/04_BDD/ docs/05_ADR/ docs/06_SYS/ docs/07_REQ/ 2>/dev/null -
在可追溯性标签中仅引用已存在的文档
-
仅当对应的上游工件类型确实不存在时,使用
null -
绝不要使用或
BRD-XXX这类占位符TBD -
不要创建缺失的上游工件——跳过相关功能即可
创建REQ前,请阅读:
- 共享标准:
.claude/skills/doc-flow/SHARED_CONTENT.md - 上游SYS文档: 阅读驱动本REQ的系统需求
- 模板:
ai_dev_flow/07_REQ/REQ-MVP-TEMPLATE.md - 创建规则:
ai_dev_flow/07_REQ/REQ_CREATION_RULES.md - 验证规则:
ai_dev_flow/07_REQ/REQ_VALIDATION_RULES.md - 验证脚本:
./ai_dev_flow/scripts/validate_req_template.sh
When to Use This Skill
何时使用本技能
Use when:
doc-req- Have completed BRD through SYS (Layers 1-6)
- Need to decompose system requirements into atomic units
- Preparing for implementation (Layer 8+)
- Achieving >=90% SPEC-readiness score
- You are at Layer 7 of the SDD workflow
在以下场景使用:
doc-req- 已完成从BRD到SYS的所有工件(第1-6层)
- 需要将系统需求分解为原子单元
- 为实现工作做准备(第8层及以上)
- 要达到≥90%的SPEC就绪度评分
- 处于SDD工作流的第7层
Reserved ID Exemption (REQ-00_*)
保留ID豁免(REQ-00_*)
Scope: Documents with reserved ID are FULLY EXEMPT from validation.
000Pattern:
REQ-00_*.mdDocument Types:
- Index documents ()
REQ-00_index.md - Traceability matrix templates ()
REQ-00_TRACEABILITY_MATRIX-TEMPLATE.md - Glossaries, registries, checklists
Rationale: Reserved ID 000 documents are framework infrastructure, not project artifacts requiring traceability or quality gates.
Validation Behavior: Skip all checks when filename matches pattern.
REQ-00_*范围: 保留ID为的文档完全豁免验证。
000模式:
REQ-00_*.md文档类型:
- 索引文档()
REQ-00_index.md - 可追溯性矩阵模板()
REQ-00_TRACEABILITY_MATRIX-TEMPLATE.md - 术语表、注册表、检查清单
理由: 保留ID 000的文档属于框架基础设施,而非需要可追溯性或质量 gates的项目工件。
验证行为: 当文件名匹配模式时,跳过所有检查。
REQ-00_*REQ-Specific Guidance
REQ专属指南
1. REQ v3.0 Format (12 Required Sections)
1. REQ v3.0格式(12个必填章节)
CRITICAL: REQ v3.0 expanded from 7 to 12 sections
Document Control (MANDATORY - First section before all numbered sections)
Core Sections:
- Description: Atomic requirement + SHALL/SHOULD/MAY language + context + scenario
- Functional Requirements: Core capabilities + business rules
- Interface Specifications: Protocol/ABC definitions + DTOs + REST endpoints
- Data Schemas: JSON Schema + Pydantic models + Database schema
- Error Handling Specifications: Exception catalog + error response schema + circuit breaker config
- Configuration Specifications: YAML schema + environment variables + validation
- Quality Attributes: Performance targets (p50/p95/p99) + reliability/security/scalability
- Implementation Guidance: Algorithms/patterns + concurrency/async + dependency injection
- Acceptance Criteria: >=15 measurable criteria covering functional/error/quality/data/integration
- Verification Methods: BDD scenarios + unit/integration/contract/performance tests
- Traceability: Section 7 format with cumulative tags (6 required)
- Change History: Version control table
CRITICAL: REQ v3.0从7个章节扩展到12个章节
文档控制(MANDATORY - 所有编号章节之前的第一个章节)
核心章节:
- 描述: 原子需求 + SHALL/SHOULD/MAY规范语言 + 上下文 + 场景
- 功能需求: 核心能力 + 业务规则
- 接口规范: 协议/ABC定义 + DTO + REST端点
- 数据模式: JSON Schema + Pydantic模型 + 数据库模式
- 错误处理规范: 异常目录 + 错误响应模式 + 断路器配置
- 配置规范: YAML模式 + 环境变量 + 验证规则
- 质量属性: 性能目标(p50/p95/p99) + 可靠性/安全性/可扩展性
- 实现指南: 算法/模式 + 并发/异步 + 依赖注入
- 验收标准: ≥15个可衡量的标准,覆盖功能/错误/质量/数据/集成场景
- 验证方法: BDD场景 + 单元/集成/契约/性能测试
- 可追溯性: 第7层格式,包含累积标签(6个必填)
- 变更历史: 版本控制表格
2. Document Control Requirements (11 Mandatory Fields)
2. 文档控制要求(11个必填字段)
| Field | Format | Example |
|---|---|---|
| Status | Approved/In Review/Draft | Approved |
| Version | Semantic X.Y.Z | 2.0.1 |
| Date Created | ISO 8601 | 2025-11-18 |
| Last Updated | ISO 8601 | 2025-11-19 |
| Author | Name/Role | System Architect |
| Priority | Level (P-level) | High (P2) |
| Category | Type | Functional |
| Source Document | DOC-ID section X.Y.Z | SYS-02 section 3.1.1 |
| Verification Method | Method type | BDD + Integration Test |
| Assigned Team | Team name | IB Integration Team |
| SPEC-Ready Score | Format with emoji | >=90% (Target: >=90%) |
| IMPL-Ready Score | Format with emoji | >=90% (Target: >=90%) |
| Template Version | Must be 3.0 | 3.0 |
| 字段 | 格式 | 示例 |
|---|---|---|
| 状态 | Approved/In Review/Draft | Approved |
| 版本 | 语义化X.Y.Z | 2.0.1 |
| 创建日期 | ISO 8601 | 2025-11-18 |
| 最后更新日期 | ISO 8601 | 2025-11-19 |
| 作者 | 姓名/角色 | System Architect |
| 优先级 | Level(P级别) | High (P2) |
| 分类 | 类型 | Functional |
| 源文档 | DOC-ID章节X.Y.Z | SYS-02 section 3.1.1 |
| 验证方法 | 方法类型 | BDD + Integration Test |
| 分配团队 | 团队名称 | IB Integration Team |
| SPEC就绪度评分 | 带emoji的格式 | >=90% (Target: >=90%) |
| IMPL就绪度评分 | 带emoji的格式 | >=90% (Target: >=90%) |
| 模板版本 | 必须为3.0 | 3.0 |
3. Dual Readiness Scoring (SPEC-Ready + IMPL-Ready)
3. 双重就绪度评分(SPEC-Ready + IMPL-Ready)
MANDATORY: Each REQ must calculate BOTH scores
SPEC-Ready Score Formula:
SPEC-Ready Score = (Completed Sections / 12) * 100%IMPL-Ready Score: Measures readiness for implementation approach documentation
Quality Gate: Both scores >=90% required for layer transition
Status and Ready Score Mapping:
| Ready Score | Required Status |
|---|---|
| >= 90% | Approved |
| 70-89% | In Review |
| < 70% | Draft |
Note: For REQ documents with dual scores, use the LOWER score to determine status.
Example:
markdown
undefinedMANDATORY: 每个REQ必须同时计算两个评分
SPEC就绪度评分公式:
SPEC-Ready Score = (已完成章节数 / 12) * 100%IMPL就绪度评分: 衡量实现方案文档的就绪程度
质量门: 两个评分均需≥90%才能进入下一层级
状态与就绪度评分映射:
| 就绪度评分 | 要求的状态 |
|---|---|
| >= 90% | Approved |
| 70-89% | In Review |
| < 70% | Draft |
注意: 对于有双重评分的REQ文档,使用较低的评分来确定状态。
示例:
markdown
undefinedReadiness Scores
就绪度评分
SPEC-Ready Score: >=95% (Target: >=90%)
IMPL-Ready Score: >=92% (Target: >=90%)
Section Status:
- 1. Description
- 2. Functional Requirements
- 3. Interface Specifications
- 4. Data Schemas
- 5. Error Handling Specifications
- 6. Configuration Specifications
- 7. Quality Attributes
- 8. Implementation Guidance
- 9. Acceptance Criteria
- 10. Verification Methods
- 11. Traceability
- 12. Change History (In Progress)
Readiness: READY for SPEC/IMPL creation
undefinedSPEC-Ready Score: >=95% (Target: >=90%)
IMPL-Ready Score: >=92% (Target: >=90%)
章节状态:
- 1. 描述
- 2. 功能需求
- 3. 接口规范
- 4. 数据模式
- 5. 错误处理规范
- 6. 配置规范
- 7. 质量属性
- 8. 实现指南
- 9. 验收标准
- 10. 验证方法
- 11. 可追溯性
- 12. 变更历史(进行中)
就绪状态: 已准备好创建SPEC/IMPL文档
undefined4. Element ID Format (MANDATORY)
4. 元素ID格式(MANDATORY)
Pattern: (4 segments, dot-separated)
REQ.{DOC_NUM}.{ELEM_TYPE}.{SEQ}| Element Type | Code | Example |
|---|---|---|
| Functional Requirement | 01 | REQ.02.01.01 |
| Dependency | 05 | REQ.02.05.01 |
| Acceptance Criteria | 06 | REQ.02.06.01 |
| Atomic Requirement | 27 | REQ.02.27.01 |
REMOVED PATTERNS - Do NOT use:
- - Use
AC-XXXREQ.NN.06.SS - - Use
FR-XXXREQ.NN.01.SS - - Use
R-XXXREQ.NN.27.SS - - Use
REQ-XXXREQ.NN.27.SS
Reference: - Cross-Reference Link Format
ID_NAMING_STANDARDS.md模式: (4个段,点分隔)
REQ.{DOC_NUM}.{ELEM_TYPE}.{SEQ}| 元素类型 | 编码 | 示例 |
|---|---|---|
| 功能需求 | 01 | REQ.02.01.01 |
| 依赖项 | 05 | REQ.02.05.01 |
| 验收标准 | 06 | REQ.02.06.01 |
| 原子需求 | 27 | REQ.02.27.01 |
已移除的模式 - 请勿使用:
- - 请使用
AC-XXXREQ.NN.06.SS - - 请使用
FR-XXXREQ.NN.01.SS - - 请使用
R-XXXREQ.NN.27.SS - - 请使用
REQ-XXXREQ.NN.27.SS
参考: - 交叉引用链接格式
ID_NAMING_STANDARDS.md5. Atomic Requirement Principles
5. 原子需求原则
- Single Responsibility: Each REQ defines exactly one requirement
- Measurable: Acceptance criteria provide true/false outcomes
- Self-Contained: Understandable without external context
- SPEC-Ready: Contains ALL information for automated SPEC generation (>=90% completeness)
- Modal Language: SHALL (absolute), SHOULD (preferred), MAY (optional)
- 单一职责: 每个REQ仅定义一个需求
- 可衡量: 验收标准需提供明确的真假结果
- 自包含: 无需外部上下文即可理解
- SPEC就绪: 包含自动生成SPEC所需的全部信息(完整性≥90%)
- 模态语言: 使用SHALL(强制)、SHOULD(推荐)、MAY(可选)
6. Domain/Subdomain Organization
6. 领域/子领域组织
Location: within project docs directory
REQ/{domain}/{subdomain}/Domains: (external integrations), (risk management), (data requirements), (ML requirements), (security), etc.
api/risk/data/ml/auth/Format:
REQ-NN_descriptive_slug.mdExample:
REQ-risk-limits-01_position_validation.md存储位置: 项目文档目录下的
REQ/{domain}/{subdomain}/领域: (外部集成)、(风险管理)、(数据需求)、(ML需求)、(安全)等
api/risk/data/ml/auth/格式:
REQ-NN_descriptive_slug.md示例:
REQ-risk-limits-01_position_validation.mdTag Format Convention (By Design)
标签格式约定(设计规范)
The SDD framework uses two distinct notation systems for cross-references:
| Notation | Format | Artifacts | Purpose |
|---|---|---|---|
| Dash | TYPE-NN | ADR, SPEC, CTR | Technical artifacts - references to files/documents |
| Dot | TYPE.NN.TT.SS | BRD, PRD, EARS, BDD, SYS, REQ, IMPL, TASKS | Hierarchical artifacts - references to elements inside documents |
Key Distinction:
- -> Points to the document
@adr: ADR-033ADR-033_risk_limit_enforcement.md - -> Points to element 01.03 inside document
@brd: BRD.17.01.03BRD-017.md
SDD框架使用两种不同的标记系统进行交叉引用:
| 标记法 | 格式 | 适用工件 | 用途 |
|---|---|---|---|
| 短横线 | TYPE-NN | ADR, SPEC, CTR | 技术工件 - 指向文件/文档的引用 |
| 点 | TYPE.NN.TT.SS | BRD, PRD, EARS, BDD, SYS, REQ, IMPL, TASKS | 分层工件 - 指向文档内部元素的引用 |
关键区别:
- -> 指向文档
@adr: ADR-033ADR-033_risk_limit_enforcement.md - -> 指向文档
@brd: BRD.17.01.03内部的元素01.03BRD-017.md
Cumulative Tagging Requirements
累积标签要求
Layer 7 (REQ): Must include tags from Layers 1-6 (BRD, PRD, EARS, BDD, ADR, SYS)
Tag Count: 6 tags (@brd, @prd, @ears, @bdd, @adr, @sys)
Format:
markdown
undefined第7层(REQ): 必须包含第1-6层的标签(BRD、PRD、EARS、BDD、ADR、SYS)
标签数量: 6个标签(@brd, @prd, @ears, @bdd, @adr, @sys)
格式:
markdown
undefinedTraceability
可追溯性
Required Tags (Cumulative Tagging Hierarchy - Layer 7):
markdown
@brd: BRD.01.01.03
@prd: PRD.01.07.02
@ears: EARS.01.25.01
@bdd: BDD.01.14.01
@adr: ADR-033, ADR-045
@sys: SYS.01.01.01, SYS.01.02.07Upstream Sources:
- BRD-01
- PRD-01
- EARS-01
- BDD-01
- ADR-033
- SYS-01
Downstream Artifacts:
- IMPL-NN (to be created) - Implementation approach
- CTR-NN (to be created) - Data contracts
- SPEC-NN (to be created) - Technical specifications
**Element Type Codes for Tags**:
- EARS: Type 25 (formal requirement)
- BDD: Type 14 (scenario)
- SYS: Type 01 (functional), 02 (quality attribute), 26 (system req)必填标签(累积标签层级 - 第7层):
markdown
@brd: BRD.01.01.03
@prd: PRD.01.07.02
@ears: EARS.01.25.01
@bdd: BDD.01.14.01
@adr: ADR-033, ADR-045
@sys: SYS.01.01.01, SYS.01.02.07上游来源:
- BRD-01
- PRD-01
- EARS-01
- BDD-01
- ADR-033
- SYS-01
下游工件:
- IMPL-NN(待创建)- 实现方案
- CTR-NN(待创建)- 数据契约
- SPEC-NN(待创建)- 技术规范
**标签的元素类型编码**:
- EARS: 类型25(正式需求)
- BDD: 类型14(场景)
- SYS: 类型01(功能)、02(质量属性)、26(系统需求)Threshold Registry Integration
阈值注册表集成
Purpose: Prevent magic numbers by referencing centralized threshold registry.
目的: 通过引用集中式阈值注册表避免魔法数字。
When @threshold Tag is Required
何时需要@threshold标签
Use for ALL quantitative values that are:
@threshold- Business-critical (compliance limits, SLAs)
- Configurable (timeout values, rate limits, retry policies)
- Shared across documents (performance targets)
- Quality attribute-related (p50/p95/p99 latencies, throughput limits)
- Error handling configurations (circuit breaker, retry counts)
对于以下所有定量值,使用:
@threshold- 业务关键值(合规限制、SLA)
- 可配置值(超时时间、速率限制、重试策略)
- 跨文档共享的值(性能目标)
- 质量属性相关值(p50/p95/p99延迟、吞吐量限制)
- 错误处理配置(断路器、重试次数)
@threshold Tag Format
@threshold标签格式
markdown
@threshold: PRD.NN.category.subcategory.keyExamples:
@threshold: PRD.035.perf.api.p95_latency@threshold: PRD.035.timeout.circuit_breaker.threshold@threshold: PRD.035.retry.max_attempts@threshold: PRD.035.limit.api.requests_per_second
markdown
@threshold: PRD.NN.category.subcategory.key示例:
@threshold: PRD.035.perf.api.p95_latency@threshold: PRD.035.timeout.circuit_breaker.threshold@threshold: PRD.035.retry.max_attempts@threshold: PRD.035.limit.api.requests_per_second
REQ-Specific Threshold Categories
REQ专属阈值分类
| Category | REQ Usage | Example Key |
|---|---|---|
| Performance acceptance criteria | |
| Circuit breaker, connection configs | |
| Retry policy configurations | |
| Rate limits, resource limits | |
| Memory, CPU constraints | |
| 分类 | REQ用途 | 示例Key |
|---|---|---|
| 性能验收标准 | |
| 断路器、连接配置 | |
| 重试策略配置 | |
| 速率限制、资源限制 | |
| 内存、CPU约束 | |
Magic Number Detection
魔法数字检测
Invalid (hardcoded values):
p95 response time: 200msmax_retries: 3rate_limit: 100 req/s
Valid (registry references):
p95 response time: @threshold: PRD.NN.perf.api.p95_latencymax_retries: @threshold: PRD.NN.retry.max_attemptsrate_limit: @threshold: PRD.NN.limit.api.requests_per_second
无效(硬编码值):
p95响应时间: 200ms最大重试次数: 3速率限制: 100 req/s
有效(注册表引用):
p95响应时间: @threshold: PRD.NN.perf.api.p95_latency最大重试次数: @threshold: PRD.NN.retry.max_attempts速率限制: @threshold: PRD.NN.limit.api.requests_per_second
Upstream/Downstream Artifacts
上游/下游工件
Upstream Sources:
- BRD (Layer 1) - Business requirements
- PRD (Layer 2) - Product features
- EARS (Layer 3) - Formal requirements
- BDD (Layer 4) - Test scenarios
- ADR (Layer 5) - Architecture decisions
- SYS (Layer 6) - System requirements (PRIMARY SOURCE)
Downstream Artifacts:
- IMPL (Layer 8) - Implementation approach (optional)
- CTR (Layer 9) - Data contracts (optional)
- SPEC (Layer 10) - Technical specifications
- Code (Layer 13) - Implementation
Same-Type Document Relationships (conditional):
- - REQs sharing domain context
@related-req: REQ-NN - - REQ that must be implemented first
@depends-req: REQ-NN
上游来源:
- BRD(第1层)- 业务需求
- PRD(第2层)- 产品功能
- EARS(第3层)- 正式需求
- BDD(第4层)- 测试场景
- ADR(第5层)- 架构决策
- SYS(第6层)- 系统需求(主要来源)
下游工件:
- IMPL(第8层)- 实现方案(可选)
- CTR(第9层)- 数据契约(可选)
- SPEC(第10层)- 技术规范
- Code(第13层)- 实现代码
同类型文档关系(可选):
- - 共享领域上下文的REQ
@related-req: REQ-NN - - 必须先实现的REQ
@depends-req: REQ-NN
Creation Process
创建流程
Step 1: Read Upstream Artifacts
步骤1: 阅读上游工件
Especially focus on SYS (Layer 6) - system requirements to decompose.
重点关注SYS(第6层)——需要分解的系统需求。
Step 2: Reserve ID Number
步骤2: 预留ID编号
Check for next available ID number.
ai_dev_flow/REQ/ID Numbering Convention: Start with 2 digits and expand only as needed.
- ✅ Correct: REQ-01, REQ-99, REQ-102
- ❌ Incorrect: REQ-001, REQ-009 (extra leading zero not required)
Domain-based naming:
REQ-domain-subdomain-NN查看获取下一个可用的ID编号。
ai_dev_flow/REQ/ID编号约定: 以2位数字开头,仅在需要时扩展位数。
- ✅ 正确: REQ-01, REQ-99, REQ-102
- ❌ 错误: REQ-001, REQ-009(不需要前导零)
基于领域的命名:
REQ-domain-subdomain-NNStep 3: Create REQ File
步骤3: 创建REQ文件
Nested Folder Rule (MANDATORY): ALL REQ documents MUST use nested folders regardless of document size.
Location Options:
- Standard:
docs/07_REQ/REQ-NN_{slug}/REQ-NN_{slug}.md - Domain-based:
docs/07_REQ/{domain}/REQ-NN_{slug}/REQ-NN_{slug}.md - Subdomain:
docs/07_REQ/{domain}/{subdomain}/REQ-NN_{slug}/REQ-NN_{slug}.md
On-Demand Folder Creation: Before saving the document, create the target directory:
bash
undefined嵌套文件夹规则(MANDATORY): 无论文档大小,所有REQ文档都必须使用嵌套文件夹。
存储位置选项:
- 标准:
docs/07_REQ/REQ-NN_{slug}/REQ-NN_{slug}.md - 基于领域:
docs/07_REQ/{domain}/REQ-NN_{slug}/REQ-NN_{slug}.md - 子领域:
docs/07_REQ/{domain}/{subdomain}/REQ-NN_{slug}/REQ-NN_{slug}.md
按需创建文件夹: 保存文档前,先创建目标目录:
bash
undefinedCreate target directory (ALWAYS use nested folder)
创建目标目录(始终使用嵌套文件夹)
mkdir -p docs/07_REQ/REQ-NN_{slug}/
mkdir -p docs/07_REQ/REQ-NN_{slug}/
OR for domain-based structure
或者基于领域的结构
mkdir -p docs/07_REQ/{domain}/REQ-NN_{slug}/
**CRITICAL**: Never create REQ files directly in `docs/07_REQ/` without a nested folder structure.
**Domain Selection**: Use domain from project configuration or upstream SYS context:
- Financial: `risk/`, `trading/`, `collection/`, `compliance/`, `ml/`
- SaaS: `tenant/`, `subscription/`, `billing/`, `workspace/`
- Generic: `api/`, `auth/`, `data/`, `core/`, `integration/`
**Section Files**: For large requirements (>50KB), use Section Files format: `REQ-NN.S_section_title.md` (S = section number).mkdir -p docs/07_REQ/{domain}/REQ-NN_{slug}/
**CRITICAL**: 绝不要直接在`docs/07_REQ/`下创建REQ文件,必须使用嵌套文件夹结构。
**领域选择**: 使用项目配置或上游SYS上下文中的领域:
- 金融领域: `risk/`, `trading/`, `collection/`, `compliance/`, `ml/`
- SaaS领域: `tenant/`, `subscription/`, `billing/`, `workspace/`
- 通用领域: `api/`, `auth/`, `data/`, `core/`, `integration/`
**章节文件**: 对于大型需求(>50KB),使用章节文件格式: `REQ-NN.S_section_title.md`(S = 章节编号)Step 4: Fill Document Control Section
步骤4: 填写文档控制章节
Complete metadata with all 11 required fields plus Document Revision History table.
完成包含11个必填字段的元数据,以及文档修订历史表格。
Step 5: Complete All 12 Required Sections
步骤5: 完成所有12个必填章节
Critical: REQ v3.0 requires all 12 sections for >=90% SPEC-readiness
- Description: Atomic requirement + SHALL/SHOULD/MAY language
- Functional Requirements: Core capabilities + business rules
- Interface Specifications: APIs, endpoints, contracts, Protocol/ABC class
- Data Schemas: Models, validation, constraints, Pydantic/dataclass
- Error Handling Specifications: Error codes, recovery, exception definitions
- Configuration Specifications: Settings, feature flags, YAML config
- Quality Attributes: Performance, security, scalability with thresholds
- Implementation Guidance: Technical approach, patterns
- Acceptance Criteria: >=15 measurable criteria
- Verification Methods: BDD scenarios, tests
- Traceability: Cumulative tags (6 tags)
- Change History: Version control table
Critical: REQ v3.0需要完成所有12个章节才能达到≥90%的SPEC就绪度
- 描述: 原子需求 + SHALL/SHOULD/MAY规范语言
- 功能需求: 核心能力 + 业务规则
- 接口规范: API、端点、契约、Protocol/ABC类
- 数据模式: 模型、验证、约束、Pydantic/dataclass
- 错误处理规范: 错误码、恢复策略、异常定义
- 配置规范: 设置、功能开关、YAML配置
- 质量属性: 性能、安全性、可扩展性(带阈值引用)
- 实现指南: 技术方案、模式
- 验收标准: ≥15个可衡量的标准
- 验证方法: BDD场景、测试
- 可追溯性: 累积标签(6个标签)
- 变更历史: 版本控制表格
Step 6: Calculate Readiness Scores
步骤6: 计算就绪度评分
Count completed sections and calculate both SPEC-Ready and IMPL-Ready percentages.
Quality Gate: Both scores must achieve >=90%
统计已完成的章节数,计算SPEC就绪度和IMPL就绪度百分比。
质量门: 两个评分均需达到≥90%
Step 7: Add Cumulative Tags
步骤7: 添加累积标签
Include all 6 upstream tags (@brd through @sys).
包含所有6个上游标签(@brd至@sys)。
Step 8: Create/Update Traceability Matrix
步骤8: 创建/更新可追溯性矩阵
MANDATORY: Update
ai_dev_flow/REQ/REQ-00_TRACEABILITY_MATRIX-TEMPLATE.mdMANDATORY: 更新
ai_dev_flow/REQ/REQ-00_TRACEABILITY_MATRIX-TEMPLATE.mdStep 9: Validate REQ
步骤9: 验证REQ
bash
./ai_dev_flow/scripts/validate_req_template.sh ai_dev_flow/REQ/REQ-NN_*.md
python ai_dev_flow/scripts/validate_tags_against_docs.py --artifact REQ-NN --expected-layers brd,prd,ears,bdd,adr,sys --strictbash
./ai_dev_flow/scripts/validate_req_template.sh ai_dev_flow/REQ/REQ-NN_*.md
python ai_dev_flow/scripts/validate_tags_against_docs.py --artifact REQ-NN --expected-layers brd,prd,ears,bdd,adr,sys --strictStep 10: Commit Changes
步骤10: 提交变更
Commit REQ file and traceability matrix.
提交REQ文件和可追溯性矩阵。
Validation
验证
Validation Checks (20 Total)
验证检查项(共20项)
| Check | Description | Type |
|---|---|---|
| CHECK 1 | Required 12 sections | Error |
| CHECK 2 | Document Control (11 fields) | Error |
| CHECK 3 | Traceability structure | Error/Warning |
| CHECK 4 | Legacy (deprecated) | Info |
| CHECK 5 | Version format (X.Y.Z) | Error |
| CHECK 6 | Date format (ISO 8601) | Error |
| CHECK 7 | Priority format (P1-P4) | Warning |
| CHECK 8 | Source document format | Warning |
| CHECK 9 | SPEC-Ready Score | Error/Warning |
| CHECK 10 | Template Version (3.0) | Error |
| CHECK 11 | Change History | Error/Warning |
| CHECK 12 | Filename/ID format | Error |
| CHECK 13 | Resource tag (Template 2.0) | Error |
| CHECK 14 | Cumulative tagging (6 tags) | Error |
| CHECK 15 | Complete upstream chain | Error |
| CHECK 16 | Link resolution | Error/Warning |
| CHECK 17 | Traceability matrix | Warning |
| CHECK 18 | SPEC-Ready content | Warning |
| CHECK 19 | IMPL-Ready Score | Error |
| CHECK 20 | Element ID format compliance | Error |
| 检查项 | 描述 | 类型 |
|---|---|---|
| CHECK 1 | 必填的12个章节是否存在 | 错误 |
| CHECK 2 | 文档控制(11个字段) | 错误 |
| CHECK 3 | 可追溯性结构 | 错误/警告 |
| CHECK 4 | 遗留(已弃用)内容 | 信息 |
| CHECK 5 | 版本格式(X.Y.Z) | 错误 |
| CHECK 6 | 日期格式(ISO 8601) | 错误 |
| CHECK 7 | 优先级格式(P1-P4) | 警告 |
| CHECK 8 | 源文档格式 | 警告 |
| CHECK 9 | SPEC就绪度评分 | 错误/警告 |
| CHECK 10 | 模板版本(3.0) | 错误 |
| CHECK 11 | 变更历史 | 错误/警告 |
| CHECK 12 | 文件名/ID格式 | 错误 |
| CHECK 13 | 资源标签(模板2.0) | 错误 |
| CHECK 14 | 累积标签(6个标签) | 错误 |
| CHECK 15 | 完整的上游链 | 错误 |
| CHECK 16 | 链接解析 | 错误/警告 |
| CHECK 17 | 可追溯性矩阵 | 警告 |
| CHECK 18 | SPEC就绪内容 | 警告 |
| CHECK 19 | IMPL就绪度评分 | 错误 |
| CHECK 20 | 元素ID格式合规性 | 错误 |
Validation Tiers
验证层级
| Tier | Type | Exit Code | Description |
|---|---|---|---|
| Tier 1 | Errors | 1 | Blocking - must fix before commit |
| Tier 2 | Warnings | 0 | Quality issues - recommended to fix |
| Tier 3 | Info | 0 | Informational - no action required |
| 层级 | 类型 | 退出码 | 描述 |
|---|---|---|---|
| Tier 1 | 错误 | 1 | 阻塞性 - 必须修复才能提交 |
| Tier 2 | 警告 | 0 | 质量问题 - 建议修复 |
| Tier 3 | 信息 | 0 | 参考信息 - 无需操作 |
Automated Validation
自动化验证
bash
undefinedbash
undefinedValidate single file
验证单个文件
./scripts/validate_req_template.sh docs/REQ/REQ-NN_slug.md
./scripts/validate_req_template.sh docs/REQ/REQ-NN_slug.md
Validate all REQ files
验证所有REQ文件
find docs/REQ -name "REQ-*.md" -exec ./scripts/validate_req_template.sh {} ;
find docs/REQ -name "REQ-*.md" -exec ./scripts/validate_req_template.sh {} ;
Cumulative tagging validation
累积标签验证
python ai_dev_flow/scripts/validate_tags_against_docs.py
--artifact REQ-NN
--expected-layers brd,prd,ears,bdd,adr,sys
--strict
--artifact REQ-NN
--expected-layers brd,prd,ears,bdd,adr,sys
--strict
undefinedpython ai_dev_flow/scripts/validate_tags_against_docs.py
--artifact REQ-NN
--expected-layers brd,prd,ears,bdd,adr,sys
--strict
--artifact REQ-NN
--expected-layers brd,prd,ears,bdd,adr,sys
--strict
undefinedManual Checklist
手动检查清单
- Document Control section at top with 11 required fields
- All 12 required sections completed
- SPEC-Ready Score >=90%
- IMPL-Ready Score >=90%
- Template Version = 3.0
- Section 3: Interface Specifications with Protocol/ABC class
- Section 4: Data Schemas with Pydantic/dataclass models
- Section 5: Error Handling with exception definitions
- Section 6: Configuration with YAML schema
- Section 7: Quality Attributes with @threshold references
- Section 9: >=15 acceptance criteria
- Cumulative tags: @brd through @sys (6 tags) included
- Each requirement atomic (single responsibility)
- Acceptance criteria testable and measurable
- Traceability matrix updated
- 顶部有包含11个必填字段的文档控制章节
- 所有12个必填章节已完成
- SPEC就绪度评分≥90%
- IMPL就绪度评分≥90%
- 模板版本=3.0
- 第3章:接口规范包含Protocol/ABC类
- 第4章:数据模式包含Pydantic/dataclass模型
- 第5章:错误处理包含异常定义
- 第6章:配置包含YAML模式
- 第7章:质量属性包含@threshold引用
- 第9章:≥15个验收标准
- 累积标签:包含@brd至@sys(6个标签)
- 每个需求都是原子化的(单一职责)
- 验收标准可测试、可衡量
- 可追溯性矩阵已更新
Diagram Standards
图表标准
All diagrams MUST use Mermaid syntax. Text-based diagrams (ASCII art, box drawings) are prohibited.
See: and skill.
ai_dev_flow/DIAGRAM_STANDARDS.mdmermaid-gen所有图表必须使用Mermaid语法。禁止使用基于文本的图表(ASCII艺术、框线图)。
参考: 和技能。
ai_dev_flow/DIAGRAM_STANDARDS.mdmermaid-genCommon Pitfalls
常见陷阱
- Incomplete sections: All 12 sections mandatory for SPEC-readiness
- Missing new sections: Sections 3-7 are new in v3.0 - don't skip them
- Low readiness scores: Both SPEC-Ready and IMPL-Ready must achieve >=90%
- Non-atomic requirements: Each REQ must be single, testable unit
- Missing cumulative tags: Layer 7 must include all 6 upstream tags
- Vague acceptance criteria: Must be measurable and testable
- Hardcoded values: Use @threshold references, not magic numbers
- Legacy element IDs: Use format, not AC-XXX or FR-XXX
REQ.NN.TT.SS - Status/score mismatch: Status must match the LOWER of the two scores
- 章节不完整: 所有12个章节都是SPEC就绪度的必填项
- 遗漏新增章节: 第3-7章是v3.0新增的——不要跳过
- 就绪度评分过低: SPEC就绪度和IMPL就绪度都必须≥90%
- 非原子需求: 每个REQ必须是单一、可测试的单元
- 缺失累积标签: 第7层必须包含所有6个上游标签
- 模糊的验收标准: 必须可衡量、可测试
- 硬编码值: 使用@threshold引用,不要用魔法数字
- 遗留元素ID: 使用格式,不要用AC-XXX或FR-XXX
REQ.NN.TT.SS - 状态/评分不匹配: 状态必须与较低的评分匹配
Post-Creation Validation (MANDATORY - NO CONFIRMATION)
创建后验证(MANDATORY - 无需确认)
CRITICAL: Execute this validation loop IMMEDIATELY after document creation.
CRITICAL: 文档创建后立即执行此验证循环。
Automatic Validation Loop
自动验证循环
LOOP:
1. Run: python scripts/validate_cross_document.py --document {doc_path} --auto-fix
2. IF errors fixed: GOTO LOOP (re-validate)
3. IF warnings fixed: GOTO LOOP (re-validate)
4. IF unfixable issues: Log for manual review, continue
5. IF clean: Mark VALIDATED, proceedLOOP:
1. 运行: python scripts/validate_cross_document.py --document {doc_path} --auto-fix
2. 如果错误已修复: 回到LOOP(重新验证)
3. 如果警告已修复: 回到LOOP(重新验证)
4. 如果存在无法修复的问题: 记录以便手动审核,继续
5. 如果验证通过: 标记为VALIDATED,继续Validation Command
验证命令
bash
undefinedbash
undefinedPer-document validation (Phase 1)
单文档验证(阶段1)
python ai_dev_flow/scripts/validate_cross_document.py --document docs/REQ/REQ-NN_slug.md --auto-fix
python ai_dev_flow/scripts/validate_cross_document.py --document docs/REQ/REQ-NN_slug.md --auto-fix
Layer validation (Phase 2) - run when all REQ documents complete
层级验证(阶段2)- 所有REQ文档完成后运行
python ai_dev_flow/scripts/validate_cross_document.py --layer REQ --auto-fix
undefinedpython ai_dev_flow/scripts/validate_cross_document.py --layer REQ --auto-fix
undefinedLayer-Specific Upstream Requirements
层级专属上游需求
| This Layer | Required Upstream Tags | Count |
|---|---|---|
| REQ (Layer 7) | @brd, @prd, @ears, @bdd, @adr, @sys | 6 tags |
| 当前层级 | 必填上游标签 | 数量 |
|---|---|---|
| REQ(第7层) | @brd, @prd, @ears, @bdd, @adr, @sys | 6个标签 |
Auto-Fix Actions (No Confirmation Required)
自动修复操作(无需确认)
| Issue | Fix Action |
|---|---|
| Missing @brd/@prd/@ears/@bdd/@adr/@sys tag | Add with upstream document reference |
| Invalid tag format | Correct to TYPE.NN.TT.SS (4-segment) or TYPE-NN format |
| Broken link | Recalculate path from current location |
| Missing traceability section | Insert from template |
| 问题 | 修复动作 |
|---|---|
| 缺失@brd/@prd/@ears/@bdd/@adr/@sys标签 | 添加上游文档引用 |
| 无效的标签格式 | 修正为TYPE.NN.TT.SS(4段)或TYPE-NN格式 |
| 链接失效 | 根据当前位置重新计算路径 |
| 缺失可追溯性章节 | 从模板插入 |
Validation Codes Reference
验证代码参考
| Code | Description | Severity |
|---|---|---|
| XDOC-001 | Referenced requirement ID not found | ERROR |
| XDOC-002 | Missing cumulative tag | ERROR |
| XDOC-003 | Upstream document not found | ERROR |
| XDOC-006 | Tag format invalid | ERROR |
| XDOC-007 | Gap in cumulative tag chain | ERROR |
| XDOC-009 | Missing traceability section | ERROR |
| 代码 | 描述 | 严重程度 |
|---|---|---|
| XDOC-001 | 引用的需求ID未找到 | 错误 |
| XDOC-002 | 缺失累积标签 | 错误 |
| XDOC-003 | 上游文档未找到 | 错误 |
| XDOC-006 | 标签格式无效 | 错误 |
| XDOC-007 | 累积标签链存在缺口 | 错误 |
| XDOC-009 | 缺失可追溯性章节 | 错误 |
Quality Gate
质量门
Blocking: YES - Cannot proceed to IMPL/SPEC creation until Phase 1 validation passes with 0 errors.
阻塞性: 是 - 阶段1验证必须通过且无错误,才能继续创建IMPL/SPEC文档。
Next Skill
下一个技能
After creating REQ, use:
doc-specdoc-impldoc-ctrThe SPEC will:
- Reference this REQ as upstream source
- Include all 7 upstream tags (@brd through @req)
- Use YAML format
- Define implementation contracts
- Achieve 100% implementation-readiness
创建REQ后,使用:
doc-specdoc-impldoc-ctrSPEC文档将:
- 引用本REQ作为上游来源
- 包含所有7个上游标签(@brd至@req)
- 使用YAML格式
- 定义实现契约
- 达到100%的实现就绪度
Reference Documents
参考文档
REQ artifacts do not support REF documents. Reference documents are limited to BRD and ADR types only per the SDD framework.
For supplementary documentation needs, create:
- BRD-REF: Business context and domain glossaries
- ADR-REF: Technical reference guides and architecture summaries
REQ工件不支持REF文档。根据SDD框架,参考文档仅限于BRD和ADR类型。
如需补充文档,可创建:
- BRD-REF: 业务上下文和领域术语表
- ADR-REF: 技术参考指南和架构摘要
Related Resources
相关资源
- Template: (primary authority)
ai_dev_flow/07_REQ/REQ-MVP-TEMPLATE.md - REQ Creation Rules:
ai_dev_flow/07_REQ/REQ_CREATION_RULES.md - REQ Validation Rules:
ai_dev_flow/07_REQ/REQ_VALIDATION_RULES.md - REQ README:
ai_dev_flow/07_REQ/README.md - Shared Standards:
.claude/skills/doc-flow/SHARED_CONTENT.md
Section Templates (for documents >50KB):
- Index template:
ai_dev_flow/07_REQ/REQ-SECTION-0-TEMPLATE.md - Content template:
ai_dev_flow/07_REQ/REQ-SECTION-TEMPLATE.md - Reference: (Section-Based File Splitting)
ai_dev_flow/ID_NAMING_STANDARDS.md
- 模板: (主要权威来源)
ai_dev_flow/07_REQ/REQ-MVP-TEMPLATE.md - REQ创建规则:
ai_dev_flow/07_REQ/REQ_CREATION_RULES.md - REQ验证规则:
ai_dev_flow/07_REQ/REQ_VALIDATION_RULES.md - REQ README:
ai_dev_flow/07_REQ/README.md - 共享标准:
.claude/skills/doc-flow/SHARED_CONTENT.md
章节模板(适用于>50KB的文档):
- 索引模板:
ai_dev_flow/07_REQ/REQ-SECTION-0-TEMPLATE.md - 内容模板:
ai_dev_flow/07_REQ/REQ-SECTION-TEMPLATE.md - 参考: (基于章节的文件拆分)
ai_dev_flow/ID_NAMING_STANDARDS.md
Quick Reference
快速参考
REQ Purpose: Atomic, implementation-ready requirements
Layer: 7
Tags Required: @brd, @prd, @ears, @bdd, @adr, @sys (6 tags)
Format: REQ v3.0 (12 sections)
Quality Gate: SPEC-Ready Score >=90% AND IMPL-Ready Score >=90%
Element ID Format:
REQ.NN.TT.SS- Functional Requirement = 01
- Dependency = 05
- Acceptance Criteria = 06
- Atomic Requirement = 27
Removed Patterns: AC-XXX, FR-XXX, R-XXX, REQ-XXX
Document Control Fields: 11 required (+ Template Version = 3.0)
Status/Score Mapping: >=90% Approved, 70-89% In Review, <70% Draft
File Size Limits: >50KB use section files
Next: doc-spec (or optionally doc-impl/doc-ctr first)
REQ目的: 原子化、可直接实现的需求
层级: 7
必填标签: @brd, @prd, @ears, @bdd, @adr, @sys(6个标签)
格式: REQ v3.0(12个章节)
质量门: SPEC就绪度评分≥90% 且 IMPL就绪度评分≥90%
元素ID格式:
REQ.NN.TT.SS- 功能需求 = 01
- 依赖项 = 05
- 验收标准 = 06
- 原子需求 = 27
已移除模式: AC-XXX, FR-XXX, R-XXX, REQ-XXX
文档控制字段: 11个必填字段(+ 模板版本=3.0)
状态/评分映射: ≥90% 已批准, 70-89% 审核中, <70% 草稿
文件大小限制: >50KB使用章节文件
下一步: doc-spec(或可选先使用doc-impl/doc-ctr)
Version History
版本历史
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0 | 2026-02-08 | Initial skill definition with YAML frontmatter standardization | System |
| 版本 | 日期 | 变更 | 作者 |
|---|---|---|---|
| 1.0 | 2026-02-08 | 初始技能定义,标准化YAML前置内容 | System |