doc-spec-autopilot

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

doc-spec-autopilot

doc-spec-autopilot

Purpose

用途

Automated Technical Specifications (SPEC) generation pipeline that processes REQ documents (and optional CTR) to generate implementation-ready YAML specifications with TASKS-Ready scoring.
Layer: 9
Upstream: REQ (Layer 7), CTR (Layer 8 - optional)
Downstream: TSPEC (Layer 10), TASKS (Layer 11)

自动化的**技术规格说明(SPEC)**生成流水线,处理REQ文档(及可选的CTR文档)以生成可直接用于实现的YAML规格说明,并提供TASKS就绪评分。
层级: 9
上游: REQ(层级7),CTR(层级8 - 可选)
下游: TSPEC(层级10),TASKS(层级11)

Skill Dependencies

技能依赖

SkillPurposePhase
doc-naming
Element ID format (SPEC.NN.TT.SS, codes 15, 16, 17, 21, 28)All Phases
doc-req-validator
Validate REQ SPEC-Ready scorePhase 2
doc-spec
SPEC creation rules, YAML formatPhase 3
quality-advisor
Real-time quality feedbackPhase 3
doc-spec-validator
Validation with TASKS-Ready scoringPhase 4
doc-spec-reviewer
Content review, link validation, quality scoringPhase 5: Review
doc-spec-fixer
Apply fixes from review report, create missing filesPhase 5: Fix

技能用途阶段
doc-naming
元素ID格式(SPEC.NN.TT.SS,编码15、16、17、21、28)所有阶段
doc-req-validator
验证REQ的SPEC就绪评分阶段2
doc-spec
SPEC创建规则、YAML格式阶段3
quality-advisor
实时质量反馈阶段3
doc-spec-validator
带TASKS就绪评分的验证阶段4
doc-spec-reviewer
内容审查、链接验证、质量评分阶段5:审查
doc-spec-fixer
应用审查报告中的修复建议,创建缺失文件阶段5:修复

Smart Document Detection

智能文档检测

The autopilot automatically determines the action based on the input document type.
该自动化工具会根据输入文档类型自动确定操作。

Input Type Recognition (Multiple Upstreams)

输入类型识别(多上游来源)

SPEC can be derived from REQ and/or CTR:
InputDetected AsAction
SPEC-NN
Self typeReview existing SPEC document
REQ-NN
Primary upstreamGenerate if missing, review if exists
CTR-NN
Alternative upstreamGenerate if missing, review if exists
SPEC可从REQ和/或CTR推导而来:
输入识别类型操作
SPEC-NN
自身类型审查现有SPEC文档
REQ-NN
主要上游来源若缺失则生成,若存在则审查
CTR-NN
备选上游来源若缺失则生成,若存在则审查

Detection Algorithm

检测算法

1. Parse input: Extract TYPE and NN from "{TYPE}-{NN}"
2. Determine action:
   - IF TYPE == "SPEC": Review Mode
   - ELSE IF TYPE in ["REQ", "CTR"]: Generate/Find Mode
   - ELSE: Error (invalid type for this autopilot)
3. For Generate/Find Mode:
   - Check: Does SPEC-{NN} exist in docs/09_SPEC/?
   - IF exists: Switch to Review Mode for SPEC-{NN}
   - ELSE: Proceed with Generation from {TYPE}-{NN}
1. 解析输入:从"{TYPE}-{NN}"中提取TYPE和NN
2. 确定操作:
   - 若TYPE == "SPEC":审查模式
   - 若TYPE属于["REQ", "CTR"]:生成/查找模式
   - 否则:错误(该自动化工具不支持此类型)
3. 对于生成/查找模式:
   - 检查:docs/09_SPEC/中是否存在SPEC-{NN}?
   - 若存在:切换为SPEC-{NN}的审查模式
   - 否则:从{TYPE}-{NN}开始生成

File Existence Check

文件存在性检查

bash
undefined
bash
undefined

Check for nested folder structure (mandatory)

检查嵌套文件夹结构(必填)

ls docs/09_SPEC/SPEC-{NN}_*/
undefined
ls docs/09_SPEC/SPEC-{NN}_*/
undefined

Examples

示例

bash
undefined
bash
undefined

Review mode (same type - SPEC input)

审查模式(同一类型 - SPEC输入)

/doc-spec-autopilot SPEC-01 # Reviews existing SPEC-01
/doc-spec-autopilot SPEC-01 # 审查现有SPEC-01

Generate/Find mode (upstream types)

生成/查找模式(上游类型)

/doc-spec-autopilot REQ-01 # Generates SPEC-01 if missing, or reviews existing SPEC-01 /doc-spec-autopilot CTR-01 # Generates SPEC-01 if missing, or reviews existing SPEC-01
/doc-spec-autopilot REQ-01 # 若缺失则生成SPEC-01,否则审查现有SPEC-01 /doc-spec-autopilot CTR-01 # 若缺失则生成SPEC-01,否则审查现有SPEC-01

Multiple inputs

多输入

/doc-spec-autopilot REQ-01,REQ-02 # Generates/reviews SPEC-01 and SPEC-02 /doc-spec-autopilot SPEC-01,SPEC-02 # Reviews SPEC-01 and SPEC-02
undefined
/doc-spec-autopilot REQ-01,REQ-02 # 生成/审查SPEC-01和SPEC-02 /doc-spec-autopilot SPEC-01,SPEC-02 # 审查SPEC-01和SPEC-02
undefined

Action Determination Output

操作确定输出

Input: REQ-01
├── Detected Type: REQ (primary upstream)
├── Expected SPEC: SPEC-01
├── SPEC Exists: Yes → docs/09_SPEC/SPEC-01_f1_iam/
└── Action: REVIEW MODE - Running doc-spec-reviewer on SPEC-01

Input: CTR-05
├── Detected Type: CTR (alternative upstream)
├── Expected SPEC: SPEC-05
├── SPEC Exists: No
└── Action: GENERATE MODE - Creating SPEC-05 from CTR-05

Input: SPEC-03
├── Detected Type: SPEC (self)
└── Action: REVIEW MODE - Running doc-spec-reviewer on SPEC-03

输入: REQ-01
├── 检测类型: REQ(主要上游来源)
├── 预期SPEC: SPEC-01
├── SPEC是否存在: 是 → docs/09_SPEC/SPEC-01_f1_iam/
└── 操作: 审查模式 - 对SPEC-01运行doc-spec-reviewer

输入: CTR-05
├── 检测类型: CTR(备选上游来源)
├── 预期SPEC: SPEC-05
├── SPEC是否存在: 否
└── 操作: 生成模式 - 从CTR-05创建SPEC-05

输入: SPEC-03
├── 检测类型: SPEC(自身)
└── 操作: 审查模式 - 对SPEC-03运行doc-spec-reviewer

Workflow Overview

工作流概述

