@dtt_siye/atool 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/VERSION +1 -1
  2. package/hooks/session-start +9 -12
  3. package/lib/export-analysis.sh +100 -0
  4. package/lib/install-kiro.sh +11 -6
  5. package/lib/knowledge-graph.sh +7 -2
  6. package/package.json +1 -1
  7. package/skills/doc-standards-enforcer/SKILL.md +200 -220
  8. package/skills/doc-standards-enforcer/examples/valid-document-example.md +5 -5
  9. package/skills/doc-standards-enforcer/references/101-standards-summary.md +17 -17
  10. package/skills/project-analyze/SKILL.md +138 -124
  11. package/skills/project-analyze/phases/{phase0-discovery.md → archive/phase0-discovery.md} +6 -2
  12. package/skills/project-analyze/phases/{phase1-inventory.md → archive/phase1-inventory.md} +10 -0
  13. package/skills/project-analyze/phases/{phase2-deep-analysis.md → archive/phase2-deep-analysis.md} +20 -0
  14. package/skills/project-analyze/phases/{phase3-knowledge-graph.md → archive/phase3-knowledge-graph.md} +31 -0
  15. package/skills/project-analyze/phases/{phase3a-multi-dimensional.md → archive/phase3a-multi-dimensional.md} +13 -0
  16. package/skills/project-analyze/phases/{phase5-synthesis.md → archive/phase5-synthesis.md} +20 -0
  17. package/skills/project-analyze/phases/phase1-setup.md +182 -0
  18. package/skills/project-analyze/phases/phase2-understand.md +108 -0
  19. package/skills/project-analyze/phases/phase3-graph.md +77 -0
  20. package/skills/project-analyze/phases/phase4-synthesize.md +260 -0
  21. package/skills/project-analyze/phases/phase5-export.md +161 -0
  22. package/skills/project-analyze/prompts/{deep-analysis-agent.md → archive/deep-analysis-agent.md} +14 -1
  23. package/skills/project-analyze/prompts/understand-agent.md +407 -0
  24. package/skills/requirements-writer/README.md +1 -1
  25. package/skills/requirements-writer/SKILL.md +378 -284
  26. package/skills/requirements-writer/examples/prd-outline-example.md +5 -5
  27. package/skills/requirements-writer/templates/module-prd-template.md +15 -15
  28. package/skills/requirements-writer/templates/prd-outline-template.md +3 -3
  29. package/skills/requirements-writer/templates/user-story-template.md +23 -23
  30. package/skills/software-architecture/SKILL.md +248 -17
  31. package/templates/CLAUDE.md.android +17 -0
  32. package/templates/CLAUDE.md.devops +17 -0
  33. package/templates/CLAUDE.md.generic +17 -0
  34. package/templates/CLAUDE.md.go +17 -0
  35. package/templates/CLAUDE.md.harmony +17 -0
  36. package/templates/CLAUDE.md.java +17 -0
  37. package/templates/CLAUDE.md.mobile-flutter +17 -0
  38. package/templates/CLAUDE.md.mobile-react-native +17 -0
  39. package/templates/CLAUDE.md.mobile-swift +17 -0
  40. package/templates/CLAUDE.md.python +17 -0
  41. package/templates/CLAUDE.md.rust +17 -0
  42. package/templates/CLAUDE.md.rust-tauri +17 -0
  43. package/templates/CLAUDE.md.web +17 -0
  44. package/templates/cursor-rules.android.mdc +17 -0
  45. package/templates/cursor-rules.devops.mdc +17 -0
  46. package/templates/cursor-rules.generic.mdc +17 -0
  47. package/templates/cursor-rules.go.mdc +17 -0
  48. package/templates/cursor-rules.harmony.mdc +17 -0
  49. package/templates/cursor-rules.java.mdc +17 -0
  50. package/templates/cursor-rules.mobile-flutter.mdc +17 -0
  51. package/templates/cursor-rules.mobile-react-native.mdc +17 -0
  52. package/templates/cursor-rules.mobile-swift.mdc +17 -0
  53. package/templates/cursor-rules.python.mdc +17 -0
  54. package/templates/cursor-rules.rust-tauri.mdc +17 -0
  55. package/templates/cursor-rules.rust.mdc +17 -0
  56. package/templates/cursor-rules.web.mdc +17 -0
  57. package/templates/kiro-steering.android.md +6 -0
  58. package/templates/kiro-steering.devops.md +6 -0
  59. package/templates/kiro-steering.generic.md +6 -0
  60. package/templates/kiro-steering.go.md +6 -0
  61. package/templates/kiro-steering.harmony.md +6 -0
  62. package/templates/kiro-steering.java.md +6 -0
  63. package/templates/kiro-steering.mobile-flutter.md +6 -0
  64. package/templates/kiro-steering.mobile-react-native.md +6 -0
  65. package/templates/kiro-steering.mobile-swift.md +6 -0
  66. package/templates/kiro-steering.python.md +6 -0
  67. package/templates/kiro-steering.rust-tauri.md +6 -0
  68. package/templates/kiro-steering.rust.md +6 -0
  69. package/templates/kiro-steering.web.md +6 -0
  70. package/templates/shared/hard-rules.md +21 -0
  71. /package/skills/project-analyze/phases/{phase0.5-prescan.md → archive/phase0.5-prescan.md} +0 -0
  72. /package/skills/project-analyze/phases/{phase2a-l4-analysis.md → archive/phase2a-l4-analysis.md} +0 -0
  73. /package/skills/project-analyze/phases/{phase2b-l5-analysis.md → archive/phase2b-l5-analysis.md} +0 -0
  74. /package/skills/project-analyze/phases/{phase4-code-quality.md → archive/phase4-code-quality.md} +0 -0
  75. /package/skills/project-analyze/phases/{phase6-validation.md → archive/phase6-validation.md} +0 -0
  76. /package/skills/project-analyze/prompts/{code-review-agent.md → archive/code-review-agent.md} +0 -0
  77. /package/skills/project-analyze/prompts/{inventory-agent.md → archive/inventory-agent.md} +0 -0
  78. /package/skills/project-analyze/prompts/{l4-analysis-agent.md → archive/l4-analysis-agent.md} +0 -0
