feature-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
[IMPORTANT] Use
TaskCreate
to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ATTENTION ask user whether to skip.
【重要提示】 开始所有工作前必须使用
TaskCreate
将全部任务拆分为小任务,包括每个文件读取的单独任务。这可以避免长文件导致的上下文丢失。对于简单任务,AI必须主动询问用户是否可以跳过拆分步骤。

Quick Summary

快速概要

Goal: Generate comprehensive 26-section business feature documentation with mandatory code evidence for all test cases, plus AI companion file.
Workflow:
  1. Detect & Gather — Auto-detect modules from git changes OR user-specified module, read existing docs
  2. Investigate Code — Grep/glob codebase to gather evidence (
    file:line
    format) for every test case
  3. Write Documentation — Follow exact 26-section structure, place in
    docs/business-features/{Module}/
  4. Generate AI Companion — Create
    .ai.md
    file (max 300 lines) with domain model, file locations, key expressions
  5. Verification — 3-pass system: evidence audit, domain model verification, cross-reference audit
Key Rules:
  • EVERY test case MUST ATTENTION have verifiable code evidence (
    FilePath:LineNumber
    ), no exceptions
  • Output must have exactly 26 sections matching the master template
  • Always update CHANGELOG.md and Version History (Section 26) when modifying docs
  • When writing Section 17 test cases: include an
    IntegrationTest
    field pointing to the test file and method name. Format:
    IntegrationTest: Orders/OrderCommandIntegrationTests.cs::{MethodName}
    . If no integration test exists yet, set
    Status: Untested
    .
  • Verify every TC-{MOD}-XXX in Section 17 has a corresponding
    [Trait("TestSpec", "TC-{MOD}-XXX")]
    in the integration test codebase. If missing, flag as
    Status: Untested
    .
  • If third verification pass finds >5 issues, HALT and re-run verification
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
  • docs/project-reference/domain-entities-reference.md
    — Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models) (content auto-injected by hook — check for [Injected: ...] header before reading)
目标:生成包含26个完整章节的业务功能文档,要求所有测试用例必须附带代码证据,同时生成AI配套文件。
工作流
  1. 检测与收集 — 从Git变更自动检测模块,或使用用户指定的模块,读取现有文档
  2. 代码调研 — 用Grep/glob扫描代码库,为每个测试用例收集
    文件:行号
    格式的证据
  3. 编写文档 — 严格遵循26章节结构,写入
    docs/business-features/{Module}/
    目录
  4. 生成AI配套文件 — 创建最多300行的
    .ai.md
    文件,包含领域模型、文件位置、关键表达式
  5. 验证 — 三重验证体系:证据审计、领域模型验证、交叉引用审计
核心规则
  • 每个测试用例必须附带可验证的代码证据(
    文件路径:行号
    ),无例外
  • 输出必须严格匹配主模板的26个章节结构
  • 修改文档时必须更新CHANGELOG.md和第26章的版本历史
  • 编写第17章测试用例时:必须包含
    IntegrationTest
    字段,指向测试文件和方法名,格式为
    IntegrationTest: Orders/OrderCommandIntegrationTests.cs::{方法名}
    。如果暂无集成测试,设置
    Status: Untested
  • 验证第17章每个TC-{MOD}-XXX在集成测试代码库中都有对应的
    [Trait("TestSpec", "TC-{MOD}-XXX")]
    ,如果缺失标记为
    Status: Untested
  • 如果第三次验证发现超过5个问题,立即终止并重新运行验证
保持怀疑,应用批判性思维、顺序思维。每个声明都需要可追溯的证明,置信度需超过80%。
  • docs/project-reference/domain-entities-reference.md
    — 领域实体目录、关系、跨服务同步(任务涉及业务实体/模型时读取,内容由钩子自动注入,读取前先检查[Injected: ...]头部)

Project Pattern Discovery

项目模式发现

Before implementation, search your codebase for project-specific patterns:
  • Search for:
    business-features
    ,
    detailed-features
    ,
    feature-docs-template
  • Look for: existing feature doc folders, 26-section templates, AI companion files
MANDATORY IMPORTANT MUST ATTENTION Read the
feature-docs-reference.md
companion doc for project-specific patterns and code examples. If file not found, continue with search-based discovery above.
实现前先在代码库中搜索项目特有的模式:
  • 搜索关键词:
    business-features
    detailed-features
    feature-docs-template
  • 查找内容:现有功能文档文件夹、26章节模板、AI配套文件
强制要求 重要 必须注意 读取
feature-docs-reference.md
配套文档获取项目特有模式和代码示例。 如果找不到该文件,继续使用上述搜索方式发现模式。

Feature Documentation Generation & Verification

功能文档生成与验证

Generate comprehensive feature documentation following project conventions and folder structure.
GOLD STANDARD References:
Search your codebase for existing feature docs to use as reference:
bash
find docs/business-features -name "README.*.md" -type f | head -5
Template File:
docs/templates/detailed-feature-docs-template.md
AI Companion Template:
docs/templates/feature-docs-ai-template.md