mermaid
flowchart TD
    subgraph Phase1["Phase 1: REQ/CTR Analysis"]
        A[Start] --> B[Read REQ Documents]
        B --> C[Read CTR Documents if exists]
        C --> D[Extract Implementation Details]
        D --> E[Map to SPEC Structure]
    end

    subgraph Phase2["Phase 2: SPEC Readiness Check"]
        E --> F[Check REQ SPEC-Ready Score]
        F --> G{Score >= 90%?}
        G -->|No| H[Flag REQ Issues]
        H --> I{Auto-Fixable?}
        I -->|Yes| J[Fix REQ Issues]
        J --> F
        I -->|No| K[Abort - Manual Fix Required]
        G -->|Yes| L[Mark REQ Ready]
    end

    subgraph Phase3["Phase 3: SPEC Generation"]
        L --> M[Generate YAML Structure]
        M --> N[Add Methods/Interfaces]
        N --> O[Add Data Models]
        O --> P[quality-advisor: Real-time Feedback]
        P --> Q[Add Traceability]
        Q --> R[Write SPEC File]
    end

    subgraph Phase4["Phase 4: SPEC Validation"]
        R --> S[Run doc-spec-validator]
        S --> T{TASKS-Ready >= 90%?}
        T -->|No| U[Auto-Fix SPEC Issues]
        U --> V[Re-validate SPEC]
        V --> T
        T -->|Yes| W[Mark SPEC Validated]
    end

    subgraph Phase5["Phase 5: Review & Fix Cycle"]
        W --> X[Run doc-spec-reviewer]
        X --> X2{Score >= 90?}
        X2 -->|No| X3[Run doc-spec-fixer]
        X3 --> X4{Iteration < Max?}
        X4 -->|Yes| X
        X4 -->|No| X5[Flag Manual Review]
        X2 -->|Yes| Y[Verify Quality Checks]
        X5 --> Y
        Y --> Z[Update Traceability Matrix]
        Z --> AA[Generate Summary Report]
    end

    AA --> AB[Complete]
    K --> AC[Exit with Error]

mermaid
flowchart TD
    subgraph Phase1["Phase 1: REQ/CTR Analysis"]
        A[Start] --> B[Read REQ Documents]
        B --> C[Read CTR Documents if exists]
        C --> D[Extract Implementation Details]
        D --> E[Map to SPEC Structure]
    end

    subgraph Phase2["Phase 2: SPEC Readiness Check"]
        E --> F[Check REQ SPEC-Ready Score]
        F --> G{Score >= 90%?}
        G -->|No| H[Flag REQ Issues]
        H --> I{Auto-Fixable?}
        I -->|Yes| J[Fix REQ Issues]
        J --> F
        I -->|No| K[Abort - Manual Fix Required]
        G -->|Yes| L[Mark REQ Ready]
    end

    subgraph Phase3["Phase 3: SPEC Generation"]
        L --> M[Generate YAML Structure]
        M --> N[Add Methods/Interfaces]
        N --> O[Add Data Models]
        O --> P[quality-advisor: Real-time Feedback]
        P --> Q[Add Traceability]
        Q --> R[Write SPEC File]
    end

    subgraph Phase4["Phase 4: SPEC Validation"]
        R --> S[Run doc-spec-validator]
        S --> T{TASKS-Ready >= 90%?}
        T -->|No| U[Auto-Fix SPEC Issues]
        U --> V[Re-validate SPEC]
        V --> T
        T -->|Yes| W[Mark SPEC Validated]
    end

    subgraph Phase5["Phase 5: Review & Fix Cycle"]
        W --> X[Run doc-spec-reviewer]
        X --> X2{Score >= 90?}
        X2 -->|No| X3[Run doc-spec-fixer]
        X3 --> X4{Iteration < Max?}
        X4 -->|Yes| X
        X4 -->|No| X5[Flag Manual Review]
        X2 -->|Yes| Y[Verify Quality Checks]
        X5 --> Y
        Y --> Z[Update Traceability Matrix]
        Z --> AA[Generate Summary Report]
    end

    AA --> AB[Complete]
    K --> AC[Exit with Error]

SPEC YAML Format (13 Required Sections)

SPEC YAML格式(13个必填章节)

Trading Nexus patterns require comprehensive 13-section YAML structure:
yaml
undefined
Trading Nexus模式要求包含13个章节的完整YAML结构:
yaml
undefined

SPEC-NN: Specification Title

SPEC-NN: Specification Title

Required sections (all 13 mandatory)

Required sections (all 13 mandatory)

metadata: spec_id: SPEC-01 title: "Component Specification" version: "1.0.0" status: "approved" created_date: "2026-02-09T00:00:00" last_updated: "2026-02-09T00:00:00" task_ready_score: "✅ 95% (Target: ≥90%)" authors: [{name: "...", email: "...", role: "..."}] reviewers: [{name: "...", email: "...", role: "..."}]
traceability: upstream_sources: business_requirements: - id: "BRD.01.01.03" link: "../01_BRD/BRD-01.md#BRD.01.01.03" relationship: "Business driver" product_requirements: - id: "PRD.01.07.02" link: "../02_PRD/PRD-01.md#PRD.01.07.02" atomic_requirements: - id: "REQ-01.01.01" # CRITICAL: Use nested REQ path format link: "../07_REQ/SYS-01_iam/REQ-01.01_jwt_authentication.md" cumulative_tags: brd: ["BRD.01.01.03"] prd: ["PRD.01.07.02"] ears: ["EARS.01.25.01"] bdd: ["BDD.01.14.01"] adr: ["ADR-01"] sys: ["SYS.01.26.01"] req: ["REQ.01.27.01"] ctr: ["CTR.01.16.01"] threshold: ["perf.auth.p95_latency", "sla.uptime.target"] # 9th layer
interfaces:

Level 1: External APIs (REST)

external_apis: - endpoint: "POST /api/v1/auth/login" method: "POST" auth: "None" rate_limit: "5 req/5 min per IP" request_schema: type: "object" required: ["email", "password"] properties: email: { type: "string", format: "email" } password: { type: "string", minLength: 12 } response_schema: type: "object" properties: access_token: { type: "string" } token_type: { type: "string", enum: ["Bearer"] } latency_target_ms: "@threshold:perf.auth.p95_latency"

Level 2: Internal APIs (Service signatures)

internal_apis: - interface: "AuthService.authenticate()" signature: "async def authenticate(email: str, password: str) -> TokenPair" purpose: | 1. Fetch user by email from Identity Platform. 2. Verify password via Argon2id. 3. Issue JWT token pair.

Level 3: Classes (OOP structure)

classes: - name: "IAMService" description: "Facade combining auth, token, and authz services" constructor: params: config: { type: object, required: true } methods: - name: "initialize" input: { } output: { success: boolean }
data_models:
  • id: SPEC.01.17.01 name: "RequestModel" json_schema: type: object properties: id: { type: string } pydantic_code: | from pydantic import BaseModel class RequestModel(BaseModel): id: str
validation_rules:
  • id: SPEC.01.21.01 rule: "Email format validation" implementation: "Use EmailStr from pydantic"
error_handling: catalog: INVALID_CREDENTIALS: http_status: 401 message: "Invalid email or password" RATE_LIMIT_EXCEEDED: http_status: 429 message: "Too many attempts"
configuration: environment_variables: - name: JWT_SECRET required: true description: "JWT signing secret" feature_flags: - name: MFA_REQUIRED default: false
performance: latency_targets: login_p95_ms: "@threshold:perf.auth.p95_latency" throughput_targets: auth_rps: "@threshold:perf.auth.throughput"
behavior: login_flow: pseudocode: | def login(email, password): enforce_rate_limit(ip, "login") user = idp.get_user(email) if not user or not verify_password(password, user.hash): raise AuthenticationError("INVALID_CREDENTIALS") return token_service.issue_tokens(user)
behavioral_examples: api_example_login: request: endpoint: "/api/v1/auth/login" payload: { email: "user@example.com", password: "SecureP@ss!" } response: status: 200 body: { access_token: "<jwt>", token_type: "Bearer" }
architecture: component_structure: - name: "AuthService" responsibility: "User authentication" dependencies: ["GCP Identity Platform", "Redis"] resilience: circuit_breaker_enabled: true retry_policy: max_attempts: 3 backoff_strategy: "exponential"
operations: slo: uptime: "@threshold:sla.uptime.target" error_rate: "<1%" monitoring_metrics: ["auth_login_latency_p95_ms", "auth_errors_total"]
req_implementations:
  • req_id: "REQ-01.01" req_link: "../07_REQ/SYS-01_iam/REQ-01.01.md" implementation: interfaces: - class: "AuthService" method: "login" signature: "async def login(...) -> LoginResult" data_models: - name: "LoginRequest" fields: ["email", "password"] validation_rules: - rule: "Rate limit login attempts" implementation: "5 attempts/5 minutes per IP" error_handling: - error_code: "INVALID_CREDENTIALS" http_status: 401 test_approach: unit_tests: ["hash verification rejects wrong password"] integration_tests: ["login flow returns token pair"]