@@ -1,341 +1,435 @@
1
1
  ---
2
2
  name: requirements-writer
3
- description: Guide users through a structured workflow for writing PRDs and requirements documents. Use when user wants to write Product Requirements Documents (PRD), Functional Requirements (FR), Non-Functional Requirements (NFR), Acceptance Criteria (AC), or User Stories. This workflow implements a phased approach to avoid context length limitations: 1) Create requirements outline and plan, 2) Write detailed PRDs by module/feature, 3) Write comprehensive User Stories (8000+ words each) with complete specs.
4
- version: 1.0.0
5
- allowed-tools: Read, Write, Edit, Bash, Skill
3
+ description: "Guide users through writing PRDs and requirements documents with Multi-Agent architecture. 在需要撰写 PRD、需求文档、用户故事时使用。Supports Quick PRD (single feature) and Full PRD (multi-module project). Integrates with project-analyze for code-driven requirement reverse-engineering."
4
+ version: 2.1.0
5
+ category: documentation
6
6
  ---
7
7
 
8
- # Requirements Writer
8
+ # Requirements Writer v2.0
9
9
 
10
- Guide for writing comprehensive Product Requirements Documents (PRD), Functional Requirements (FR), Non-Functional Requirements (NFR), Acceptance Criteria (AC), and User Stories following Inspection Agent project standards.
10
+ Multi-Agent 驱动的需求文档撰写系统。支持从零写 PRD(前向)和从代码逆向补齐需求(后向)。
11
11
 
12
- ## Purpose
12
+ ## 核心原则
13
13
 
14
- Ensure requirements documentation is:
15
- - **Business-readable** - Clear to non-technical stakeholders
16
- - **Testable** - Can be verified through acceptance criteria
17
- - **Traceable** - Linked from PRD → FR → US → AC → Design → Implementation
14
+ 1. **深度优先于长度** 覆盖率 100% 的 3000 字 PRD 优于覆盖率 60% 的 8000 字 PRD
15
+ 2. **按钮级定义** 每个 UI 元素都有明确的行为定义,开发无需二次确认
16
+ 3. **字段级规格** 每个数据字段都有类型/约束/校验/默认值/业务含义
17
+ 4. **跨模块关联** 所有模块共享术语表、数据模型索引、角色权限矩阵
18
+ 5. **可追溯链路** — PRD → FR → US → AC → Design → Code,双向可追溯
18
19
 
19
- This skill uses a **phased approach** to avoid context length limitations and ensure consistency:
20
- 1. **Requirements Outline & Plan** - High-level structure and module breakdown
21
- 2. **Module-Level PRDs** - Detailed requirements by functional module
22
- 3. **User Stories** - Comprehensive specifications (8000+ words each)
20
+ ## 触发条件
23
21
 
24
- ## When This Skill Activates
22
+ - 用户说"写 PRD"、"create requirements"、"write user stories"、"需求文档"
23
+ - 用户说"补齐 PRD"、"完善需求"(后向模式,读取已有代码/分析结果)
24
+ - 用户在 project-analyze 完成后说"生成正式 PRD"
25
25
 
26
- This skill activates when:
27
- - Writing or updating PRDs (Product Requirements Documents)
28
- - Creating Functional Requirements (FR) or Non-Functional Requirements (NFR)
29
- - Defining Acceptance Criteria (AC)
30
- - Writing User Stories (US)
31
- - Explicitly invoked via "write PRD", "create requirements", or similar phrases
26
+ ## 双模式
32
27
 
33
- ## Critical Dependencies
28
+ ### Quick PRD(单功能/小需求)
34
29
 
35
- This skill **depends on** `doc-standards-enforcer` skill:
36
- - All documents must follow file naming: `<x-digit-id>-<slug>.md`
37
- - All documents must include frontmatter template
38
- - All documents must include version history table
39
- - All documents must be in appropriate hundreds-based directory
30
+ 适用:单个功能点、小型需求变更、快速原型定义。
40
31
 
41
- ## Workflow Phases
32
+ **轻量访谈**(1-2 个问题,参考 clarify-before-build Tier 1):
33
+ - 如果需求已明确 → 跳过,直接生成
34
+ - 如果有模糊点 → 问 1-2 个关键问题("这个功能是给谁用的?""成功标准是什么?")
42
35
 