遵循项目规范和文件夹结构生成完整的功能文档。
黄金标准参考
在代码库中搜索现有功能文档作为参考:
bash
find docs/business-features -name "README.*.md" -type f | head -5
模板文件
docs/templates/detailed-feature-docs-template.md
AI配套文件模板
docs/templates/feature-docs-ai-template.md

[CRITICAL] MANDATORY CODE EVIDENCE RULE

【关键】强制代码证据规则

EVERY test case MUST ATTENTION have verifiable code evidence. This is non-negotiable.
每个测试用例必须附带可验证的代码证据,该要求不可协商。

Evidence Format

证据格式

markdown
**Evidence**: `{RelativeFilePath}:{LineNumber}` or `{RelativeFilePath}:{StartLine}-{EndLine}`
markdown
**证据**`{相对文件路径}:{行号}``{相对文件路径}:{起始行号}-{结束行号}`

Valid vs Invalid Evidence

有效与无效证据对比

ValidInvalid
ErrorMessage.cs:83
{FilePath}:{LineRange}
(template)
Handler.cs:42-52
SomeFile.cs
(no line)
interviews.service.ts:115-118
"Based on CQRS pattern" (vague)

有效证据无效证据
ErrorMessage.cs:83
{FilePath}:{LineRange}
(模板占位符)
Handler.cs:42-52
SomeFile.cs
(无行号)
interviews.service.ts:115-118
"基于CQRS模式" (模糊描述)

Output Structure

输出结构

All documentation MUST ATTENTION be placed in the correct folder structure:
docs/
├── BUSINESS-FEATURES.md              # Master index (UPDATE if new module)
├── templates/
│   └── detailed-feature-docs-template.md  # MASTER TEMPLATE
└── business-features/
    ├── {Module}/                     # One folder per service/module in your project
    │   ├── README.md                 # Complete module documentation
    │   ├── INDEX.md                  # Navigation hub
    │   ├── API-REFERENCE.md          # Endpoint documentation
    │   ├── TROUBLESHOOTING.md        # Issue resolution guide
    │   └── detailed-features/
    │       ├── README.{FeatureName}.md     # Comprehensive (human-facing, 1000+ lines)
    │       └── README.{FeatureName}.ai.md  # AI companion (code-focused, 300-500 lines)
    └── ...
所有文档必须放在正确的文件夹结构中:
docs/
├── BUSINESS-FEATURES.md              # 主索引(新增模块时必须更新)
├── templates/
│   └── detailed-feature-docs-template.md  # 主模板
└── business-features/
    ├── {Module}/                     # 项目中每个服务/模块对应一个文件夹
    │   ├── README.md                 # 完整模块文档
    │   ├── INDEX.md                  # 导航中心
    │   ├── API-REFERENCE.md          # 端点文档
    │   ├── TROUBLESHOOTING.md        # 问题解决指南
    │   └── detailed-features/
    │       ├── README.{FeatureName}.md     # 面向人员的完整文档(1000+行)
    │       └── README.{FeatureName}.ai.md  # 面向代码的AI配套文件(300-500行)
    └── ...

Module Mapping

模块映射

Search your codebase to discover the module-to-folder mapping:
bash
undefined
搜索代码库发现模块到文件夹的映射关系:
bash
undefined

Find all service directories

查找所有服务目录

ls -d src/Services/*/
ls -d src/Services/*/

Find all existing feature doc modules

查找所有现有功能文档模块

ls -d docs/business-features/*/

Map each module code to its folder name and service path. Example pattern:

| Module Code | Folder Name | Service Path              |
| ----------- | ----------- | ------------------------- |
| {Module1}   | `{Module1}` | `src/Services/{Module1}/` |
| {Module2}   | `{Module2}` | `src/Services/{Module2}/` |

---
ls -d docs/business-features/*/

将每个模块代码映射到对应的文件夹名和服务路径,示例模式:

| 模块代码 | 文件夹名 | 服务路径                  |
| ----------- | ----------- | ------------------------- |
| {Module1}   | `{Module1}` | `src/Services/{Module1}/` |
| {Module2}   | `{Module2}` | `src/Services/{Module2}/` |

---

MANDATORY 26-SECTION STRUCTURE

强制26章节结构