threshold_references: registry_document: "PRD-01_thresholds" keys_used: performance: - key: "perf.auth.p95_latency" usage: "performance.latency_targets.login" sla: - key: "sla.uptime.target" usage: "operations.slo.uptime"

---
metadata: spec_id: SPEC-01 title: "Component Specification" version: "1.0.0" status: "approved" created_date: "2026-02-09T00:00:00" last_updated: "2026-02-09T00:00:00" task_ready_score: "✅ 95% (Target: ≥90%)" authors: [{name: "...", email: "...", role: "..."}] reviewers: [{name: "...", email: "...", role: "..."}]
traceability: upstream_sources: business_requirements: - id: "BRD.01.01.03" link: "../01_BRD/BRD-01.md#BRD.01.01.03" relationship: "Business driver" product_requirements: - id: "PRD.01.07.02" link: "../02_PRD/PRD-01.md#PRD.01.07.02" atomic_requirements: - id: "REQ-01.01.01" # CRITICAL: Use nested REQ path format link: "../07_REQ/SYS-01_iam/REQ-01.01_jwt_authentication.md" cumulative_tags: brd: ["BRD.01.01.03"] prd: ["PRD.01.07.02"] ears: ["EARS.01.25.01"] bdd: ["BDD.01.14.01"] adr: ["ADR-01"] sys: ["SYS.01.26.01"] req: ["REQ.01.27.01"] ctr: ["CTR.01.16.01"] threshold: ["perf.auth.p95_latency", "sla.uptime.target"] # 9th layer
interfaces:

Level 1: External APIs (REST)

external_apis: - endpoint: "POST /api/v1/auth/login" method: "POST" auth: "None" rate_limit: "5 req/5 min per IP" request_schema: type: "object" required: ["email", "password"] properties: email: { type: "string", format: "email" } password: { type: "string", minLength: 12 } response_schema: type: "object" properties: access_token: { type: "string" } token_type: { type: "string", enum: ["Bearer"] } latency_target_ms: "@threshold:perf.auth.p95_latency"

Level 2: Internal APIs (Service signatures)

internal_apis: - interface: "AuthService.authenticate()" signature: "async def authenticate(email: str, password: str) -> TokenPair" purpose: | 1. Fetch user by email from Identity Platform. 2. Verify password via Argon2id. 3. Issue JWT token pair.

Level 3: Classes (OOP structure)

classes: - name: "IAMService" description: "Facade combining auth, token, and authz services" constructor: params: config: { type: object, required: true } methods: - name: "initialize" input: { } output: { success: boolean }
data_models:
  • id: SPEC.01.17.01 name: "RequestModel" json_schema: type: object properties: id: { type: string } pydantic_code: | from pydantic import BaseModel class RequestModel(BaseModel): id: str
validation_rules:
  • id: SPEC.01.21.01 rule: "Email format validation" implementation: "Use EmailStr from pydantic"
error_handling: catalog: INVALID_CREDENTIALS: http_status: 401 message: "Invalid email or password" RATE_LIMIT_EXCEEDED: http_status: 429 message: "Too many attempts"
configuration: environment_variables: - name: JWT_SECRET required: true description: "JWT signing secret" feature_flags: - name: MFA_REQUIRED default: false
performance: latency_targets: login_p95_ms: "@threshold:perf.auth.p95_latency" throughput_targets: auth_rps: "@threshold:perf.auth.throughput"
behavior: login_flow: pseudocode: | def login(email, password): enforce_rate_limit(ip, "login") user = idp.get_user(email) if not user or not verify_password(password, user.hash): raise AuthenticationError("INVALID_CREDENTIALS") return token_service.issue_tokens(user)
behavioral_examples: api_example_login: request: endpoint: "/api/v1/auth/login" payload: { email: "user@example.com", password: "SecureP@ss!" } response: status: 200 body: { access_token: "<jwt>", token_type: "Bearer" }
architecture: component_structure: - name: "AuthService" responsibility: "User authentication" dependencies: ["GCP Identity Platform", "Redis"] resilience: circuit_breaker_enabled: true retry_policy: max_attempts: 3 backoff_strategy: "exponential"
operations: slo: uptime: "@threshold:sla.uptime.target" error_rate: "<1%" monitoring_metrics: ["auth_login_latency_p95_ms", "auth_errors_total"]
req_implementations:
  • req_id: "REQ-01.01" req_link: "../07_REQ/SYS-01_iam/REQ-01.01.md" implementation: interfaces: - class: "AuthService" method: "login" signature: "async def login(...) -> LoginResult" data_models: - name: "LoginRequest" fields: ["email", "password"] validation_rules: - rule: "Rate limit login attempts" implementation: "5 attempts/5 minutes per IP" error_handling: - error_code: "INVALID_CREDENTIALS" http_status: 401 test_approach: unit_tests: ["hash verification rejects wrong password"] integration_tests: ["login flow returns token pair"]
threshold_references: registry_document: "PRD-01_thresholds" keys_used: performance: - key: "perf.auth.p95_latency" usage: "performance.latency_targets.login" sla: - key: "sla.uptime.target" usage: "operations.slo.uptime"

---

Phase 5: Review & Fix Cycle (v2.2)

阶段5:审查与修复周期(v2.2)

Iterative review and fix cycle to ensure SPEC quality before completion.
mermaid
flowchart TD
    A[Phase 5 Start] --> B[Run doc-spec-reviewer]
    B --> C[Generate Review Report]
    C --> D{Review Score >= 90?}

    D -->|Yes| E[PASS - Proceed to Phase 6]
    D -->|No| F{Iteration < Max?}

    F -->|Yes| G[Run doc-spec-fixer]
    G --> H[Apply Fixes]
    H --> I[Generate Fix Report]
    I --> J[Increment Iteration]
    J --> B

    F -->|No| K[Flag for Manual Review]
    K --> L[Generate Final Report with Remaining Issues]
    L --> E
迭代式审查与修复周期,确保完成前的SPEC质量。
mermaid
flowchart TD
    A[Phase 5 Start] --> B[Run doc-spec-reviewer]
    B --> C[Generate Review Report]
    C --> D{Review Score >= 90?}

    D -->|Yes| E[PASS - Proceed to Phase 6]
    D -->|No| F{Iteration < Max?}

    F -->|Yes| G[Run doc-spec-fixer]
    G --> H[Apply Fixes]
    H --> I[Generate Fix Report]
    I --> J[Increment Iteration]
    J --> B

    F -->|No| K[Flag for Manual Review]
    K --> L[Generate Final Report with Remaining Issues]
    L --> E