43
- ### Phase 1: Requirements Outline & Plan
36
+ 直接生成 1 PRD 文件(5 节 Schema):
37
+ 1. Executive Summary(问题 + 方案 + 成功标准)
38
+ 2. User Experience & Functionality(用户故事 + 验收标准 + UI 交互定义)
39
+ 3. AI System Requirements(如适用:工具/模型/评估策略)
40
+ 4. Technical Specifications(架构 + 集成 + 安全)
41
+ 5. Risks & Roadmap(风险 + 分阶段发布)
44
42
 
45
- **Objective**: Create high-level structure to guide detailed writing and avoid context issues.
43
+ 触发方式:用户说"快速 PRD"、"Quick PRD"、或需求明确且范围小时自动选择。
46
44
 
47
- **Deliverables**:
48
- - Requirements outline document (`docs/xxx-requirements/xxx-prd-outline.md`)
49
- - Module breakdown with sequencing
50
- - Writing plan with dependencies
45
+ ### Full PRD(多模块项目/大型需求)
51
46
 
52
- **Template**: See `templates/prd-outline-template.md`
47
+ 适用:多模块项目、完整产品需求、CMMI 5 级交付要求。
53
48
 
54
- **Key Activities**:
55
- 1. Define project scope (In/Out)
56
- 2. Identify modules (e.g., COMPARE, JURY, PORTAL, DETECTORS, AUTO_FIX)
57
- 3. Create module dependency graph
58
- 4. Establish writing sequence (start with independent modules)
59
- 5. Define personas and scenarios
49
+ 执行 4 Phase 流程(见下方)。
60
50
 
61
- ### Phase 2: Module-Level PRDs
51
+ 触发方式:用户说"完整 PRD"、"Full PRD"、或需求涉及多模块时自动选择。
62
52
 
63
- **Objective**: Write detailed PRDs for each module following the outline.
53
+ ---
64
54
 
65
- **Deliverables**:
66
- - Module PRD files (`docs/xxx-requirements/xxx-prd-<module>.md`)
67
- - FR/NFR documents for each module
68
- - Acceptance criteria for each feature
55
+ ## Full PRD: 5 Phase 流程
69
56
 
70
- **Template**: See `templates/module-prd-template.md`
57
+ ### Phase D: DISCOVERY(需求访谈 — 动笔前必做)
71
58
 
72
- **Per-Module PRD Must Include**:
73
- - Problem/Goal
74
- - Scope (In/Out for this module)
75
- - Personas & Scenarios (relevant to module)
76
- - Functional Requirements (FR-<MODULE>-<SEQ>)
77
- - Non-Functional Requirements (NFR-<MODULE>-<SEQ>)
78
- - UX Notes (interaction intent, not implementation)
79
- - Acceptance Criteria (AC-<MODULE>-<SEQ>)
80
- - Risks/Assumptions
81
- - Cross-references to related modules
82
- - Version History
59
+ **目标**:在写任何 PRD 之前,确保需求足够清晰。引用 clarify-before-build 的分级机制 + brainstorming 的访谈风格。
83
60
 
84
- **Writing Guidelines**:
85
- - One PRD per module
86
- - If PRD exceeds 8-12 pages, create sub-topic PRDs with an index
87
- - Link FRs to specific User Stories
88
- - NFRs must be quantifiable and testable
89
- - ACs must avoid subjective language (e.g., "fast", "good experience")
90
- - Reference data structures, APIs, and design docs
61
+ **需求清晰度评估**(参考 clarify-before-build Tier 分级):
91
62
 
92
- ### Phase 3: User Stories
63
+ | 清晰度 | 信号 | 行为 |
64
+ |--------|------|------|
65
+ | **高**(Tier 0/1) | 用户给了完整需求文档/设计稿/竞品参考 | 跳过访谈,直接 Phase 0 |
66
+ | **中**(Tier 2) | 用户给了大致方向但有模糊点(如"做个用户管理") | 结构化提问 3-5 个关键问题 |
67
+ | **低**(Tier 3) | 用户只有一句话需求(如"做一个天气 App") | 完整访谈(brainstorming 风格) |
93
68
 
94
- **Objective**: Write comprehensive User Stories with complete specifications.
69
+ **结构化提问(Tier 2,3-5 个问题)**:
95
70
 
96
- **Deliverables**:
97
- - User Story files (`docs/xxx-requirements/xxx-user-stories/xxx-us-<module>-<feature>.md`)
98
- - Complete spec for each US (8000+ words)
99
- - Detailed acceptance criteria
100
- - Data and metrics references
101
- - Permission and audit requirements
71
+ 按优先级逐个提问(一次一个问题,等用户回答后再问下一个):
72
+ 1. **核心问题**:为什么要做这个?解决谁的什么问题?
73
+ 2. **成功标准**:怎么判断做成了?有没有具体的 KPI?
74
+ 3. **用户角色**:谁来用?有几种角色?权限区别?
75
+ 4. **约束条件**:技术栈/预算/时间/合规要求?
76
+ 5. **边界确认**:明确不做什么?(避免范围蔓延)
102
77
 
103
- **Template**: See `templates/user-story-template.md`
78
+ **完整访谈(Tier 3,brainstorming 风格)**:
104
79
 