All feature documentation MUST ATTENTION follow this section order:
#SectionStakeholder Focus
1Executive SummaryPO, BA
2Business ValuePO, BA
3Business RequirementsPO, BA
4Business RulesBA, Dev
5Process FlowsBA, Dev, Architect
6Design ReferenceBA, UX, Dev
7System DesignDev, Architect
8ArchitectureDev, Architect
9Domain ModelDev, Architect
10API ReferenceDev, Architect
11Frontend ComponentsDev
12Backend ControllersDev
13Cross-Service IntegrationDev, Architect
14Security ArchitectureDev, Architect
15Performance ConsiderationsDev, Architect, DevOps
16Implementation GuideDev
17Test SpecificationsQA
18Test Data RequirementsQA
19Edge Cases CatalogQA, Dev
20Regression ImpactQA
21TroubleshootingDev, QA, DevOps
22Operational RunbookDevOps
23Roadmap and DependenciesPO, BA
24Related DocumentationAll
25GlossaryPO, BA
26Version HistoryAll
所有功能文档必须遵循以下章节顺序:
序号章节名称面向受众
1执行摘要产品负责人、业务分析师
2业务价值产品负责人、业务分析师
3业务需求产品负责人、业务分析师
4业务规则业务分析师、开发人员
5流程流业务分析师、开发人员、架构师
6设计参考业务分析师、UX设计师、开发人员
7系统设计开发人员、架构师
8架构开发人员、架构师
9领域模型开发人员、架构师
10API参考开发人员、架构师
11前端组件开发人员
12后端控制器开发人员
13跨服务集成开发人员、架构师
14安全架构开发人员、架构师
15性能考量开发人员、架构师、DevOps
16实现指南开发人员
17测试规范测试人员
18测试数据要求测试人员
19边界用例目录测试人员、开发人员
20回归影响测试人员
21问题排查开发人员、测试人员、DevOps
22运维手册DevOps
23路线图与依赖产品负责人、业务分析师
24相关文档所有人员
25术语表产品负责人、业务分析师
26版本历史所有人员

Stakeholder Quick Navigation

受众快速导航

AudienceSections
Product OwnerExecutive Summary, Business Value, Roadmap
Business AnalystBusiness Requirements, Business Rules, Process Flows, Domain Model
DeveloperArchitecture, Domain Model, API Reference, Implementation Guide
Technical ArchitectSystem Design, Cross-Service Integration, Security, Performance
QA/QCTest Specifications, Test Data, Edge Cases, Regression Impact
DevOps/SupportTroubleshooting, Operational Runbook

受众对应章节
产品负责人执行摘要、业务价值、路线图
业务分析师业务需求、业务规则、流程流、领域模型
开发人员架构、领域模型、API参考、实现指南
技术架构师系统设计、跨服务集成、安全、性能
测试人员测试规范、测试数据、边界用例、回归影响
DevOps/运维支持问题排查、运维手册

Phase 1: Module Detection & Context Gathering

阶段1:模块检测与上下文收集

Step 1.0: Auto-Detect Modules from Git Changes (Default)

步骤1.0:从Git变更自动检测模块(默认)

When no module or feature is explicitly specified, automatically detect affected modules from git changes:
  1. Run
    git diff --name-only HEAD
    (captures both staged and unstaged changes)
  2. If no uncommitted changes, run
    git diff --name-only HEAD~1
    (last commit)
  3. Extract unique module names from changed file paths using the Module Mapping table
  4. For each detected module, check if a business feature doc exists in
    docs/business-features/{Module}/
  5. If docs exist → proceed to Phase 1.5 (Update Mode) for each module
  6. If no docs exist → skip (do not create docs from scratch without explicit user request)
  7. If no service-layer files changed (e.g., only
    .claude/
    ,
    docs/
    , config files) → report "No business feature docs impacted" and exit