5.1 Initial Review

5.1 初始审查

Run
doc-spec-reviewer
to identify issues.
bash
/doc-spec-reviewer SPEC-NN
Output:
SPEC-NN.R_review_report_v001.md
运行
doc-spec-reviewer
以识别问题。
bash
/doc-spec-reviewer SPEC-NN
输出:
SPEC-NN.R_review_report_v001.md

5.2 Fix Cycle

5.2 修复周期

If review score < 90%, invoke
doc-spec-fixer
.
bash
/doc-spec-fixer SPEC-NN --revalidate
Fix Categories:
CategoryFixes Applied
Missing SectionsAdd missing 13 required sections
Broken LinksUpdate paths, fix REQ references
Element IDsConvert legacy patterns, fix invalid type codes
Threshold ReferencesReplace hardcoded values with @threshold syntax
Interface LevelsAdd missing external/internal/classes stubs
TraceabilityUpdate cumulative tags (9 layers)
Output:
SPEC-NN.F_fix_report_v001.md
若审查评分<90%,调用
doc-spec-fixer
bash
/doc-spec-fixer SPEC-NN --revalidate
修复类别:
类别应用的修复
缺失章节添加缺失的13个必填章节
失效链接更新路径,修复REQ引用
元素ID转换旧有模式,修复无效类型编码
阈值引用替换硬编码值为@threshold语法
接口层级添加缺失的外部/内部/类存根
可追溯性更新累积标签(9个层级)
输出:
SPEC-NN.F_fix_report_v001.md

5.3 Re-Review

5.3 重新审查

After fixes, automatically re-run reviewer.
bash
/doc-spec-reviewer SPEC-NN
Output:
SPEC-NN.R_review_report_v002.md
修复后,自动重新运行审查工具。
bash
/doc-spec-reviewer SPEC-NN
输出:
SPEC-NN.R_review_report_v002.md

5.4 Iteration Control

5.4 迭代控制

ParameterDefaultDescription
max_iterations
3Maximum fix-review cycles
target_score
90Minimum passing score
stop_on_manual
falseStop if only manual issues remain
Iteration Example:
Iteration 1:
  Review v001: Score 82 (3 errors, 5 warnings)
  Fix v001: Fixed 6 issues, added 2 sections

Iteration 2:
  Review v002: Score 93 (0 errors, 3 warnings)
  Status: PASS (score >= 90)
参数默认值描述
max_iterations
3最大修复-审查周期数
target_score
90最低合格分数
stop_on_manual
false若仅剩余手动问题则停止
迭代示例:
迭代1:
  审查v001: 分数82(3个错误,5个警告)
  修复v001: 修复6个问题,添加2个章节

迭代2:
  审查v002: 分数93(0个错误,3个警告)
  状态: 通过(分数≥90)

5.5 Quality Checks (Post-Fix)

5.5 质量检查(修复后)

After passing the fix cycle:
  1. Section Completeness:
    • All 13 required sections present
    • No placeholder text remaining ([TBD], TODO, XXX)
    • Minimum content length per section
  2. Three-Level Interface Coverage:
    • external_apis defined with OpenAPI format
    • internal_apis defined with method signatures
    • classes defined with constructors and methods
  3. Element ID Compliance (per
    doc-naming
    skill):
    • All IDs use SPEC.NN.TT.SS format
    • Element type codes valid for SPEC (15, 16, 17, 21, 28)
    • No legacy patterns
  4. TASKS-Ready Report:
    TASKS-Ready Score Breakdown
    ===========================
    Interface Completeness:  23/25 (3 levels defined)
    Data Models:             20/20 (Pydantic + JSON Schema)
    Validation Rules:        15/15 (input/output validated)
    Error Handling:          15/15 (catalog with HTTP status)
    Test Approach:           10/10 (unit + integration tests)
    Traceability:            10/10 (all 9 cumulative tags)
    Performance Specs:        5/5 (@threshold references)
    ----------------------------
    Total TASKS-Ready Score: 98/100 (Target: >= 90)
    Status: READY FOR TASKS GENERATION
  5. Traceability Matrix Update:
    bash
    # Update SPEC traceability
    python ai_dev_flow/scripts/update_traceability_matrix.py \
      --spec docs/09_SPEC/SPEC-NN.yaml \
      --matrix docs/09_SPEC/SPEC-00_TRACEABILITY_MATRIX.md

通过修复周期后:
  1. 章节完整性:
    • 所有13个必填章节均存在
    • 无占位文本残留([TBD]、TODO、XXX)
    • 每个章节达到最小内容长度
  2. 三级接口覆盖:
    • 按OpenAPI格式定义external_apis
    • 按方法签名定义internal_apis
    • 按构造函数和方法定义classes
  3. 元素ID合规性(遵循
    doc-naming
    技能):
    • 所有ID使用SPEC.NN.TT.SS格式
    • 元素类型编码对SPEC有效(15、16、17、21、28)
    • 无旧有模式
  4. TASKS就绪报告:
    TASKS就绪评分明细
    ===========================
    接口完整性:  23/25(定义了3个层级)
    数据模型:             20/20(Pydantic + JSON Schema)
    验证规则:        15/15(输入/输出已验证)
    错误处理:          15/15(含HTTP状态码的目录)
    测试方法:           10/10(单元 + 集成测试)
    可追溯性:            10/10(所有9个累积标签)
    性能规格:        5/5(@threshold引用)
    ----------------------------
    TAS就绪总评分: 98/100(目标: ≥90)
    状态: 可用于生成TASKS
  5. 可追溯性矩阵更新:
    bash
    # 更新SPEC可追溯性
    python ai_dev_flow/scripts/update_traceability_matrix.py \
      --spec docs/09_SPEC/SPEC-NN.yaml \
      --matrix docs/09_SPEC/SPEC-00_TRACEABILITY_MATRIX.md

Element Type Codes

元素类型编码

CodeElement TypeExample
15StepSPEC.01.15.01
16InterfaceSPEC.01.16.01
17Data ModelSPEC.01.17.01
21Validation RuleSPEC.01.21.01
28Specification ElementSPEC.01.28.01

编码元素类型示例
15步骤SPEC.01.15.01
16接口SPEC.01.16.01
17数据模型SPEC.01.17.01
21验证规则SPEC.01.21.01
28规格说明元素SPEC.01.28.01

Cumulative Tags (7-8 Required)

累积标签(7-8个必填)

markdown
@brd: BRD.NN.TT.SS
@prd: PRD.NN.TT.SS
@ears: EARS.NN.TT.SS
@bdd: BDD.NN.TT.SS
@adr: ADR-NN
@sys: SYS.NN.TT.SS
@req: REQ.NN.TT.SS
@ctr: CTR.NN.TT.SS  # Optional

markdown
@brd: BRD.NN.TT.SS
@prd: PRD.NN.TT.SS
@ears: EARS.NN.TT.SS
@bdd: BDD.NN.TT.SS
@adr: ADR-NN
@sys: SYS.NN.TT.SS
@req: REQ.NN.TT.SS
@ctr: CTR.NN.TT.SS  # 可选

Configuration

配置

Default Configuration

默认配置