105
- **Per-User Story Must Include**:
80
+ 引用 `/brainstorming` skill 的对话机制:
81
+ - **一次只问一个问题**(不要一次抛出 5 个问题)
82
+ - **优先多选题**(给用户选项比开放式问题更容易回答)
83
+ - **先读后问**(先检查项目中已有的文档/代码,不问已有答案的问题)
84
+ - **追问直到清晰**(如果答案仍模糊,继续追问细节)
85
+
86
+ 访谈必须覆盖以下维度:
87
+ 1. **业务背景**:为什么现在做?商业驱动是什么?
88
+ 2. **目标用户画像**:主要角色 + 使用场景 + 痛点
89
+ 3. **功能边界**:In Scope / Out of Scope / 未来考虑
90
+ 4. **质量期望**:性能/安全/可用性/合规要求
91
+ 5. **已有资产**:有没有竞品参考?设计稿?旧系统文档?
92
+ 6. **技术约束**:必须用的技术栈?必须对接的系统?
93
+
94
+ **补充材料请求**:
95
+
96
+ 如果访谈中发现以下信息缺失,主动要求用户补充:
97
+ - "能否提供竞品截图或链接?"(帮助理解期望的 UI/UX)
98
+ - "有没有现有的数据库 schema 或 API 文档?"(后向集成时尤为重要)
99
+ - "有没有业务流程图或审批流程说明?"(复杂业务逻辑)
100
+ - "有没有设计稿(Figma/Sketch/手绘)?"(UI 相关需求)
101
+
102
+ **退出机制**(参考 clarify-before-build):
103
+ 当用户说"别问了"、"直接写"、"go ahead"时,立即停止访谈,用已有信息进入 Phase 0。未确认的部分在 PRD 中标注 `[待确认:{问题}]`。
104
+
105
+ **产出**:访谈记录写入 `docs/requirements/000-discovery.md`(问答记录 + 关键决策 + 待确认项列表)
106
106
 
107
- #### Frontmatter
108
- ```yaml
109
- ---
110
- doc_id: US-XXX-xxxx
111
- title: User Story Title
112
- status: draft
113
- owner: PM
114
- last_updated: YYYY-MM-DD
115
- related_docs:
116
- - docs/x00-requirements/xxx-prd-<module>.md
117
- us_id: US-IA-0001
118
- module: IA
119
- priority: P0|P1|P2
120
107
  ---
121
- ```
122
108
 
123
- #### Story Statement
124
- ```
125
- As a [role],
126
- I want [feature/capability],
127
- so that [benefit/value].
128
- ```
109
+ ### Phase 0: CONTEXT BUILD(共享上下文构建)
110
+
111
+ **目标**:基于 Phase D 访谈结果,建立所有 Agent 共享的协调层。
112
+
113
+ **输入**:
114
+ - Phase D 访谈记录(`000-discovery.md`)
115
+ - 用户补充的材料(设计稿/竞品/旧文档)
116
+ - 项目现有文档(README、旧 PRD、架构文档)
117
+ - project-analyze 结果(如有 `atool-analysis/`)
118
+
119
+ **产出**:`docs/requirements/000-context.md`
129
120
 
130
- #### Comprehensive Spec (8000+ Words Total)
131
-
132
- 1. **Background & Context** (1000-1500 words)
133
- - Business problem
134
- - Current state (if any)
135
- - Why this matters now
136
- - Success metrics
137
-
138
- 2. **User Personas & Scenarios** (1000-1500 words)
139
- - Primary persona details
140
- - Secondary personas (if applicable)
141
- - Detailed scenario walkthroughs
142
- - Edge cases and alternative paths
143
-
144
- 3. **Functional Requirements** (1500-2000 words)
145
- - Complete feature breakdown
146
- - Input specifications
147
- - Processing rules
148
- - Output specifications
149
- - Error handling and edge cases
150
- - Integration points
151
-
152
- 4. **User Experience & Interaction** (1000-1500 words)
153
- - UI/UX flow descriptions
154
- - Interaction patterns
155
- - Feedback mechanisms
156
- - Accessibility considerations
157
- - Responsive behavior
158
-
159
- 5. **Data & Metrics** (800-1000 words)
160
- - Data entities involved
161
- - Fields and validations
162
- - Metrics to track
163
- - Analytics requirements
164
- - References to data dictionary
165
-
166
- 6. **Permissions & Security** (800-1000 words)
167
- - RBAC requirements
168
- - Data scope (which data users can access)
169
- - Audit requirements
170
- - Privacy considerations
171
- - Compliance needs
172
-
173
- 7. **Acceptance Criteria** (1000-1500 words)
174
- - Detailed acceptance criteria
175
- - Each criterion must be objectively verifiable
176
- - Test cases for each criterion
177
- - Performance criteria (if applicable)
178
- - Edge case coverage
179
-
180
- 8. **Dependencies & Integration** (500-800 words)
181
- - Legacy system dependencies
182
- - New system dependencies
183
- - Third-party integrations
184
- - API dependencies
185
- - Data migration needs (if any)
186
-
187
- 9. **Risks & Mitigation** (500-800 words)
188
- - Technical risks
189
- - Business risks
190
- - Mitigation strategies
191
- - Rollback plans
192
-
193
- 10. **Out of Scope** (300-500 words)
194
- - Explicitly list what's NOT included
195
- - Future phases
196
- - Related features not in this US
197
-
198
- #### Version History Table
199
121
  ```markdown
200
- | Version | Date | Owner | Change |
201
- |---|---|---|---|
202
- | v0.1 | YYYY-MM-DD | PM | Initial version |
122
+ # 项目需求上下文
123
+
124
+ ## 1. 项目概述
125
+ - 项目名称 / 业务定位 / 目标用户
126
+ - 项目范围(In Scope / Out of Scope)
127
+
128
+ ## 2. 模块地图
129
+ | 模块 | 职责 | 上游依赖 | 下游被依赖 | 共享数据实体 |
130
+ |------|------|---------|-----------|------------|
131
+
132
+ ## 3. 全局术语表
133
+ | 术语 | 定义 | 归属模块 | 关联模块 |
134
+ |------|------|---------|---------|
135
+
136
+ ## 4. 全局数据模型索引
137
+ | 实体 | 归属模块 | 读取方 | 写入方 | 关键字段 |
138
+ |------|---------|--------|--------|---------|
139
+
140
+ ## 5. 用户角色权限矩阵
141
+ | 角色 | 可访问模块 | 关键权限 | 数据范围 |
142
+ |------|-----------|---------|---------|
143
+
144
+ ## 6. 模块写作顺序(按依赖关系)
145
+ 1. {被依赖最多的模块} → 2. ... → N. {叶子模块}
146
+
147
+ ## 7. 全局非功能需求
148
+ - 性能基线 / 安全标准 / 合规要求 / 可用性目标
203
149
  ```