Path-to-Module Detection Rules:
Search your codebase to build the path-to-module mapping. Common patterns:
Changed File Path PatternDetected Module
src/Services/{Module}/**
{Module}
{frontend-apps-dir}/{app-name}/**
{Module} (map app name to module)
{frontend-libs-dir}/{domain-lib}/src/{feature}/**
{Module} (map feature to module)
Build a project-specific mapping by examining:
bash
ls -d src/Services/*/
ls -d {frontend-apps-dir}/*/
未明确指定模块或功能时,从Git变更自动检测受影响的模块:
  1. 运行
    git diff --name-only HEAD
    (捕获暂存和未暂存的变更)
  2. 如果没有未提交的变更,运行
    git diff --name-only HEAD~1
    (最近一次提交)
  3. 使用模块映射表从变更文件路径中提取唯一的模块名称
  4. 对每个检测到的模块,检查
    docs/business-features/{Module}/
    下是否存在业务功能文档
  5. 如果文档存在 → 进入**阶段1.5(更新模式)**处理每个模块
  6. 如果文档不存在 → 跳过(无用户明确请求时不要从零创建文档)
  7. 如果没有服务层文件变更(例如仅修改了
    .claude/
    docs/
    、配置文件)→ 报告"无业务功能文档受影响"并退出
路径到模块检测规则
搜索代码库构建路径到模块的映射,常见模式:
变更文件路径模式检测到的模块
src/Services/{Module}/**
{Module}
{frontend-apps-dir}/{app-name}/**
{Module} (将应用名映射到模块)
{frontend-libs-dir}/{domain-lib}/src/{feature}/**
{Module} (将功能映射到模块)
通过以下命令构建项目特有的映射:
bash
ls -d src/Services/*/
ls -d {frontend-apps-dir}/*/

Step 1.1: Identify Target Module

步骤1.1:确定目标模块

Determine which module the feature belongs to by:
  1. User explicitly specifies module name
  2. Feature name/domain implies module (search codebase to verify mapping)
  3. Search codebase for feature-related entities/commands
  4. Auto-detected from git diff (Step 1.0 above) — used when invoked as a workflow step without explicit module
通过以下方式确定功能所属的模块:
  1. 用户明确指定模块名称
  2. 功能名称/领域暗示所属模块(搜索代码库验证映射关系)
  3. 搜索代码库中与功能相关的实体/命令
  4. 从Git diff自动检测(上述步骤1.0)—— 作为无明确模块指定的工作流步骤调用时使用

Step 1.2: Read Existing Documentation

步骤1.2:读取现有文档

Before creating new docs, read existing structure:
  1. Read
    docs/BUSINESS-FEATURES.md
    (master index)
  2. Read
    docs/business-features/{Module}/INDEX.md
    (if exists)
  3. Read
    docs/business-features/{Module}/README.md
    (if exists)
  4. Identify what already exists vs what needs creation/update
创建新文档前,先读取现有结构:
  1. 读取
    docs/BUSINESS-FEATURES.md
    (主索引)
  2. 读取
    docs/business-features/{Module}/INDEX.md
    (如果存在)
  3. 读取
    docs/business-features/{Module}/README.md
    (如果存在)
  4. 识别已有的内容和需要创建/更新的内容

Step 1.3: Codebase Analysis

步骤1.3:代码库分析

Gather evidence from source code:
  • Entities:
    src/Services/{Module}/{Module}.Domain/Entities/
  • Commands:
    src/Services/{Module}/{Module}.Application/UseCaseCommands/
  • Queries:
    src/Services/{Module}/{Module}.Application/UseCaseQueries/
  • Controllers:
    src/Services/{Module}/{Module}.Service/Controllers/
  • Frontend:
    {frontend-apps-dir}/{app-name}/
    or
    {frontend-libs-dir}/{domain-lib}/
从源代码收集证据:
  • 实体
    src/Services/{Module}/{Module}.Domain/Entities/
  • 命令
    src/Services/{Module}/{Module}.Application/UseCaseCommands/
  • 查询
    src/Services/{Module}/{Module}.Application/UseCaseQueries/
  • 控制器
    src/Services/{Module}/{Module}.Service/Controllers/
  • 前端
    {frontend-apps-dir}/{app-name}/
    {frontend-libs-dir}/{domain-lib}/

Step 1.4: Feature Analysis

步骤1.4:功能分析

Build knowledge model in
.ai/workspace/analysis/[feature-name].md
.
.ai/workspace/analysis/[feature-name].md
中构建知识模型。

Discovery Areas

发现范围

  1. Domain Entity Discovery: Entities, value objects, enums
  2. Workflow Discovery: Commands, Queries, Event Handlers, Background Jobs
  3. API Discovery: Controllers, endpoints, DTOs
  4. Frontend Discovery: Components, Services, Stores
  5. Cross-Service Discovery: Message Bus messages, producers, consumers

  1. 领域实体发现:实体、值对象、枚举
  2. 工作流发现:命令、查询、事件处理器、后台任务
  3. API发现:控制器、端点、DTO
  4. 前端发现:组件、服务、存储
  5. 跨服务发现:消息总线消息、生产者、消费者

Phase 1.5: Update Mode (when updating existing docs)

阶段1.5:更新模式(更新现有文档时)

When UPDATING an existing business feature document (not creating from scratch):
更新现有业务功能文档(而非从零创建)时:

Step 1.5.1: Diff Analysis

步骤1.5.1:差异分析

  1. Identify the source of changes (git diff, branch comparison, commit history)
  2. Categorize changes by type: backend entity, command, query, frontend component, i18n, etc.
  3. Map each change to impacted documentation sections (use table below)
  1. 识别变更来源(Git diff、分支对比、提交历史)
  2. 按类型对变更分类:后端实体、命令、查询、前端组件、i18n等
  3. 将每个变更映射到受影响的文档章节(使用下表)

Step 1.5.2: Section Impact Mapping

步骤1.5.2:章节影响映射

Change TypeImpacted Sections
New entity property3 (Business Requirements), 9 (Domain Model), 10 (API Reference)
New API endpoint10 (API Reference), 12 (Backend Controllers), 14 (Security)
New frontend component11 (Frontend Components)
New filter/query3 (Business Requirements), 10 (API Reference)
New i18n keys11 (Frontend Components)
Any new functionality17 (Test Specs), 18 (Test Data), 19 (Edge Cases), 20 (Regression Impact) — MANDATORY
Any change1 (Executive Summary), 26 (Version History) — ALWAYS UPDATE
变更类型受影响章节
新增实体属性3(业务需求)、9(领域模型)、10(API参考)
新增API端点10(API参考)、12(后端控制器)、14(安全)
新增前端组件11(前端组件)
新增筛选/查询3(业务需求)、10(API参考)
新增i18n key11(前端组件)
任何新增功能17(测试规范)、18(测试数据)、19(边界用例)、20(回归影响) — 强制更新
任何变更1(执行摘要)、26(版本历史) — 必须更新

Step 1.5.3: Mandatory Test Coverage (Sections 17-20)

步骤1.5.3:强制测试覆盖(第17-20章)

CRITICAL: When documenting ANY new functionality, you MUST ATTENTION update:
  • Section 17 (Test Specifications): Add test cases (TC-{MOD}-XXX) for new features with GIVEN/WHEN/THEN format. Each TC entry should include:
    markdown
    #### TC-GM-001: Create SMART Goal Successfully
    
    **Priority**: P0-Critical
    **Status**: Tested | Untested
    **IntegrationTest**: `Orders/OrderCommandIntegrationTests.cs::SaveOrder_WhenValidData_ShouldCreateSuccessfully`
    **Evidence**: `{Service}.Application/{Feature}/Commands/Save{Feature}Command.cs:42-68`
  • Section 18 (Test Data): Add seed data required for new test cases
  • Section 19 (Edge Cases): Add edge cases for boundary conditions, error states, permission checks
  • Section 20 (Regression Impact): Add regression risk rows for impacted areas, update test suite counts
Failure to update test sections is a blocking quality issue.
关键:记录任何新增功能时,必须更新:
  • 第17章(测试规范):为新功能添加GIVEN/WHEN/THEN格式的测试用例(TC-{MOD}-XXX),每个TC条目应包含:
    markdown
    #### TC-GM-001: 成功创建SMART目标
    
    **优先级**:P0-最高
    **状态**:已测试 | 未测试
    **IntegrationTest**: `Orders/OrderCommandIntegrationTests.cs::SaveOrder_WhenValidData_ShouldCreateSuccessfully`
    **证据**: `{Service}.Application/{Feature}/Commands/Save{Feature}Command.cs:42-68`
  • 第18章(测试数据):添加新测试用例所需的种子数据
  • 第19章(边界用例):添加边界条件、错误状态、权限检查相关的边界用例
  • 第20章(回归影响):添加受影响区域的回归风险行,更新测试套件计数
未更新测试章节属于阻断性质量问题。

Step 1.5.4: CHANGELOG Entry

步骤1.5.4:CHANGELOG条目

Always create/update
CHANGELOG.md
entry under
[Unreleased]
following Keep a Changelog format.

始终在
[Unreleased]
下按照Keep a Changelog格式创建/更新CHANGELOG.md条目。

Phase 2: Documentation Generation

阶段2:文档生成

Generate at
docs/business-features/{Module}/detailed-features/README.{FeatureName}.md
.
生成到
docs/business-features/{Module}/detailed-features/README.{FeatureName}.md

Key Format Examples

核心格式示例

Business Requirements (FR-XX):
markdown
undefined
业务需求(FR-XX)
markdown
undefined

FR-{MOD}-01: {Requirement Title}

FR-{MOD}-01: {需求标题}

AspectDetails
Description{What this requirement enables}
Scope{Who can use / affected entities}
Evidence
{FilePath}:{LineRange}

**User Stories (US-XX)**:

```markdown
维度详情
描述{该需求支持的功能}
范围{可使用的角色/受影响的实体}
证据
{FilePath}:{LineRange}

**用户故事(US-XX)**:

```markdown

US-{MOD}-01: {Story Title}

US-{MOD}-01: {故事标题}

As a {role} I want {goal/desire} So that {benefit/value}
Acceptance Criteria:
  • AC-01: {Criterion with evidence reference}
  • AC-02: {Criterion with evidence reference}
Related Requirements: FR-{MOD}-01, FR-{MOD}-02 Evidence:
{FilePath}:{LineRange}

**Test Summary Table (MANDATORY)**:

```markdown
| Category    | P0 (Critical) | P1 (High) | P2 (Medium) | P3 (Low) |  Total  |
| ----------- | :-----------: | :-------: | :---------: | :------: | :-----: |
| {Category1} |      {N}      |    {N}    |     {N}     |   {N}    |   {N}   |
| **Total**   |    **{N}**    |  **{N}**  |   **{N}**   | **{N}**  | **{N}** |
Test Case Format (TC-XX):
markdown
undefined
作为 {角色} 我想要 {目标/需求} 以便 {收益/价值}
验收标准
  • AC-01: {带证据引用的标准}
  • AC-02: {带证据引用的标准}
相关需求: FR-{MOD}-01, FR-{MOD}-02 证据:
{FilePath}:{LineRange}

**测试汇总表(强制)**:

```markdown
| 分类    | P0(最高) | P1(高) | P2(中) | P3(低) |  总计  |
| ----------- | :-----------: | :-------: | :---------: | :------: | :-----: |
| {分类1} |      {N}      |    {N}    |     {N}     |   {N}    |   {N}   |
| **总计**   |    **{N}**    |  **{N}**  |   **{N}**   | **{N}**  | **{N}** |
测试用例格式(TC-XX)
markdown
undefined

TC-{MOD}-001: {Test Name} [P0]

TC-{MOD}-001: {测试名称} [P0]

Acceptance Criteria:
  • {Passing criteria 1}
  • {Passing criteria 2}
GIVEN {initial context} WHEN {action performed} THEN {expected outcome}
Edge Cases:
  • {Invalid scenario} → {Expected error/behavior}
Evidence:
{FilePath}:{LineRange}

**Troubleshooting Format**:

```markdown
验收标准
  • {通过标准1}
  • {通过标准2}
GIVEN {初始上下文} WHEN {执行的操作} THEN {预期结果}
边界用例
  • {无效场景} → {预期错误/行为}
证据:
{FilePath}:{LineRange}

**问题排查格式**:

```markdown

{Issue Title}

{问题标题}

Symptoms: {Observable problem}
Causes:
  1. {Cause 1}
  2. {Cause 2}
Resolution:
  • {Step 1}
  • {Step 2}

**Permission Matrix**:

```markdown
| Role  | View | Create | Edit | Delete | Special     |
| ----- | :--: | :----: | :--: | :----: | ----------- |
| Admin |  ✅  |   ✅   |  ✅  |   ✅   | Full access |

症状: {可观察到的问题}
原因
  1. {原因1}
  2. {原因2}
解决方案
  • {步骤1}
  • {步骤2}

**权限矩阵**:

```markdown
| 角色  | 查看 | 创建 | 编辑 | 删除 | 特殊权限     |
| ----- | :--: | :----: | :--: | :----: | ----------- |
| 管理员 |  ✅  |   ✅   |  ✅  |   ✅   | 完全访问 |

Phase 2.5: AI Companion Generation

阶段2.5:AI配套文件生成

Generate AI-agent optimized companion file alongside the comprehensive documentation.
Output:
docs/business-features/{Module}/detailed-features/README.{FeatureName}.ai.md
Template:
docs/templates/detailed-feature-docs-template.ai.md
在完整文档旁生成AI Agent优化的配套文件。
输出
docs/business-features/{Module}/detailed-features/README.{FeatureName}.ai.md
模板
docs/templates/detailed-feature-docs-template.ai.md

AI Companion Structure (10 Sections, ~260 lines)

AI配套文件结构(10章节,约260行)

SectionContentSource from Full Doc
ContextPurpose, entities, serviceExecutive Summary
File LocationsExact paths to all key filesImplementation Guide
Domain ModelProperties, expressionsDomain Model
API ContractsEndpoints, request/response shapesAPI Reference
Business RulesValidation, state transitionsBusiness Rules
PatternsRequired / Anti-patternsArchitecture
IntegrationEvents, dependenciesCross-Service Integration
SecurityAuthorization matrixSecurity Architecture
Test ScenariosKey GIVEN/WHEN/THEN casesTest Specifications
Quick ReferenceDecision tree, code snippetsImplementation Guide
章节内容来源章节
上下文用途、实体、服务执行摘要
文件位置所有关键文件的精确路径实现指南
领域模型属性、表达式领域模型
API契约端点、请求/响应结构API参考
业务规则校验、状态转换业务规则
模式要求/反模式架构
集成事件、依赖跨服务集成
安全权限矩阵安全架构
测试场景核心GIVEN/WHEN/THEN用例测试规范
快速参考决策树、代码片段实现指南

Compression Rules

压缩规则

  1. Tables over prose - Convert paragraphs to table rows
  2. Paths over descriptions -
    File:Line
    over "located in..."
  3. Signatures over examples -
    { id: string } → { entity: Dto }
    over full code
  4. Decisions over explanations - What to do, not why
  1. 表格优先于段落 - 将段落转换为表格行
  2. 路径优先于描述 - 优先使用
    文件:行号
    而非"位于..."
  3. 签名优先于示例 - 优先使用
    { id: string } → { entity: Dto }
    而非完整代码
  4. 决策优先于解释 - 说明要做什么,而非为什么

AI Companion Extended (6-Section Variant, ~420 lines)

AI配套文件扩展版(6章节变体,约420行)

For larger features, use the extended companion format:
  1. Quick Reference (~40 lines) - Module, service, file locations
  2. Domain Model (~80 lines) - Entities, enums, value objects (condensed)
  3. API Contracts (~100 lines) - Signatures with DTOs only
  4. Validation Rules (~80 lines) - BR-XX table format
  5. Service Boundaries (~60 lines) - Cross-service integration
  6. Critical Paths (~60 lines) - Key workflows as decision trees
针对较大的功能,使用扩展配套格式:
  1. 快速参考(约40行)- 模块、服务、文件位置
  2. 领域模型(约80行)- 实体、枚举、值对象(精简版)
  3. API契约(约100行)- 仅包含DTO的签名
  4. 校验规则(约80行)- BR-XX表格格式
  5. 服务边界(约60行)- 跨服务集成
  6. 关键路径(约60行)- 作为决策树的核心工作流

AI Companion Header

AI配套文件头部

markdown
undefined
markdown
undefined

{FeatureName} Feature - AI Context

{FeatureName} 功能 - AI 上下文

AI-optimized context file for code generation tasks. Full documentation: README.{FeatureName}Feature.md Last synced: {YYYY-MM-DD}
undefined
为代码生成任务优化的AI上下文文件。 完整文档: README.{FeatureName}Feature.md 最后同步时间: {YYYY-MM-DD}
undefined

Skip These Sections in AI Companion

AI配套文件需跳过的章节

  • Troubleshooting (operational)
  • Operational Runbook (DevOps)
  • Business Value (stakeholder)
  • Version History (changelog)
  • Glossary (definitions)
  • 问题排查(运维相关)
  • 运维手册(DevOps相关)
  • 业务价值( stakeholders相关)
  • 版本历史(变更日志)
  • 术语表(定义)

AI Companion Quality Check

AI配套文件质量检查

  • File size ≤300 lines (standard) or ≤500 lines (extended)
  • All file paths are exact and current
  • API contracts include request/response shapes
  • Business rules have evidence references
  • Patterns section has required/anti-pattern markers
  • Evidence chain preserved from full doc
  • Links back to comprehensive doc
  • 'Last synced' timestamp included

  • 文件大小 ≤300行(标准版)或 ≤500行(扩展版)
  • 所有文件路径精确且最新
  • API契约包含请求/响应结构
  • 业务规则附带证据引用
  • 模式章节包含要求/反模式标记
  • 保留完整文档的证据链
  • 包含指向完整文档的链接
  • 包含'最后同步时间'时间戳

Phase 3: Master Index Update

阶段3:主索引更新

After creating/updating module docs, update
docs/BUSINESS-FEATURES.md
:
  1. Read current content
  2. Verify module is listed in the "Detailed Module Documentation" table
  3. Add link if missing:
    markdown
    | **{Module}** | [Description] | [View Details](./business-features/{Module}/README.md) |

创建/更新模块文档后,更新
docs/BUSINESS-FEATURES.md
  1. 读取当前内容
  2. 验证模块已在"详细模块文档"表中列出
  3. 缺失则添加链接:
    markdown
    | **{Module}** | [描述] | [查看详情](./business-features/{Module}/README.md) |

Anti-Hallucination Protocols

防幻觉协议

<!-- SYNC:evidence-based-reasoning -->
Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs proof.
  1. Cite
    file:line
    , grep results, or framework docs for EVERY claim
  2. Declare confidence: >80% act freely, 60-80% verify first, <60% DO NOT recommend
  3. Cross-service validation required for architectural changes
  4. "I don't have enough evidence" is valid and expected output
BLOCKED until:
- [ ]
Evidence file path (
file:line
)
- [ ]
Grep search performed
- [ ]
3+ similar patterns found
- [ ]
Confidence level stated
Forbidden without proof: "obviously", "I think", "should be", "probably", "this is because" If incomplete → output:
"Insufficient evidence. Verified: [...]. Not verified: [...]."
<!-- /SYNC:evidence-based-reasoning -->
<!-- SYNC:evidence-based-reasoning -->
基于证据的推理 — 禁止猜测。每个声明都需要证明。
  1. 每个声明都需要引用
    文件:行号
    、grep结果或框架文档
  2. 声明置信度:>80%可直接执行,60-80%先验证,<60% 不要推荐
  3. 架构变更需要跨服务验证
  4. "我没有足够的证据"是有效且预期的输出
阻断条件:
- [ ]
证据文件路径(
文件:行号
- [ ]
已执行Grep搜索
- [ ]
找到3+相似模式
- [ ]
已说明置信度
无证据时禁止使用: "显然"、"我认为"、"应该是"、"可能"、"这是因为" 如果信息不完整 → 输出:
"证据不足。已验证:[...]。未验证:[...]。"
<!-- /SYNC:evidence-based-reasoning -->

DOCUMENTATION_ACCURACY_CHECKPOINT

文档准确性检查点

Before writing any documentation:
  • "Have I read the actual code that implements this?"
  • "Are my line number references accurate and current?"
  • "Can I provide a code snippet as evidence?"
编写任何文档前:
  • "我是否阅读了实现该功能的实际代码?"
  • "我的行号引用是否准确且最新?"
  • "我可以提供代码片段作为证据吗?"

TEST CASE EVIDENCE VERIFICATION

测试用例证据验证

For EVERY test case:
  1. Read the Evidence file at claimed line number
  2. Verify: Does code at that line support test assertion?
  3. Check Edge Cases: Find error constants in
    ErrorMessage.cs
  4. Fix immediately if line numbers wrong

每个测试用例都需要:
  1. 读取证据文件中声明行号的内容
  2. 验证:该行代码是否支持测试断言?
  3. 检查边界用例:在
    ErrorMessage.cs
    中找到错误常量
  4. 如果行号错误立即修复

Phase 3.5: Verification (3 Passes)

阶段3.5:验证(三重检查)

First Pass - Test Case Evidence Audit

第一遍 - 测试用例证据审计

For EVERY test case in documentation:
  1. Read the Evidence file at the claimed line number
  2. Verify match: Does the code at that line support the test assertion?
  3. Check Edge Cases: Find error message constants in
    ErrorMessage.cs
  4. Fix immediately if line numbers are wrong
文档中的每个测试用例都需要:
  1. 读取证据文件中声明行号的内容
  2. 验证匹配:该行代码是否支持测试断言?
  3. 检查边界用例:在
    ErrorMessage.cs
    中找到错误消息常量
  4. 立即修复错误的行号

Second Pass - Domain Model Verification

第二遍 - 领域模型验证

  • Read EACH entity file referenced in Domain Model section
  • Verify property names, types, and line numbers
  • Check enum values exist in actual source
  • Remove any documented properties not found in source
  • 读取领域模型章节中引用的每个实体文件
  • 验证属性名称、类型和行号
  • 检查枚举值是否存在于实际源代码中
  • 删除源代码中不存在的文档化属性

Third Pass - Cross-Reference Audit

第三遍 - 交叉引用审计

  • Test Summary counts match actual test case count
  • All internal links work
  • No template placeholders remain (
    {FilePath}
    ,
    {LineRange}
    )
  • ErrorMessage.cs constants match edge case messages
CRITICAL: If ANY pass finds hallucinated content, re-investigate and fix before completing.

  • 测试汇总计数与实际测试用例数量匹配
  • 所有内部链接可正常访问
  • 无模板占位符残留(
    {FilePath}
    {LineRange}
  • ErrorMessage.cs常量与边界用例消息匹配
关键:如果任何一遍检查发现虚构内容,完成前必须重新调研并修复。

Quality Checklist

质量检查清单

Structure

结构

  • Documentation placed in correct folder structure
  • README.md follows template format (26 sections)
  • INDEX.md created with navigation links
  • Master index (BUSINESS-FEATURES.md) updated
  • Stakeholder navigation table present
  • ASCII diagrams for architecture
  • API endpoints documented with examples
  • CHANGELOG.md updated with entry under
    [Unreleased]
  • 文档放在正确的文件夹结构中
  • README.md遵循模板格式(26个章节)
  • 已创建带导航链接的INDEX.md
  • 已更新主索引(BUSINESS-FEATURES.md)
  • 包含受众导航表
  • 包含架构的ASCII图
  • API端点附带示例文档
  • 已在
    [Unreleased]
    下更新CHANGELOG.md条目

Test Case Evidence (MANDATORY)

测试用例证据(强制)

  • EVERY test case has Evidence field with
    file:line
    format
  • No template placeholders remain (
    {FilePath}
    ,
    {LineRange}
    )
  • Line numbers verified by reading actual source files
  • Edge case errors match constants from
    ErrorMessage.cs
  • Test Summary counts match actual number of test cases
  • 每个测试用例都有证据字段,格式为
    文件:行号
  • 无模板占位符残留(
    {FilePath}
    {LineRange}
  • 行号已通过读取实际源文件验证
  • 边界用例错误与
    ErrorMessage.cs
    中的常量匹配
  • 测试汇总计数与实际测试用例数量匹配

Anti-Hallucination

防幻觉

  • All entity properties verified against source code
  • All enum values verified against actual enum definitions
  • No invented methods, properties, or models
  • All code snippets copied from actual files
  • 所有实体属性已对照源代码验证
  • 所有枚举值已对照实际枚举定义验证
  • 无虚构的方法、属性或模型
  • 所有代码片段均从实际文件复制

Related

相关

  • documentation
  • feature-implementation

  • documentation
  • feature-implementation

Closing Reminders

最后提醒

  • IMPORTANT MUST ATTENTION break work into small todo tasks using
    TaskCreate
    BEFORE starting
  • IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
  • IMPORTANT MUST ATTENTION cite
    file:line
    evidence for every claim (confidence >80% to act)
  • IMPORTANT MUST ATTENTION add a final review todo task to verify work quality MANDATORY IMPORTANT MUST ATTENTION READ the following files before starting: <!-- SYNC:evidence-based-reasoning:reminder -->
  • IMPORTANT MUST ATTENTION cite
    file:line
    evidence for every claim. Confidence >80% to act, <60% = do NOT recommend. <!-- /SYNC:evidence-based-reasoning:reminder -->
  • 重要 必须注意 开始前使用
    TaskCreate
    将工作拆分为小的待办任务
  • 重要 必须注意 创建新代码前在代码库中搜索3+相似模式
  • 重要 必须注意 每个声明都引用
    文件:行号
    证据(置信度>80%才可执行)
  • 重要 必须注意 添加最终评审待办任务验证工作质量 强制要求 重要 必须注意 开始前读取以下文件: <!-- SYNC:evidence-based-reasoning:reminder -->
  • 重要 必须注意 每个声明都引用
    文件:行号
    证据。置信度>80%才可执行,<60% 请勿推荐。 <!-- /SYNC:evidence-based-reasoning:reminder -->