yaml
spec_autopilot:
  version: "2.0"

  scoring:
    spec_ready_min: 90
    tasks_ready_min: 90
    strict_mode: false
    # NEW: 7-component scoring weights
    scoring_weights:
      interface_completeness: 25  # All 3 levels defined
      data_models: 20             # Pydantic + JSON Schema
      validation_rules: 15        # Input/output validation
      error_handling: 15          # Error catalog with HTTP status
      test_approach: 10           # Unit + integration tests
      traceability: 10            # All 9 cumulative tags
      performance_specs: 5        # Latency targets with thresholds

  execution:
    max_parallel: 3        # HARD LIMIT - do not exceed
    chunk_size: 3          # Documents per chunk
    pause_between_chunks: true
    auto_fix: true
    continue_on_error: false
    timeout_per_req: 180  # seconds

  output:
    format: yaml
    report_format: markdown
    # NEW: File splitting strategy
    max_file_size_kb: 66
    split_strategy: auto  # auto, single, nested

  validation:
    skip_validation: false
    fix_iterations_max: 3
    # NEW: Enhanced validation
    require_all_13_sections: true
    require_three_interface_levels: true
    require_threshold_registry: true
    require_req_implementations: true
    require_nested_req_paths: true

  traceability:
    # NEW: 9-layer cumulative tags
    required_layers: 9
    include_threshold_references: true
yaml
spec_autopilot:
  version: "2.0"

  scoring:
    spec_ready_min: 90
    tasks_ready_min: 90
    strict_mode: false
    # 新增:7个组件的评分权重
    scoring_weights:
      interface_completeness: 25  # 定义了所有3个层级
      data_models: 20             # Pydantic + JSON Schema
      validation_rules: 15        # 输入/输出验证
      error_handling: 15          # 含HTTP状态码的错误目录
      test_approach: 10           # 单元 + 集成测试
      traceability: 10            # 所有9个累积标签
      performance_specs: 5        # 带阈值的延迟目标

  execution:
    max_parallel: 3        # 硬限制 - 请勿超出
    chunk_size: 3          # 每个批次的文档数
    pause_between_chunks: true
    auto_fix: true
    continue_on_error: false
    timeout_per_req: 180  # 秒

  output:
    format: yaml
    report_format: markdown
    # 新增:文件拆分策略
    max_file_size_kb: 66
    split_strategy: auto  # auto, single, nested

  validation:
    skip_validation: false
    fix_iterations_max: 3
    # 新增:增强验证
    require_all_13_sections: true
    require_three_interface_levels: true
    require_threshold_registry: true
    require_req_implementations: true
    require_nested_req_paths: true

  traceability:
    # 新增:9个层级的累积标签
    required_layers: 9
    include_threshold_references: true

7-Component TASKS-Ready Scoring

7组件TASKS就绪评分

ComponentWeightCriteria
Interface Completeness25%external_apis, internal_apis, classes defined
Data Models20%Pydantic code + JSON Schema present
Validation Rules15%Input/output validation specified
Error Handling15%Error catalog with HTTP status codes
Test Approach10%Unit + integration tests in req_implementations
Traceability10%All 9 cumulative tags populated
Performance Specs5%Latency targets with @threshold references
Score Display Format:
✅ 95% (Target: ≥90%)  # Passing
🟡 87% (Target: ≥90%)  # Near threshold
❌ 75% (Target: ≥90%)  # Failing

组件权重标准
接口完整性25%定义了external_apis、internal_apis、classes
数据模型20%存在Pydantic代码 + JSON Schema
验证规则15%指定了输入/输出验证
错误处理15%含HTTP状态码的错误目录
测试方法10%req_implementations中有单元 + 集成测试
可追溯性10%所有9个累积标签已填充
性能规格5%带@threshold引用的延迟目标
分数显示格式:
✅ 95% (目标: ≥90%)  # 通过
🟡 87% (目标: ≥90%)  # 接近阈值
❌ 75% (目标: ≥90%)  # 未通过

Context Management

上下文管理

Chunked Parallel Execution (MANDATORY)

分块并行执行(必填)

CRITICAL: To prevent conversation context overflow errors ("Prompt is too long", "Conversation too long"), all autopilot operations MUST follow chunked execution rules:
Chunk Size Limit: Maximum 3 documents per chunk
Chunking Rules:
  1. Chunk Formation: Group REQ-derived SPEC documents into chunks of maximum 3 at a time
  2. Sequential Chunk Processing: Process one chunk at a time, completing all documents in a chunk before starting the next
  3. Context Pause: After completing each chunk, provide a summary and pause for user acknowledgment
  4. Progress Tracking: Display chunk progress (e.g., "Chunk 2/4: Processing SPEC-04, SPEC-05, SPEC-06...")
Why Chunking is Required:
  • Prevents "Conversation too long" errors during batch processing
  • Allows context compaction between chunks
  • Enables recovery from failures without losing all progress
  • Provides natural checkpoints for user review
Chunk Completion Template:
markdown
undefined
关键: 为防止对话上下文溢出错误("提示过长"、"对话过长"),所有自动化工具操作必须遵循分块执行规则:
分块大小限制: 每个批次最多3个文档
分块规则:
  1. 批次形成: 将REQ派生的SPEC文档分组为最多3个文档的批次
  2. 批次顺序处理: 一次处理一个批次,完成一个批次的所有文档后再开始下一个
  3. 上下文暂停: 完成每个批次后,提供摘要并暂停以等待用户确认
  4. 进度跟踪: 显示批次进度(例如:"批次2/4:正在处理SPEC-04、SPEC-05、SPEC-06...")
分块的必要性:
  • 批量处理时防止"对话过长"错误
  • 允许批次间的上下文压缩
  • 故障恢复时不会丢失所有进度
  • 为用户提供自然的检查点
批次完成模板:
markdown
undefined

Chunk N/M Complete

批次N/M完成

Generated:
  • SPEC-XX: TASKS-Ready Score 94%
  • SPEC-YY: TASKS-Ready Score 92%
  • SPEC-ZZ: TASKS-Ready Score 95%
Proceeding to next chunk...

---
已生成:
  • SPEC-XX: TASKS就绪评分94%
  • SPEC-YY: TASKS就绪评分92%
  • SPEC-ZZ: TASKS就绪评分95%
正在进入下一批次...

---

Execution Modes

执行模式

Single SPEC Mode

单SPEC模式

Generate SPEC from one REQ document.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --req docs/REQ/REQ-01_authentication.md \
  --output docs/SPEC/ \
  --id 01
从一个REQ文档生成SPEC。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --req docs/REQ/REQ-01_authentication.md \
  --output docs/SPEC/ \
  --id 01

Batch Mode

批量模式

Generate SPEC from multiple REQ documents.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --batch config/spec_batch.yaml \
  --output docs/SPEC/
从多个REQ文档生成SPEC。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --batch config/spec_batch.yaml \
  --output docs/SPEC/

Dry Run Mode

试运行模式

Preview execution plan without generating files.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --req docs/REQ/ \
  --dry-run
预览执行计划但不生成文件。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
  --req docs/REQ/ \
  --dry-run

Review Mode (v2.1)

审查模式(v2.1)

Validate existing SPEC documents and generate a quality report without modification.
Purpose: Audit existing SPEC documents for compliance, quality scores, and identify issues.
Command:
bash
undefined
验证现有SPEC文档并生成质量报告,不修改文档。
用途: 审计现有SPEC文档的合规性、质量评分并识别问题。
命令:
bash
undefined

Review single SPEC

审查单个SPEC

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode review
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode review

Review all SPECs

审查所有SPEC

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md

**Review Process**:

```mermaid
flowchart TD
    A[Input: Existing SPEC] --> B[Load YAML Files]
    B --> C[Validate YAML Syntax]
    C --> D[Check 13 Required Sections]
    D --> E[Validate 3-Level Interfaces]
    E --> F[Check Threshold References]
    F --> G[Calculate TASKS-Ready Score]
    G --> H{Generate Report}
    H --> I[Fixable Issues List]
    H --> J[Manual Review Items]
    H --> K[7-Component Breakdown]
    I --> L[Output: Review Report]
    J --> L
    K --> L
Review Report Structure:
markdown
undefined
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md

**审查流程**:

```mermaid
flowchart TD
    A[Input: Existing SPEC] --> B[Load YAML Files]
    B --> C[Validate YAML Syntax]
    C --> D[Check 13 Required Sections]
    D --> E[Validate 3-Level Interfaces]
    E --> F[Check Threshold References]
    F --> G[Calculate TASKS-Ready Score]
    G --> H{Generate Report}
    H --> I[Fixable Issues List]
    H --> J[Manual Review Items]
    H --> K[7-Component Breakdown]
    I --> L[Output: Review Report]
    J --> L
    K --> L
审查报告结构:
markdown
undefined

SPEC Review Report: SPEC-01.yaml

SPEC审查报告: SPEC-01.yaml

Summary

摘要

  • TASKS-Ready Score: 87% 🟡
  • Total Issues: 9
  • Auto-Fixable: 6
  • Manual Review: 3
  • TAS就绪评分: 87% 🟡
  • 总问题数: 9
  • 可自动修复: 6
  • 需手动审查: 3

7-Component Score Breakdown

7组件评分明细

ComponentScoreStatus
Interface Completeness23/25🟡
Data Models18/20🟡
Validation Rules14/15
Error Handling13/15🟡
Test Approach9/10
Traceability8/10🟡
Performance Specs4/5🟡
组件分数状态
接口完整性23/25🟡
数据模型18/20🟡
验证规则14/15
错误处理13/15🟡
测试方法9/10
可追溯性8/10🟡
性能规格4/5🟡

Section Completeness

章节完整性

SectionPresentStatus
metadataComplete
traceabilityMissing @ctr tag
interfaces🟡Missing internal_apis
data_modelsComplete
validation_rulesComplete
error_handlingComplete
configurationComplete
performance🟡Hardcoded values
behaviorComplete
behavioral_examplesComplete
architectureComplete
operationsComplete
req_implementationsMissing
章节是否存在状态
metadata完整
traceability缺失@ctr标签
interfaces🟡缺失internal_apis
data_models完整
validation_rules完整
error_handling完整
configuration完整
performance🟡硬编码值
behavior完整
behavioral_examples完整
architecture完整
operations完整
req_implementations缺失

v2.0 Compliance

v2.0合规性

CheckStatusDetails
13 Sections PresentMissing req_implementations
Three Interface Levels🟡Missing internal_apis
Threshold RegistryPresent
Nested REQ PathsCorrect format
9-Layer Traceability🟡Missing @ctr
@threshold Format2 hardcoded values
检查项状态详情
13个章节均存在缺失req_implementations
三级接口🟡缺失internal_apis
阈值注册表存在
嵌套REQ路径格式正确
9层级可追溯性🟡缺失@ctr
@threshold格式2个硬编码值

Auto-Fixable Issues

可自动修复的问题

#IssueLocationFix Action
1Missing @ctr tagtraceabilityAdd placeholder @ctr reference
2Hardcoded latencyperformance.latency_targetsReplace with @threshold:perf.api.p95
3Missing req_implementationsrootAdd template section
............
#问题位置修复操作
1缺失@ctr标签traceability添加占位符@ctr引用
2硬编码延迟值performance.latency_targets替换为@threshold:perf.api.p95
3缺失req_implementations根节点添加模板章节
............

Manual Review Required

需手动审查

#IssueLocationReason
1Missing internal_apisinterfacesArchitecture decision needed
2Incomplete behaviorbehavior.login_flowDomain knowledge required
............

**Review Configuration**:

```yaml
review_mode:
  enabled: true
  checks:
    - yaml_syntax              # Valid YAML structure
    - section_completeness     # All 13 sections present
    - interface_levels         # 3-level interface hierarchy
    - threshold_references     # @threshold format
    - cumulative_tags          # 9-layer traceability
    - score_calculation        # TASKS-Ready score
    - file_size                # <66KB check
  output:
    format: markdown
    include_fix_suggestions: true
  thresholds:
    pass: 90
    warning: 85
    fail: 0
#问题位置原因
1缺失internal_apisinterfaces需架构决策
2行为不完整behavior.login_flow需领域知识
............

**审查配置**:

```yaml
review_mode:
  enabled: true
  checks:
    - yaml_syntax              # 有效的YAML结构
    - section_completeness     # 所有13个章节均存在
    - interface_levels         # 三级接口层级
    - threshold_references     # @threshold格式
    - cumulative_tags          # 9层级可追溯性
    - score_calculation        # TASKS就绪评分
    - file_size                # <66KB检查
  output:
    format: markdown
    include_fix_suggestions: true
  thresholds:
    pass: 90
    warning: 85
    fail: 0

Fix Mode (v2.1)

修复模式(v2.1)

Auto-repair existing SPEC documents while preserving manual content.
Purpose: Apply automated fixes to SPEC documents to improve quality scores and compliance.
Command:
bash
undefined
自动修复现有SPEC文档,同时保留手动内容。
用途: 对SPEC文档应用自动修复以提高质量评分和合规性。
命令:
bash
undefined

Fix single SPEC

修复单个SPEC

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix

Fix with backup

修复并备份

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup

Fix specific issue types only

仅修复特定类型的问题

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"

Dry-run fix (preview changes)

试运行修复(预览更改)

python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run

**Fix Categories and Actions**:

| Category | Issue | Auto-Fix Action | Preserves Content |
|----------|-------|-----------------|-------------------|
| **Sections** | Missing req_implementations | Add template section | ✅ |
| **Sections** | Missing threshold_references | Add template section | ✅ |
| **Sections** | Missing metadata fields | Add required fields | ✅ |
| **Thresholds** | Hardcoded numeric values | Replace with @threshold:xxx | ✅ |
| **Thresholds** | Invalid @threshold format | Convert to category.field format | ✅ |
| **Traceability** | Missing cumulative tags | Add with placeholder references | ✅ |
| **Traceability** | Wrong REQ path format | Convert to nested format | ✅ |
| **Interfaces** | Missing level placeholder | Add template structure | ✅ |
| **Interfaces** | Missing method signatures | Flag for manual (content needed) | N/A |
| **YAML** | Formatting issues | Auto-format with ruamel.yaml | ✅ |
| **Score** | Missing TASKS-Ready score | Calculate and insert | ✅ |

**Content Preservation Rules**:

1. **Never delete** existing interface definitions
2. **Never modify** method signatures or logic
3. **Never change** data model schemas
4. **Only add** missing sections and metadata
5. **Only replace** hardcoded values with threshold references
6. **Backup first** if `--backup` flag is set

**Fix Report Structure**:

```markdown
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run

**修复类别与操作**:

| 类别 | 问题 | 自动修复操作 | 保留内容 |
|----------|-------|-----------------|-------------------|
| **章节** | 缺失req_implementations | 添加模板章节 | ✅ |
| **章节** | 缺失threshold_references | 添加模板章节 | ✅ |
| **章节** | 缺失metadata字段 | 添加必填字段 | ✅ |
| **阈值** | 硬编码数值 | 替换为@threshold:xxx | ✅ |
| **阈值** | 无效@threshold格式 | 转换为category.field格式 | ✅ |
| **可追溯性** | 缺失累积标签 | 添加占位符引用 | ✅ |
| **可追溯性** | 错误的REQ路径格式 | 转换为嵌套格式 | ✅ |
| **接口** | 缺失层级占位符 | 添加模板结构 | ✅ |
| **接口** | 缺失方法签名 | 标记为需手动处理(需内容) | N/A |
| **YAML** | 格式问题 | 用ruamel.yaml自动格式化 | ✅ |
| **评分** | 缺失TASKS就绪评分 | 计算并插入 | ✅ |

**内容保留规则**:

1. **绝不删除**现有接口定义
2. **绝不修改**方法签名或逻辑
3. **绝不更改**数据模型 schema
4. **仅添加**缺失的章节和元数据
5. **仅替换**硬编码值为阈值引用
6. 若设置`--backup`标志则**先备份**

**修复报告结构**:

```markdown

SPEC Fix Report: SPEC-01.yaml

SPEC修复报告: SPEC-01.yaml

Summary

摘要

  • Before TASKS-Ready Score: 87% 🟡
  • After TASKS-Ready Score: 94% ✅
  • Issues Fixed: 6
  • Issues Remaining: 3 (manual review required)
  • 修复前TAS就绪评分: 87% 🟡
  • 修复后TAS就绪评分: 94% ✅
  • 已修复问题数: 6
  • 剩余问题数: 3(需手动审查)

Fixes Applied

已应用的修复

#IssueLocationFix Applied
1Missing req_implementationsrootAdded template section
2Hardcoded latencyperformance.latency_targetsReplaced with @threshold:perf.api.p95
3Missing @ctr tagtraceabilityAdded @ctr: CTR.01.16.01
............
#问题位置应用的修复
1缺失req_implementations根节点添加模板章节
2硬编码延迟值performance.latency_targets替换为@threshold:perf.api.p95
3缺失@ctr标签traceability添加@ctr: CTR.01.16.01
............

Files Modified

修改的文件

  • docs/SPEC/SPEC-01.yaml
  • docs/SPEC/SPEC-01.yaml

Backup Location

备份位置

  • tmp/backup/SPEC-01_20260209_143022.yaml
  • tmp/backup/SPEC-01_20260209_143022.yaml

7-Component Score Impact

7组件评分影响

ComponentBeforeAfterDelta
Interface Completeness23/2524/25+1
Data Models18/2018/200
Validation Rules14/1514/150
Error Handling13/1513/150
Test Approach9/1010/10+1
Traceability8/1010/10+2
Performance Specs4/55/5+1
组件修复前修复后变化值
接口完整性23/2524/25+1
数据模型18/2018/200
验证规则14/1514/150
错误处理13/1513/150
测试方法9/1010/10+1
可追溯性8/1010/10+2
性能规格4/55/5+1

Next Steps

下一步

  1. Add internal_apis level to interfaces section
  2. Complete behavior.login_flow pseudocode
  3. Re-run validation to confirm score

**Fix Configuration**:

```yaml
fix_mode:
  enabled: true
  backup:
    enabled: true
    location: "tmp/backup/"
    retention_days: 7

  fix_categories:
    sections: true           # Missing required sections
    thresholds: true         # @threshold references
    traceability: true       # Cumulative tags
    interfaces: false        # Interface placeholders (risky)
    yaml: true               # YAML formatting

  preservation:
    interfaces: true         # Never modify existing interfaces
    data_models: true        # Never modify schemas
    behavior: true           # Never modify logic
    comments: true           # Preserve YAML comments

  validation:
    re_validate_after_fix: true
    require_score_improvement: false
    max_fix_iterations: 3
Command Line Options (Review/Fix):
OptionModeDefaultDescription
--mode review
Review-Run review mode only
--mode fix
Fix-Run fix mode
--output-report
BothautoReport output path
--backup
FixtrueCreate backup before fixing
--fix-types
FixallComma-separated fix categories
--dry-run
FixfalsePreview fixes without applying
--preserve-all
FixfalseExtra cautious preservation

  1. 为interfaces章节添加internal_apis层级
  2. 完善behavior.login_flow伪代码
  3. 重新运行验证以确认评分

**修复配置**:

```yaml
fix_mode:
  enabled: true
  backup:
    enabled: true
    location: "tmp/backup/"
    retention_days: 7

  fix_categories:
    sections: true           # 缺失的必填章节
    thresholds: true         # @threshold引用
    traceability: true       # 累积标签
    interfaces: false        # 接口占位符(有风险)
    yaml: true               # YAML格式化

  preservation:
    interfaces: true         # 绝不修改现有接口
    data_models: true        # 绝不修改schema
    behavior: true           # 绝不修改逻辑
    comments: true           # 保留YAML注释

  validation:
    re_validate_after_fix: true
    require_score_improvement: false
    max_fix_iterations: 3
命令行选项(审查/修复):
选项模式默认值描述
--mode review
审查-仅运行审查模式
--mode fix
修复-运行修复模式
--output-report
两者auto报告输出路径
--backup
修复true修复前创建备份
--fix-types
修复all逗号分隔的修复类别
--dry-run
修复false预览修复但不应用
--preserve-all
修复false额外谨慎的内容保留

Related Resources

相关资源

  • SPEC Skill:
    .claude/skills/doc-spec/SKILL.md
  • SPEC Validator:
    .claude/skills/doc-spec-validator/SKILL.md
  • Naming Standards:
    .claude/skills/doc-naming/SKILL.md
  • Quality Advisor:
    .claude/skills/quality-advisor/SKILL.md
  • SPEC Template:
    ai_dev_flow/09_SPEC/SPEC-TEMPLATE.yaml

  • SPEC技能:
    .claude/skills/doc-spec/SKILL.md
  • SPEC验证器:
    .claude/skills/doc-spec-validator/SKILL.md
  • 命名标准:
    .claude/skills/doc-naming/SKILL.md
  • 质量顾问:
    .claude/skills/quality-advisor/SKILL.md
  • SPEC模板:
    ai_dev_flow/09_SPEC/SPEC-TEMPLATE.yaml

Validation Rules (v2.0)

验证规则(v2.0)

CheckRequirementError Code
13 SectionsAll required sections presentSPEC-E030
Three Interface Levelsexternal_apis, internal_apis, classesSPEC-E031
Threshold Registrythreshold_references section presentSPEC-E032
REQ Implementationreq_implementations section presentSPEC-E033
Nested REQ Paths
../07_REQ/SYS-XX_domain/REQ-XX.YY.md
format
SPEC-E034
7-Component ScoreAll components calculatedSPEC-E035
File Size<66KB or split into micro-SPECsSPEC-E036
9-Layer TraceabilityAll 9 cumulative_tags populatedSPEC-E037
Threshold Format
@threshold:category.field
syntax
SPEC-E038

检查项要求错误编码
13个章节所有必填章节均存在SPEC-E030
三级接口external_apis、internal_apis、classesSPEC-E031
阈值注册表存在threshold_references章节SPEC-E032
REQ实现存在req_implementations章节SPEC-E033
嵌套REQ路径
../07_REQ/SYS-XX_domain/REQ-XX.YY.md
格式
SPEC-E034
7组件评分所有组件均已计算SPEC-E035
文件大小<66KB或拆分为微SPECSPEC-E036
9层级可追溯性所有9个累积标签均已填充SPEC-E037
阈值格式
@threshold:category.field
语法
SPEC-E038