204
150
 
205
- ## Validation Checklist
206
-
207
- ### Phase 1: Outline Validation
208
- - [ ] File follows naming convention: `xxx-prd-outline.md`
209
- - [ ] Document includes complete frontmatter
210
- - [ ] All modules are identified with clear boundaries
211
- - [ ] Module dependencies are mapped
212
- - [ ] Writing sequence is defined
213
- - [ ] Personas are defined
214
- - [ ] Version history table included
215
-
216
- ### Phase 2: PRD Validation
217
- - [ ] File follows naming convention: `xxx-prd-<module>.md`
218
- - [ ] Document follows doc-standards-enforcer compliance
219
- - [ ] Problem/Goal clearly stated
220
- - [ ] Scope (In/Out) defined
221
- - [ ] FRs follow format: `FR-<MODULE>-<SEQ>`
222
- - [ ] NFRs are quantifiable
223
- - [ ] ACs are objectively verifiable
224
- - [ ] Cross-references use relative paths
225
- - [ ] Technical details delegated to design/architecture docs
226
- - [ ] Version history table included
227
-
228
- ### Phase 3: User Story Validation
229
- - [ ] File follows naming convention: `xxx-us-<module>-<feature>.md`
230
- - [ ] Document follows doc-standards-enforcer compliance
231
- - [ ] Complete frontmatter with `us_id`, `module`, `priority`
232
- - [ ] Story statement follows format
233
- - [ ] Total content is 8000+ words
234
- - [ ] All 10 sections are complete
235
- - [ ] Acceptance criteria are objectively verifiable
236
- - [ ] Data references link to `docs/500-data/`
237
- - [ ] Permission references link to security docs
238
- - [ ] Audit requirements specified for critical operations
239
- - [ ] Version history table included
240
-
241
- ## How to Use This Skill
242
-
243
- ### Starting a New PRD
244
-
245
- When you need to write a PRD, this skill will guide you through:
246
-
247
- 1. **Automatic activation**: Mention "write PRD", "create requirements", or similar
248
- 2. **Phase 1**: Start with requirements outline
249
- 3. **Validation**: Review outline before proceeding
250
- 4. **Phase 2**: Write module-level PRDs sequentially
251
- 5. **Validation**: Review each PRD before moving to next module
252
- 6. **Phase 3**: Write comprehensive User Stories
253
- 7. **Final validation**: Ensure all US meet 8000+ word requirement
254
-
255
- ### Example Workflow
151
+ **与 project-analyze 集成**:
152
+ 如果 `atool-analysis/` 存在,从以下文件提取数据:
153
+ - `overview/summary.md` 项目概述
154
+ - `data/modules.json` → 模块地图
155
+ - `modules/*/data-model.md` 数据模型索引
156
+ - `modules/*/prd.md` 已有逆向 PRD(标注为 [来自代码分析])
157
+
158
+ ### Phase 1: MODULE PRD(按模块并行,≤5 Agents)
159
+
160
+ **目标**:每个模块生成一份按钮级 PRD。
161
+
162
+ **派发规则**:
163
+ 1. Phase 0 的模块写作顺序分批
164
+ 2. 每批 ≤5 Agents 并行
165
+ 3. 被依赖的模块先写(其 PRD 作为下游模块的输入)
166
+
167
+ **每个 Agent 接收**:
168
+ - Phase 0 共享上下文(完整)
169
+ - 本模块的代码分析数据(如有 atool-analysis/modules/{name}/)
170
+ - 上游已完成模块的 PRD 摘要(接口契约部分)
256
171
 
