feature-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese[IMPORTANT] Useto 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必须主动询问用户是否可以跳过拆分步骤。TaskCreate
Quick Summary
快速概要
Goal: Generate comprehensive 26-section business feature documentation with mandatory code evidence for all test cases, plus AI companion file.
Workflow:
- Detect & Gather — Auto-detect modules from git changes OR user-specified module, read existing docs
- Investigate Code — Grep/glob codebase to gather evidence (format) for every test case
file:line - Write Documentation — Follow exact 26-section structure, place in
docs/business-features/{Module}/ - Generate AI Companion — Create file (max 300 lines) with domain model, file locations, key expressions
.ai.md - Verification — 3-pass system: evidence audit, domain model verification, cross-reference audit
Key Rules:
- EVERY test case MUST ATTENTION have verifiable code evidence (), no exceptions
FilePath:LineNumber - 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 field pointing to the test file and method name. Format:
IntegrationTest. If no integration test exists yet, setIntegrationTest: Orders/OrderCommandIntegrationTests.cs::{MethodName}.Status: Untested - Verify every TC-{MOD}-XXX in Section 17 has a corresponding in the integration test codebase. If missing, flag as
[Trait("TestSpec", "TC-{MOD}-XXX")].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%).
- — 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)
docs/project-reference/domain-entities-reference.md
目标:生成包含26个完整章节的业务功能文档,要求所有测试用例必须附带代码证据,同时生成AI配套文件。
工作流:
- 检测与收集 — 从Git变更自动检测模块,或使用用户指定的模块,读取现有文档
- 代码调研 — 用Grep/glob扫描代码库,为每个测试用例收集格式的证据
文件:行号 - 编写文档 — 严格遵循26章节结构,写入目录
docs/business-features/{Module}/ - 生成AI配套文件 — 创建最多300行的文件,包含领域模型、文件位置、关键表达式
.ai.md - 验证 — 三重验证体系:证据审计、领域模型验证、交叉引用审计
核心规则:
- 每个测试用例必须附带可验证的代码证据(),无例外
文件路径:行号 - 输出必须严格匹配主模板的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%。
- — 领域实体目录、关系、跨服务同步(任务涉及业务实体/模型时读取,内容由钩子自动注入,读取前先检查[Injected: ...]头部)
docs/project-reference/domain-entities-reference.md
Project Pattern Discovery
项目模式发现
Before implementation, search your codebase for project-specific patterns:
- Search for: ,
business-features,detailed-featuresfeature-docs-template - Look for: existing feature doc folders, 26-section templates, AI companion files
MANDATORY IMPORTANT MUST ATTENTION Read thecompanion doc for project-specific patterns and code examples. If file not found, continue with search-based discovery above.feature-docs-reference.md
实现前先在代码库中搜索项目特有的模式:
- 搜索关键词:、
business-features、detailed-featuresfeature-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 -5Template File:
AI Companion Template:
docs/templates/detailed-feature-docs-template.mddocs/templates/feature-docs-ai-template.md遵循项目规范和文件夹结构生成完整的功能文档。
黄金标准参考:
在代码库中搜索现有功能文档作为参考:
bash
find docs/business-features -name "README.*.md" -type f | head -5模板文件:
AI配套文件模板:
docs/templates/detailed-feature-docs-template.mddocs/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
有效与无效证据对比
| Valid | Invalid |
|---|---|
| |
| |
| "Based on CQRS pattern" (vague) |
| 有效证据 | 无效证据 |
|---|---|
| |
| |
| "基于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
undefinedFind 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:
| # | Section | Stakeholder Focus |
|---|---|---|
| 1 | Executive Summary | PO, BA |
| 2 | Business Value | PO, BA |
| 3 | Business Requirements | PO, BA |
| 4 | Business Rules | BA, Dev |
| 5 | Process Flows | BA, Dev, Architect |
| 6 | Design Reference | BA, UX, Dev |
| 7 | System Design | Dev, Architect |
| 8 | Architecture | Dev, Architect |
| 9 | Domain Model | Dev, Architect |
| 10 | API Reference | Dev, Architect |
| 11 | Frontend Components | Dev |
| 12 | Backend Controllers | Dev |
| 13 | Cross-Service Integration | Dev, Architect |
| 14 | Security Architecture | Dev, Architect |
| 15 | Performance Considerations | Dev, Architect, DevOps |
| 16 | Implementation Guide | Dev |
| 17 | Test Specifications | QA |
| 18 | Test Data Requirements | QA |
| 19 | Edge Cases Catalog | QA, Dev |
| 20 | Regression Impact | QA |
| 21 | Troubleshooting | Dev, QA, DevOps |
| 22 | Operational Runbook | DevOps |
| 23 | Roadmap and Dependencies | PO, BA |
| 24 | Related Documentation | All |
| 25 | Glossary | PO, BA |
| 26 | Version History | All |
所有功能文档必须遵循以下章节顺序:
| 序号 | 章节名称 | 面向受众 |
|---|---|---|
| 1 | 执行摘要 | 产品负责人、业务分析师 |
| 2 | 业务价值 | 产品负责人、业务分析师 |
| 3 | 业务需求 | 产品负责人、业务分析师 |
| 4 | 业务规则 | 业务分析师、开发人员 |
| 5 | 流程流 | 业务分析师、开发人员、架构师 |
| 6 | 设计参考 | 业务分析师、UX设计师、开发人员 |
| 7 | 系统设计 | 开发人员、架构师 |
| 8 | 架构 | 开发人员、架构师 |
| 9 | 领域模型 | 开发人员、架构师 |
| 10 | API参考 | 开发人员、架构师 |
| 11 | 前端组件 | 开发人员 |
| 12 | 后端控制器 | 开发人员 |
| 13 | 跨服务集成 | 开发人员、架构师 |
| 14 | 安全架构 | 开发人员、架构师 |
| 15 | 性能考量 | 开发人员、架构师、DevOps |
| 16 | 实现指南 | 开发人员 |
| 17 | 测试规范 | 测试人员 |
| 18 | 测试数据要求 | 测试人员 |
| 19 | 边界用例目录 | 测试人员、开发人员 |
| 20 | 回归影响 | 测试人员 |
| 21 | 问题排查 | 开发人员、测试人员、DevOps |
| 22 | 运维手册 | DevOps |
| 23 | 路线图与依赖 | 产品负责人、业务分析师 |
| 24 | 相关文档 | 所有人员 |
| 25 | 术语表 | 产品负责人、业务分析师 |
| 26 | 版本历史 | 所有人员 |
Stakeholder Quick Navigation
受众快速导航
| Audience | Sections |
|---|---|
| Product Owner | Executive Summary, Business Value, Roadmap |
| Business Analyst | Business Requirements, Business Rules, Process Flows, Domain Model |
| Developer | Architecture, Domain Model, API Reference, Implementation Guide |
| Technical Architect | System Design, Cross-Service Integration, Security, Performance |
| QA/QC | Test Specifications, Test Data, Edge Cases, Regression Impact |
| DevOps/Support | Troubleshooting, 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:
- Run (captures both staged and unstaged changes)
git diff --name-only HEAD - If no uncommitted changes, run (last commit)
git diff --name-only HEAD~1 - Extract unique module names from changed file paths using the Module Mapping table
- For each detected module, check if a business feature doc exists in
docs/business-features/{Module}/ - If docs exist → proceed to Phase 1.5 (Update Mode) for each module
- If no docs exist → skip (do not create docs from scratch without explicit user request)
- If no service-layer files changed (e.g., only ,
.claude/, config files) → report "No business feature docs impacted" and exitdocs/
Path-to-Module Detection Rules:
Search your codebase to build the path-to-module mapping. Common patterns:
| Changed File Path Pattern | Detected Module |
|---|---|
| {Module} |
| {Module} (map app name to module) |
| {Module} (map feature to module) |
Build a project-specific mapping by examining:
bash
ls -d src/Services/*/
ls -d {frontend-apps-dir}/*/未明确指定模块或功能时,从Git变更自动检测受影响的模块:
- 运行(捕获暂存和未暂存的变更)
git diff --name-only HEAD - 如果没有未提交的变更,运行(最近一次提交)
git diff --name-only HEAD~1 - 使用模块映射表从变更文件路径中提取唯一的模块名称
- 对每个检测到的模块,检查下是否存在业务功能文档
docs/business-features/{Module}/ - 如果文档存在 → 进入**阶段1.5(更新模式)**处理每个模块
- 如果文档不存在 → 跳过(无用户明确请求时不要从零创建文档)
- 如果没有服务层文件变更(例如仅修改了、
.claude/、配置文件)→ 报告"无业务功能文档受影响"并退出docs/
路径到模块检测规则:
搜索代码库构建路径到模块的映射,常见模式:
| 变更文件路径模式 | 检测到的模块 |
|---|---|
| {Module} |
| {Module} (将应用名映射到模块) |
| {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:
- User explicitly specifies module name
- Feature name/domain implies module (search codebase to verify mapping)
- Search codebase for feature-related entities/commands
- Auto-detected from git diff (Step 1.0 above) — used when invoked as a workflow step without explicit module
通过以下方式确定功能所属的模块:
- 用户明确指定模块名称
- 功能名称/领域暗示所属模块(搜索代码库验证映射关系)
- 搜索代码库中与功能相关的实体/命令
- 从Git diff自动检测(上述步骤1.0)—— 作为无明确模块指定的工作流步骤调用时使用
Step 1.2: Read Existing Documentation
步骤1.2:读取现有文档
Before creating new docs, read existing structure:
- Read (master index)
docs/BUSINESS-FEATURES.md - Read (if exists)
docs/business-features/{Module}/INDEX.md - Read (if exists)
docs/business-features/{Module}/README.md - Identify what already exists vs what needs creation/update
创建新文档前,先读取现有结构:
- 读取(主索引)
docs/BUSINESS-FEATURES.md - 读取(如果存在)
docs/business-features/{Module}/INDEX.md - 读取(如果存在)
docs/business-features/{Module}/README.md - 识别已有的内容和需要创建/更新的内容
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: or
{frontend-apps-dir}/{app-name}/{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].mdDiscovery Areas
发现范围
- Domain Entity Discovery: Entities, value objects, enums
- Workflow Discovery: Commands, Queries, Event Handlers, Background Jobs
- API Discovery: Controllers, endpoints, DTOs
- Frontend Discovery: Components, Services, Stores
- Cross-Service Discovery: Message Bus messages, producers, consumers
- 领域实体发现:实体、值对象、枚举
- 工作流发现:命令、查询、事件处理器、后台任务
- API发现:控制器、端点、DTO
- 前端发现:组件、服务、存储
- 跨服务发现:消息总线消息、生产者、消费者
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:差异分析
- Identify the source of changes (git diff, branch comparison, commit history)
- Categorize changes by type: backend entity, command, query, frontend component, i18n, etc.
- Map each change to impacted documentation sections (use table below)
- 识别变更来源(Git diff、分支对比、提交历史)
- 按类型对变更分类:后端实体、命令、查询、前端组件、i18n等
- 将每个变更映射到受影响的文档章节(使用下表)
Step 1.5.2: Section Impact Mapping
步骤1.5.2:章节影响映射
| Change Type | Impacted Sections |
|---|---|
| New entity property | 3 (Business Requirements), 9 (Domain Model), 10 (API Reference) |
| New API endpoint | 10 (API Reference), 12 (Backend Controllers), 14 (Security) |
| New frontend component | 11 (Frontend Components) |
| New filter/query | 3 (Business Requirements), 10 (API Reference) |
| New i18n keys | 11 (Frontend Components) |
| Any new functionality | 17 (Test Specs), 18 (Test Data), 19 (Edge Cases), 20 (Regression Impact) — MANDATORY |
| Any change | 1 (Executive Summary), 26 (Version History) — ALWAYS UPDATE |
| 变更类型 | 受影响章节 |
|---|---|
| 新增实体属性 | 3(业务需求)、9(领域模型)、10(API参考) |
| 新增API端点 | 10(API参考)、12(后端控制器)、14(安全) |
| 新增前端组件 | 11(前端组件) |
| 新增筛选/查询 | 3(业务需求)、10(API参考) |
| 新增i18n key | 11(前端组件) |
| 任何新增功能 | 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 entry under following Keep a Changelog format.
CHANGELOG.md[Unreleased]始终在下按照Keep a Changelog格式创建/更新CHANGELOG.md条目。
[Unreleased]Phase 2: Documentation Generation
阶段2:文档生成
Generate at .
docs/business-features/{Module}/detailed-features/README.{FeatureName}.md生成到。
docs/business-features/{Module}/detailed-features/README.{FeatureName}.mdKey Format Examples
核心格式示例
Business Requirements (FR-XX):
markdown
undefined业务需求(FR-XX):
markdown
undefinedFR-{MOD}-01: {Requirement Title}
FR-{MOD}-01: {需求标题}
| Aspect | Details |
|---|---|
| Description | {What this requirement enables} |
| Scope | {Who can use / affected entities} |
| Evidence | |
**User Stories (US-XX)**:
```markdown| 维度 | 详情 |
|---|---|
| 描述 | {该需求支持的功能} |
| 范围 | {可使用的角色/受影响的实体} |
| 证据 | |
**用户故事(US-XX)**:
```markdownUS-{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
undefinedTC-{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:
- {Cause 1}
- {Cause 2}
Resolution:
- {Step 1}
- {Step 2}
**Permission Matrix**:
```markdown
| Role | View | Create | Edit | Delete | Special |
| ----- | :--: | :----: | :--: | :----: | ----------- |
| Admin | ✅ | ✅ | ✅ | ✅ | Full access |症状: {可观察到的问题}
原因:
- {原因1}
- {原因2}
解决方案:
- {步骤1}
- {步骤2}
**权限矩阵**:
```markdown
| 角色 | 查看 | 创建 | 编辑 | 删除 | 特殊权限 |
| ----- | :--: | :----: | :--: | :----: | ----------- |
| 管理员 | ✅ | ✅ | ✅ | ✅ | 完全访问 |Phase 2.5: AI Companion Generation
阶段2.5:AI配套文件生成
Generate AI-agent optimized companion file alongside the comprehensive documentation.
Output:
Template:
docs/business-features/{Module}/detailed-features/README.{FeatureName}.ai.mddocs/templates/detailed-feature-docs-template.ai.md在完整文档旁生成AI Agent优化的配套文件。
输出:
模板:
docs/business-features/{Module}/detailed-features/README.{FeatureName}.ai.mddocs/templates/detailed-feature-docs-template.ai.mdAI Companion Structure (10 Sections, ~260 lines)
AI配套文件结构(10章节,约260行)
| Section | Content | Source from Full Doc |
|---|---|---|
| Context | Purpose, entities, service | Executive Summary |
| File Locations | Exact paths to all key files | Implementation Guide |
| Domain Model | Properties, expressions | Domain Model |
| API Contracts | Endpoints, request/response shapes | API Reference |
| Business Rules | Validation, state transitions | Business Rules |
| Patterns | Required / Anti-patterns | Architecture |
| Integration | Events, dependencies | Cross-Service Integration |
| Security | Authorization matrix | Security Architecture |
| Test Scenarios | Key GIVEN/WHEN/THEN cases | Test Specifications |
| Quick Reference | Decision tree, code snippets | Implementation Guide |
| 章节 | 内容 | 来源章节 |
|---|---|---|
| 上下文 | 用途、实体、服务 | 执行摘要 |
| 文件位置 | 所有关键文件的精确路径 | 实现指南 |
| 领域模型 | 属性、表达式 | 领域模型 |
| API契约 | 端点、请求/响应结构 | API参考 |
| 业务规则 | 校验、状态转换 | 业务规则 |
| 模式 | 要求/反模式 | 架构 |
| 集成 | 事件、依赖 | 跨服务集成 |
| 安全 | 权限矩阵 | 安全架构 |
| 测试场景 | 核心GIVEN/WHEN/THEN用例 | 测试规范 |
| 快速参考 | 决策树、代码片段 | 实现指南 |
Compression Rules
压缩规则
- Tables over prose - Convert paragraphs to table rows
- Paths over descriptions - over "located in..."
File:Line - Signatures over examples - over full code
{ id: string } → { entity: Dto } - Decisions over explanations - What to do, not why
- 表格优先于段落 - 将段落转换为表格行
- 路径优先于描述 - 优先使用而非"位于..."
文件:行号 - 签名优先于示例 - 优先使用而非完整代码
{ id: string } → { entity: Dto } - 决策优先于解释 - 说明要做什么,而非为什么
AI Companion Extended (6-Section Variant, ~420 lines)
AI配套文件扩展版(6章节变体,约420行)
For larger features, use the extended companion format:
- Quick Reference (~40 lines) - Module, service, file locations
- Domain Model (~80 lines) - Entities, enums, value objects (condensed)
- API Contracts (~100 lines) - Signatures with DTOs only
- Validation Rules (~80 lines) - BR-XX table format
- Service Boundaries (~60 lines) - Cross-service integration
- Critical Paths (~60 lines) - Key workflows as decision trees
针对较大的功能,使用扩展配套格式:
- 快速参考(约40行)- 模块、服务、文件位置
- 领域模型(约80行)- 实体、枚举、值对象(精简版)
- API契约(约100行)- 仅包含DTO的签名
- 校验规则(约80行)- BR-XX表格格式
- 服务边界(约60行)- 跨服务集成
- 关键路径(约60行)- 作为决策树的核心工作流
AI Companion Header
AI配套文件头部
markdown
undefinedmarkdown
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}
undefinedSkip 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- Read current content
- Verify module is listed in the "Detailed Module Documentation" table
- Add link if missing:
markdown
| **{Module}** | [Description] | [View Details](./business-features/{Module}/README.md) |
创建/更新模块文档后,更新:
docs/BUSINESS-FEATURES.md- 读取当前内容
- 验证模块已在"详细模块文档"表中列出
- 缺失则添加链接:
markdown
| **{Module}** | [描述] | [查看详情](./business-features/{Module}/README.md) |
Anti-Hallucination Protocols
防幻觉协议
<!-- SYNC:evidence-based-reasoning -->
<!-- /SYNC:evidence-based-reasoning -->Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs proof.
- Cite
, grep results, or framework docs for EVERY claimfile:line- Declare confidence: >80% act freely, 60-80% verify first, <60% DO NOT recommend
- Cross-service validation required for architectural changes
- "I don't have enough evidence" is valid and expected output
BLOCKED until:Evidence file path (- [ ])file:lineGrep 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 -->基于证据的推理 — 禁止猜测。每个声明都需要证明。
- 每个声明都需要引用
、grep结果或框架文档文件:行号- 声明置信度:>80%可直接执行,60-80%先验证,<60% 不要推荐
- 架构变更需要跨服务验证
- "我没有足够的证据"是有效且预期的输出
阻断条件:证据文件路径(- [ ])文件:行号已执行Grep搜索- [ ]找到3+相似模式- [ ]已说明置信度- [ ]无证据时禁止使用: "显然"、"我认为"、"应该是"、"可能"、"这是因为" 如果信息不完整 → 输出:"证据不足。已验证:[...]。未验证:[...]。"
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:
- Read the Evidence file at claimed line number
- Verify: Does code at that line support test assertion?
- Check Edge Cases: Find error constants in
ErrorMessage.cs - Fix immediately if line numbers wrong
每个测试用例都需要:
- 读取证据文件中声明行号的内容
- 验证:该行代码是否支持测试断言?
- 检查边界用例:在中找到错误常量
ErrorMessage.cs - 如果行号错误立即修复
Phase 3.5: Verification (3 Passes)
阶段3.5:验证(三重检查)
First Pass - Test Case Evidence Audit
第一遍 - 测试用例证据审计
For EVERY test case in documentation:
- Read the Evidence file at the claimed line number
- Verify match: Does the code at that line support the test assertion?
- Check Edge Cases: Find error message constants in
ErrorMessage.cs - Fix immediately if line numbers are wrong
文档中的每个测试用例都需要:
- 读取证据文件中声明行号的内容
- 验证匹配:该行代码是否支持测试断言?
- 检查边界用例:在中找到错误消息常量
ErrorMessage.cs - 立即修复错误的行号
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端点附带示例文档
- 已在下更新CHANGELOG.md条目
[Unreleased]
Test Case Evidence (MANDATORY)
测试用例证据(强制)
- EVERY test case has Evidence field with format
file:line - 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
相关
documentationfeature-implementation
documentationfeature-implementation
Closing Reminders
最后提醒
- IMPORTANT MUST ATTENTION break work into small todo tasks using BEFORE starting
TaskCreate - IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
- IMPORTANT MUST ATTENTION cite evidence for every claim (confidence >80% to act)
file:line - 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 evidence for every claim. Confidence >80% to act, <60% = do NOT recommend. <!-- /SYNC:evidence-based-reasoning:reminder -->
file:line
- 重要 必须注意 开始前使用将工作拆分为小的待办任务
TaskCreate - 重要 必须注意 创建新代码前在代码库中搜索3+相似模式
- 重要 必须注意 每个声明都引用证据(置信度>80%才可执行)
文件:行号 - 重要 必须注意 添加最终评审待办任务验证工作质量 强制要求 重要 必须注意 开始前读取以下文件: <!-- SYNC:evidence-based-reasoning:reminder -->
- 重要 必须注意 每个声明都引用证据。置信度>80%才可执行,<60% 请勿推荐。 <!-- /SYNC:evidence-based-reasoning:reminder -->
文件:行号