File Splitting Strategy

文件拆分策略

ConditionStrategyResult
<66KBSingle file
SPEC-NN.yaml
>66KBSplit
SPEC-NN.01.yaml
,
SPEC-NN.02.yaml
>3 splitsNested folder
SPEC-NN_module/
with sub-files

条件策略结果
<66KB单个文件
SPEC-NN.yaml
>66KB拆分
SPEC-NN.01.yaml
,
SPEC-NN.02.yaml
>3个拆分文件嵌套文件夹
SPEC-NN_module/
及子文件

Review Document Standards (v2.2)

审查文档标准(v2.2)

Review reports generated by this skill are formal project documents and MUST comply with shared standards.
Reference: See
REVIEW_DOCUMENT_STANDARDS.md
in the skills directory for complete requirements.
Key Requirements:
  1. Storage Location: Same folder as the reviewed SPEC document
  2. File Naming:
    SPEC-NN.R_review_report.md
  3. YAML Frontmatter: Required with
    artifact_type: SPEC-REVIEW
    ,
    layer: 9
  4. Score Field:
    tasks_ready_score_claimed
    /
    tasks_ready_score_validated
  5. Parent Reference: Must link to parent SPEC document
Example Location (ALWAYS use nested folders):
undefined
该技能生成的审查报告属于正式项目文档,必须符合共享标准。
参考: 技能目录中的
REVIEW_DOCUMENT_STANDARDS.md
包含完整要求。
关键要求:
  1. 存储位置: 与被审查的SPEC文档同一文件夹
  2. 文件命名:
    SPEC-NN.R_review_report.md
  3. YAML前置元数据: 必填,包含
    artifact_type: SPEC-REVIEW
    ,
    layer: 9
  4. 分数字段:
    tasks_ready_score_claimed
    /
    tasks_ready_score_validated
  5. 父引用: 必须链接到父SPEC文档
示例位置(始终使用嵌套文件夹):
undefined

Monolithic SPEC (<20k tokens):

单体SPEC(<20k tokens):

docs/09_SPEC/SPEC-03_f3_observability/ ├── SPEC-03_f3_observability.yaml # ← Single YAML file ├── SPEC-03.R_review_report_v001.md # ← Review report ├── SPEC-03.F_fix_report_v001.md # ← Fix report └── .drift_cache.json # ← Drift cache
docs/09_SPEC/SPEC-03_f3_observability/ ├── SPEC-03_f3_observability.yaml # ← 单个YAML文件 ├── SPEC-03.R_review_report_v001.md # ← 审查报告 ├── SPEC-03.F_fix_report_v001.md # ← 修复报告 └── .drift_cache.json # ← 漂移缓存

Split SPEC (≥20k tokens or multiple components):

拆分后的SPEC(≥20k tokens或多组件):

docs/09_SPEC/SPEC-01_f1_iam/ ├── SPEC-01.01_authentication.yaml # ← Component 1 ├── SPEC-01.02_authorization.yaml # ← Component 2 ├── SPEC-01.03_user_profile.yaml # ← Component 3 ├── SPEC-01.R_review_report_v001.md # ← Review report ├── SPEC-01.F_fix_report_v001.md # ← Fix report └── .drift_cache.json # ← Drift cache

**Nested Folder Rule**: ALL SPECs use nested folders (`SPEC-NN_{slug}/`) regardless of size. This keeps YAML files and companion files (review reports, fix reports, drift cache) organized together.

---
docs/09_SPEC/SPEC-01_f1_iam/ ├── SPEC-01.01_authentication.yaml # ← 组件1 ├── SPEC-01.02_authorization.yaml # ← 组件2 ├── SPEC-01.03_user_profile.yaml # ← 组件3 ├── SPEC-01.R_review_report_v001.md # ← 审查报告 ├── SPEC-01.F_fix_report_v001.md # ← 修复报告 └── .drift_cache.json # ← 漂移缓存

**嵌套文件夹规则**: 所有SPEC无论大小均使用嵌套文件夹(`SPEC-NN_{slug}/`)。这可将YAML文件和配套文件(审查报告、修复报告、漂移缓存)组织在一起。

---

Version History

版本历史

VersionDateChanges
2.32026-02-11Smart Document Detection: Added automatic document type recognition; Self-type input (SPEC-NN) triggers review mode; Multiple upstream-type inputs (REQ/CTR-NN) trigger generate-if-missing or find-and-review; Updated input patterns table with type-based actions
2.22026-02-10Review & Fix Cycle: Replaced Phase 5 with iterative Review -> Fix cycle using
doc-spec-reviewer
and
doc-spec-fixer
; Added
doc-spec-fixer
skill dependency; Added iteration control (max 3 cycles); Added quality checks (section completeness, three-level interface coverage, element ID compliance, TASKS-Ready report); Added traceability matrix update step
2.12026-02-10Added Review Document Standards section; Review reports now stored alongside reviewed documents with proper YAML frontmatter and parent references
2.02026-02-09Added Review Mode for validating existing SPEC documents without modification; Added Fix Mode for auto-repairing SPEC documents while preserving manual content; Added fix categories (sections, thresholds, traceability, interfaces, yaml); Added content preservation rules; Added backup functionality for fix operations; Added review/fix report generation with 7-component score impact; Added execution modes section (single, batch, dry-run, review, fix)
1.12026-02-09Added 13-section YAML structure; Added 9-layer cumulative traceability; Added three-level interface specification (external, internal, classes); Added threshold registry pattern; Added req_implementations section for REQ-to-implementation bridges; Added 7-component TASKS-Ready scoring; Added file splitting strategy (<66KB); Added validation rules SPEC-E030 to SPEC-E038
1.02026-02-08Initial skill creation with 5-phase workflow; Integrated doc-naming, doc-spec, quality-advisor, doc-spec-validator
版本日期变更
2.32026-02-11智能文档检测: 添加自动文档类型识别;自身类型输入(SPEC-NN)触发审查模式;多上游类型输入(REQ/CTR-NN)触发缺失则生成或查找并审查;更新输入模式表格以包含基于类型的操作
2.22026-02-10审查与修复周期: 用
doc-spec-reviewer
doc-spec-fixer
的迭代审查→修复周期替换阶段5;添加
doc-spec-fixer
技能依赖;添加迭代控制(最多3个周期);添加质量检查(章节完整性、三级接口覆盖、元素ID合规性、TASKS就绪报告);添加可追溯性矩阵更新步骤
2.12026-02-10添加审查文档标准章节;审查报告现在与被审查文档存储在一起,包含正确的YAML前置元数据和父引用
2.02026-02-09添加用于验证现有SPEC文档且不修改的审查模式;添加用于自动修复SPEC文档同时保留手动内容的修复模式;添加修复类别(章节、阈值、可追溯性、接口、yaml);添加内容保留规则;添加修复操作的备份功能;添加包含7组件评分影响的审查/修复报告生成;添加执行模式章节(单文件、批量、试运行、审查、修复)
1.12026-02-09添加13章节YAML结构;添加9层级累积可追溯性;添加三级接口规格(外部、内部、类);添加阈值注册表模式;添加用于REQ到实现桥梁的req_implementations章节;添加7组件TASKS就绪评分;添加文件拆分策略(<66KB);添加验证规则SPEC-E030至SPEC-E038
1.02026-02-08初始技能创建,包含5阶段工作流;集成doc-naming、doc-spec、quality-advisor、doc-spec-validator