172
+ **产出**:`docs/requirements/{module}-prd.md`
173
+
174
+ 每个模块 PRD 必须通过**覆盖率检查表**(见下方)。
175
+
176
+ **模块 PRD 结构**:
177
+
178
+ ```markdown
179
+ # {Module Name} PRD
180
+
181
+ ## 1. 模块概述
182
+ - 业务问题(为什么需要)
183
+ - 解决方案(怎么解决)
184
+ - 成功标准(3-5 个可度量 KPI)
185
+
186
+ ## 2. 功能需求(按页面/功能点组织)
187
+
188
+ ### 2.1 {功能名}
189
+ - **FR-{MOD}-001**: {需求描述}
190
+ - 用户故事:As a [角色], I want to [操作] so that [收益]
191
+ - 验收标准:
192
+ - AC-{MOD}-001-01: {可验证条件}
193
+ - AC-{MOD}-001-02: {可验证条件}
194
+ - UI 交互定义:
195
+ - 页面布局(描述或 ASCII 线框图)
196
+ - 按钮行为表:
197
+ | 按钮 | 触发动作 | 成功反馈 | 失败反馈 | 权限 |
198
+ - 输入字段表:
199
+ | 字段 | 类型 | 必填 | 校验规则 | 默认值 | 占位文本 | 错误提示 |
200
+ - 列表/表格定义:
201
+ | 列名 | 数据源 | 排序 | 筛选 | 操作 |
202
+ - 四种状态:加载中 / 空数据 / 错误 / 正常
203
+ - 权限控制:角色×操作 矩阵
204
+ - 边界条件:
205
+ - 并发场景
206
+ - 数据极端
207
+ - 网络异常
208
+
209
+ ### 2.N {下一个功能}
210
+ ...
211
+
212
+ ## 3. 非功能需求
213
+ - NFR-{MOD}-001: 性能(具体指标,禁止 "fast")
214
+ - NFR-{MOD}-002: 安全(认证/授权/脱敏)
215
+ - NFR-{MOD}-003: 兼容性
216
+
217
+ ## 4. 数据需求
218
+ - 实体字段定义(字段/类型/约束/业务规则)
219
+ - 接口 Schema(请求/响应/错误码)
220
+
221
+ ## 5. 跨模块依赖
222
+ - 调用的外部 API(模块 + 接口 + 参数)
223
+ - 共享数据实体的读写边界
224
+ - 事件/消息契约
225
+
226
+ ## 6. 非目标(Not in Scope)
227
+
228
+ ## 7. 风险与假设
229
+
230
+ ## 8. 需求追溯矩阵
231
+ | FR 编号 | 功能点 | US 编号 | AC 编号 | 优先级 |
257
232
  ```
258
- User: "I need to write a PRD for the COMPARE module"
259
-
260
- Assistant: (This skill activates)
261
- "Let's start by creating a requirements outline. First, I'll need to understand:
262
- 1. What is the overall project scope?
263
- 2. What modules are involved?
264
- 3. What are the key dependencies?
265
-
266
- Then we'll create:
267
- - docs/300-requirements/301-prd-outline.md
268
- - docs/300-requirements/311-prd-compare.md
269
- - docs/300-requirements/330-user-stories/331-us-compare-*.md"
233
+
234
+ ### Phase 2: USER STORIES(按功能点并行,≤5 Agents)
235
+
236
+ **目标**:每个核心功能点生成一份完整 US。
237
+
238
+ **派发规则**:
239
+ 1. 从模块 PRD 中提取 P0/P1 优先级的功能点
240
+ 2. 每个功能点 1 个 Agent
241
+ 3. 每批 ≤5 并行
242
+
243
+ **每个 Agent 接收**:
244
+ - Phase 0 共享上下文
245
+ - 所属模块 PRD(完整)
246
+ - 相关模块 PRD 摘要(跨模块功能)
247
+
248
+ **产出**:`docs/requirements/user-stories/{module}-{feature}.md`
249
+
250
+ **US 结构**:
251
+
252
+ ```markdown
253
+ # US-{MOD}-{SEQ}: {Feature Name}
254
+
255
+ ## Story Statement
256
+ As a [角色], I want to [操作], so that [收益].
257
+
258
+ ## 1. 背景与上下文
259
+ - 业务问题
260
+ - 当前状态(现有实现/竞品对比)
261
+ - 为什么现在做
262
+
263
+ ## 2. 用户场景
264
+ - 主场景 walkthrough(step-by-step)
265
+ - 备选路径(≥2 个)
266
+ - 异常路径(≥3 个)
267
+
268
+ ## 3. 功能规格
269
+ - 输入规格(每个字段:类型/校验/边界)
270
+ - 处理规则(业务逻辑,用伪代码或决策表)
271
+ - 输出规格(成功/失败的完整响应)
272
+ - 错误处理(每种错误的用户提示和恢复方式)
273
+
274
+ ## 4. UI/UX 交互
275
+ - 交互流程图(Mermaid)
276
+ - 每个步骤的反馈机制
277
+ - 无障碍要求
278
+ - 响应式行为
279
+
280
+ ## 5. 数据与指标
281
+ - 涉及的数据实体和字段
282
+ - 需要埋点的事件
283
+ - 监控指标
284
+
285
+ ## 6. 权限与安全
286
+ - RBAC 需求
287
+ - 数据范围限制
288
+ - 审计日志要求
289
+
290
+ ## 7. 验收标准
291
+ 每条 AC 必须可自动化验证:
292
+ - AC-{MOD}-{SEQ}-01: Given [前提], When [操作], Then [结果]
293
+ - AC-{MOD}-{SEQ}-02: ...
294
+ (覆盖正常/异常/边界/安全/性能)
295
+
296
+ ## 8. 依赖与集成
297
+ - 前后端依赖
298
+ - 第三方服务
299
+ - 数据迁移需求
300
+
301
+ ## 9. 风险与缓解
302
+
303
+ ## 10. 非目标
270
304
  ```
271
305
 
272
- ## Integration with Doc-Standards-Enforcer
306
+ ### Phase 3: REVIEW & STITCH(主 Agent 审查)
307
+
308
+ **目标**:跨模块一致性检查 + 生成全局索引。
309
+
310
+ **检查项**:
311
+ 1. 术语一致性(所有 PRD 使用相同术语定义)
312
+ 2. 数据模型一致性(同一实体在不同模块的字段定义一致)
313
+ 3. 接口契约一致性(调用方和被调用方的参数定义一致)
314
+ 4. 编号连续性(FR/AC/US 编号无断层)
315
+ 5. 覆盖完整性(所有模块的所有功能都有 US)
316
+
317
+ **产出**:
318
+ - `docs/requirements/000-index.md` — 全局导航索引
319
+ - `docs/requirements/000-traceability-matrix.md` — 需求追溯矩阵
320
+ - `docs/requirements/000-context.md` — 更新后的共享上下文(补齐遗漏)
273
321
 
274
- This skill **automatically invokes** `doc-standards-enforcer` to ensure:
322
+ ---
323
+
324
+ ## 覆盖率检查表(替代字数要求)
325
+
326
+ ### 功能覆盖率(每个功能点必须全部通过)
327
+
328
+ - [ ] 用户故事(As a... I want... so that...)
329
+ - [ ] 验收标准(每条 AC 可自动化验证,Given-When-Then 格式)
330
+ - [ ] 页面/屏幕定义(布局描述 + 所有 UI 元素列表)
331
+ - [ ] 每个按钮:名称 + 触发动作 + 成功反馈 + 失败反馈 + 权限
332
+ - [ ] 每个输入框:类型 + 校验规则 + 错误提示文案 + 占位文本 + 默认值
333
+ - [ ] 每个列表/表格:列定义 + 排序规则 + 分页 + 空状态文案
334
+ - [ ] 每个表单:提交流程 + 二次确认(如需)+ 防重复提交
335
+ - [ ] 权限控制:每个操作的角色可见性矩阵
336
+ - [ ] 四种 UI 状态:加载中 / 空数据 / 错误 / 正常
275
337
 
276
- 1. **File naming**: All files follow `<3-digit-id>-<slug>.md` pattern
277
- 2. **Frontmatter**: All documents have complete frontmatter
278
- 3. **Directory structure**: Files are in correct hundreds-based directories
279
- 4. **Status values**: Use `draft|review|approved|deprecated`
280
- 5. **Version history**: All documents have version history table
281
- 6. **Cross-references**: Use relative paths from repository root
338
+ ### 数据覆盖率
282
339
 
283
- ## Templates
340
+ - [ ] 每个 API 的请求/响应 Schema(字段级定义)
341
+ - [ ] 每个数据实体的完整字段表(含业务规则 + 约束)
342
+ - [ ] 枚举值完整定义(含状态流转规则)
343
+ - [ ] 前后端双重校验规则
344
+ - [ ] 错误码完整表
284
345
 
285
- ### Available Templates
346
+ ### 场景覆盖率
286
347
 
287
- 1. **PRD Outline Template**: `templates/prd-outline-template.md`
288
- - Use for Phase 1: Requirements planning
348
+ - [ ] 正常路径(Happy Path)完整 walkthrough
349
+ - [ ] 异常路径(≥3 个边界场景)
350
+ - [ ] 并发场景(如适用)
351
+ - [ ] 权限边界(越权尝试的预期行为)
352
+ - [ ] 数据极端(空值/超长/特殊字符/超大数值)
289
353
 
290
- 2. **Module PRD Template**: `templates/module-prd-template.md`
291
- - Use for Phase 2: Module-level requirements
354
+ ### 跨模块关联
292
355
 
293
- 3. **User Story Template**: `templates/user-story-template.md`
294
- - Use for Phase 3: Comprehensive US specifications
356
+ - [ ] 依赖模块的接口契约(调用哪个 API、传什么参数、返回什么)
357
+ - [ ] 共享数据实体的读写边界声明
358
+ - [ ] 事件/消息的生产者和消费者定义
295
359
 
296
- ### Template Usage
360
+ ---
361
+
362
+ ## 质量标准
297
363
 
298
- Templates include:
299
- - Complete frontmatter
300
- - Section placeholders with guidance
301
- - Required fields highlighted
302
- - Example content structure
303
- - Validation reminders
364
+ ### 需求质量(来自 PRD skill 最佳实践)
304
365
 
305
- ## Common Mistakes to Avoid
366
+ 必须使用具体、可度量的标准。禁止 "fast"、"easy"、"intuitive":
306
367
 
307
- ### PRD Writing
308
- 1. **Mixing business and technical**: PRDs should focus on "what", not "how"
309
- 2. **Vague requirements**: Requirements must be specific and testable
310
- 3. **Missing NFRs**: Forgetting performance, security, scalability
311
- 4. **Subjective ACs**: Using "good experience", "fast" instead of measurable criteria
312
- 5. **No scope boundaries**: Not defining what's out of scope
368
+ ```diff
369
+ # 模糊(BAD)
370
+ - 搜索应该快速并返回相关结果
371
+ - UI 必须美观且易于使用
313
372
 
314
- ### User Story Writing
315
- 1. **Insufficient detail**: Not reaching 8000+ word requirement
316
- 2. **Missing sections**: Skipping required sections
317
- 3. **Vague acceptance criteria**: Criteria that can't be objectively verified
318
- 4. **No data references**: Not specifying data structures and fields
319
- 5. **Missing security/audit**: Forgetting RBAC and audit requirements
320
- 6. **Incomplete edge cases**: Not covering error scenarios
373
+ # 具体(GOOD)
374
+ + 搜索必须在 200ms 内返回结果(10K 记录数据集)
375
+ + 搜索算法必须达到 >= 85% Precision@10
376
+ + UI 必须遵循 Vercel/Next.js 设计系统,Lighthouse 无障碍评分 100%
377
+ ```
321
378
 
322
- ## Writing Quality Standards
379
+ ### 验收标准格式
323
380
 
324
- ### PRD Quality
325
- - **Clarity**: Non-technical stakeholders can understand
326
- - **Completeness**: All functional and non-functional requirements covered
327
- - **Consistency**: No contradictions within or across documents
328
- - **Traceability**: Each requirement links to User Story and AC
381
+ 必须使用 Given-When-Then 格式:
329
382
 
330
- ### User Story Quality
331
- - **Comprehensive**: All 10 sections thoroughly covered (8000+ words)
332
- - **Testable**: Every acceptance criterion can be verified
333
- - **Data-aware**: All data structures referenced and defined
334
- - **Security-aware**: RBAC, data scope, and audit requirements specified
335
- - **Integration-aware**: Dependencies and integration points documented
383
+ ```
384
+ Given: 用户已登录且拥有管理员角色
385
+ When: 用户点击"删除用户"按钮并确认
386
+ Then: 系统删除用户记录,返回 204,列表刷新且不再显示该用户
387
+ ```
388
+
389
+ ---
390
+
391
+ ## 与 project-analyze 集成
392
+
393
+ ### 后向模式(代码 → 需求)
394
+
395
+ 当 `atool-analysis/` 存在时,requirements-writer 自动进入后向增强模式:
396
+
397
+ 1. **Phase 0**:从 `atool-analysis/` 预填充共享上下文
398
+ - `overview/summary.md` → 项目概述
399
+ - `data/modules.json` → 模块地图
400
+ - `modules/*/data-model.md` → 数据模型索引
401
+ 2. **Phase 1**:从 `modules/*/prd.md` 读取逆向 PRD 作为基线
402
+ - 代码中已实现的功能 → 标注 [已实现]
403
+ - 补充交互细节/业务规则/边界条件
404
+ 3. **Phase 2**:从 `modules/*/api.md` 提取接口定义
405
+ - 自动生成 API 相关的 AC(Given-When-Then)
406
+ 4. **Phase 3**:对比最终 PRD 与代码实现
407
+ - 标注 [待实现](PRD 有但代码无)
408
+ - 标注 [需补充 PRD](代码有但 PRD 未覆盖)
409
+
410
+ ### 前向模式(需求 → 代码)
411
+
412
+ 无 `atool-analysis/` 时,标准从零写 PRD 流程。Phase 0 通过用户访谈获取上下文。
413
+
414
+ ---
415
+
416
+ ## 并行 Agent 规则
417
+
418
+ - 每批最多 5 个 Agent 并行
419
+ - 被依赖的模块优先(Phase 0 确定顺序)
420
+ - 每个 Agent prompt 必须包含完整共享上下文
421
+ - 产出经主 Agent review 后才算完成
422
+ - Cursor/Kiro 降级为顺序执行
423
+
424
+ ---
336
425
 
337
- ## Version History
426
+ ## Skill 协作
338
427
 
339
- | Version | Date | Owner | Change |
340
- |---|---|---|---|
341
- | v1.0.0 | 2026-01-09 | Claude Code | Initial skill implementation with phased workflow approach |
428
+ | 协作 Skill | 触发条件 | 交互方式 |
429
+ |-----------|---------|---------|
430
+ | clarify-before-build | Phase D 需求清晰度评估 | 引用 Tier 分级机制判断是否需要访谈 |
431
+ | brainstorming | Phase D Tier 3(需求极模糊) | 引用一次一问+多选优先的对话风格 |
432
+ | project-analyze | atool-analysis/ 存在时 | 读取分析结果作为数据源(后向增强模式) |
433
+ | doc-standards-enforcer | 所有文档输出 | 验证格式/命名/frontmatter 合规 |
434
+ | software-architecture | PRD 涉及架构决策 | 建议运行 /software-architecture |
435
+ | code-review | PRD 完成后需要验证代码一致性 | 建议运行 /code-review |