@laitszkin/apollo-toolkit 5.0.3 → 5.0.4

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this repository are documented in this file.
4
4
 
5
+ ## [v5.0.4] - 2026-06-07
6
+
7
+ ### Added
8
+
9
+ - **design skill `references/` folder**: Design phase now populates `<spec_dir>/references/` with external method/API reference documents (name, purpose, required parameters), reducing hallucinated external code during implementation.
10
+ - **`apltk codegraph` as dedicated workflow step**: `spec` and `docs-project` skills now run `apltk codegraph survey` before reading requirements, ensuring BDD boundaries align with real code. `design` uses codegraph survey before architecture design.
11
+ - **Brownfield refactoring assessment**: `design` skill now includes explicit T1–T3 refactoring planning for brownfield changes as a standard workflow step.
12
+ - **Worker prompt separation**: `plan` and `qa` skills now store worker prompts in `plan/*.md` and `fix/*.md` files respectively, keeping coordinator prompts focused on strategy. PROMPT.md/FIX.md Reference sections cite all worker prompt paths and code file paths.
13
+ - **Prompt generation guidance consolidated**: Notes on writing quality worker prompts moved from PROMPT.md/FIX.md templates into `plan`/`qa` SKILL.md, aligning with the optimise-skill principle of behavioral guidance in SKILL.md.
14
+
15
+ ### Changed
16
+
17
+ - **Self-review renamed to Verification**: `design` and `spec` skills now use "Pre-delivery Verification" with explicit completeness and quality checks, plus code traceability validation.
18
+
5
19
  ## [v5.0.3] - 2026-06-06
6
20
 
7
21
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laitszkin/apollo-toolkit",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Apollo Toolkit npm installer for managed skill copying across Codex, OpenClaw, and Trae.",
5
5
  "license": "MIT",
6
6
  "author": "LaiTszKin",
@@ -12,9 +12,13 @@ During architecture survey, identify and classify refactoring opportunities by m
12
12
  ## Acceptance Criteria
13
13
 
14
14
  - Three web research passes completed and recorded
15
+ - `apltk codegraph` survey run on affected modules, with findings recorded
16
+ - Brownfield assessment completed: T1–T3 refactoring opportunities identified and dispositioned
15
17
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/DESIGN.md` produced, covering: architecture design, external dependencies (with API facts and limits), data persistence, invariants, technical trade-offs, design-time refactoring
16
18
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/CHECKLIST.md` produced, covering: behavior-to-test mapping, hardening requirements, test level choices
19
+ - `docs/plans/<YYYY-MM-DD>/<spec_name>/references/` populated with external method/API reference documents (name, purpose, required parameters)
17
20
  - Architecture Diff produced using the C4 model hierarchy
21
+ - DESIGN.md and CHECKLIST.md References sections cite all designed code file paths (not just project context files)
18
22
  - Design-time refactoring classified by module boundary scope (T1–T3) and dispositioned (refactored / scheduled / deferred with rationale)
19
23
 
20
24
  ## Workflow
@@ -72,9 +76,42 @@ Verify external dependency compatibility with the repo's existing dependencies:
72
76
 
73
77
  Output: Recommended tech stack + compatibility report
74
78
 
75
- ### 3. Design Architecture → DESIGN.md
79
+ ### 3. CodeGraph Survey
76
80
 
77
- Based on the research findings, design the architecture. Use `assets/templates/DESIGN.md`.
81
+ Deeply investigate the repo using `apltk codegraph` before designing.
82
+
83
+ #### 3a. Survey the Project
84
+
85
+ Run `apltk codegraph survey --json` to get entry points, function clusters, and cross-boundary edges.
86
+
87
+ Consult `references/codegraph.md` for detailed flags.
88
+
89
+ #### 3b. List APIs in Affected Areas
90
+
91
+ Use `apltk codegraph list-apis` to review the full project API directory in the affected modules — function names, file paths, callers. Understand what existing modules and functions the new feature will interact with.
92
+
93
+ #### 3c. Code Health Assessment
94
+
95
+ While reading code via codegraph, actively assess code quality:
96
+ - Identify code smells, dead code, legacy patterns, and unnecessary complexity in the affected modules
97
+ - Classify findings using the T1–T3 framework (see `references/code-smells.md` for patterns to recognize)
98
+ - T1 items (module-internal simplification) are safe to refactor immediately — existing tests validate behavioral preservation
99
+ - T2 and T3 items feed into the target architecture design
100
+
101
+ ### 4. Read Spec and Design Architecture → DESIGN.md
102
+
103
+ Based on web research (Step 2) and codegraph findings (Step 3), design the architecture. Use `assets/templates/DESIGN.md`.
104
+
105
+ #### 4a. Brownfield Assessment
106
+
107
+ If this is a brownfield change (modifying existing code), design a refactoring plan:
108
+ - Identify which existing modules need restructuring to accommodate the new feature
109
+ - Classify refactoring by T1–T3 scopes (see `references/code-smells.md`)
110
+ - T1: Safe to refactor inline — existing unit tests validate behavior
111
+ - T2: Schedule in task decomposition — existing integration tests validate
112
+ - T3: Define migration strategy with dedicated test coverage
113
+
114
+ #### 4b. Fill DESIGN.md
78
115
 
79
116
  Transfer the research outputs from Steps 2a-2c into the **Research Summary** section of DESIGN.md (feasibility table, reference patterns table, tech stack compatibility table).
80
117
 
@@ -87,17 +124,17 @@ Cover the following sections:
87
124
  - **System Invariants**: Architectural constraints that must not be violated, plus violation symptoms
88
125
  - **Technical Trade-offs**: Each decision with rejected alternatives and lock-in effects
89
126
  - **Design-Time Refactoring**: T1–T3 code health findings classified and dispositioned
90
- - **References**: List important project context files the LLM will need to understand this design (e.g., `CLAUDE.md`, `AGENTS.md`, architecture atlas files). This reduces the LLM's need to search for relevant files when processing the design document.
127
+ - **References**: List designed code file paths, project context files, and related documents
91
128
 
92
129
  Use `Req 1`, `Req 2` numbering to reference SPEC.md requirements (matching the SPEC.md template's `Requirement 1`, `Requirement 2`).
93
130
 
94
131
  **Scale awareness** — Not every section applies at full depth. Adapt based on the change's scope:
95
132
 
96
- - **Interaction Design (Section 3)**: If the change is confined to a single module with no new cross-module coupling, mark this section as `None`. Do not fabricate INT-### entries.
97
- - **External Dependency deep-dives (Section 4.2)**: For simple utility libraries (e.g., date formatting, UUID generation) with no API quotas, authentication, or failure modes, skip the sub-tables. A one-line entry in Section 4.1 overview suffices.
98
- - **Target vs Baseline (Section 2.3)**: If the change touches multiple dimensions (new modules, removed modules, ownership shifts, deployment changes), expand to multiple rows. A single-dimension change needs only one row.
99
- - **System Invariants (Section 6)**: If the change does not modify any architectural constraint, explicitly write `None` with brief justification.
100
- - **Design-Time Refactoring (Section 8)**: If no code health issues were identified during the architecture survey, write `None`. Do not fabricate findings.
133
+ - **Interaction Design**: If the change is confined to a single module with no new cross-module coupling, mark this section as `None`. Do not fabricate INT-### entries.
134
+ - **External Dependency deep-dives**: For simple utility libraries (e.g., date formatting, UUID generation) with no API quotas, authentication, or failure modes, skip the sub-tables. A one-line entry in the overview suffices.
135
+ - **Target vs Baseline**: If the change touches multiple dimensions (new modules, removed modules, ownership shifts, deployment changes), expand to multiple rows. A single-dimension change needs only one row.
136
+ - **System Invariants**: If the change does not modify any architectural constraint, explicitly write `None` with brief justification.
137
+ - **Design-Time Refactoring**: If no code health issues were identified during the architecture survey, write `None`. Do not fabricate findings.
101
138
 
102
139
  **Design self-challenge** — Before finalizing the design, step back and ask three questions:
103
140
 
@@ -105,18 +142,10 @@ Use `Req 1`, `Req 2` numbering to reference SPEC.md requirements (matching the S
105
142
  2. **Is this the simplest viable design?** Have I introduced abstractions, indirections, or intermediate layers that are not justified by the current requirements? Prefer the simplest structure that works.
106
143
  3. **Are there rejected alternatives?** For every major architectural decision (module split, dependency choice, communication pattern), if you have not considered and explicitly rejected at least one alternative, you may be settling on the first workable solution rather than the best one.
107
144
 
108
- **Design-time refactoring** — While designing the target architecture, also assess code health in the affected modules:
109
-
110
- - **T1 (Module-internal simplification)**: Simplify control flow, remove dead code, inline unnecessary wrappers within a single function or file. Existing unit tests validate behavior — refactor directly.
111
- - **T2 (Module-internal restructuring)**: Extract shared logic, consolidate state, reorganize files within the same module boundary. Existing integration tests validate behavior — include in the design's task decomposition.
112
- - **T3 (Module boundary adjustment)**: Changes affecting a module's public API, data contract, or cross-module coupling. Requires dedicated test coverage — define test strategy in CHECKLIST.md.
113
-
114
- See `references/code-smells.md` for patterns to identify, and the module-specific reference files for detailed guidance per tier.
115
-
116
145
  **Single spec**: Produce one DESIGN.md for one SPEC.md.
117
146
  **Batch spec**: Produce **one** unified DESIGN.md covering the scope of all SPEC.md files in the batch.
118
147
 
119
- ### 4. Define Verification Strategy → CHECKLIST.md
148
+ ### 5. Define Verification Strategy → CHECKLIST.md
120
149
 
121
150
  Use the `test-case-strategy` skill to design the verification strategy.
122
151
  Use `assets/templates/CHECKLIST.md`.
@@ -128,7 +157,7 @@ Cover the following sections:
128
157
  - **Hardening Requirements**: Regression tests, drift checks, property-based tests, edge cases, authorization checks
129
158
  - **E2E / Integration Decisions**: Per flow, choose the appropriate test level with rationale
130
159
  - **Design-Time Refactoring (T3)**: If T3 refactoring is planned, define its test coverage requirements here
131
- - **References**: List important project context files the LLM will need (e.g., `CLAUDE.md`, `AGENTS.md`).
160
+ - **References**: List designed code file paths, project context files, and related documents
132
161
 
133
162
  **Mandatory test coverage** (applies when the SPEC.md describes changes other than pure documentation or pure test changes):
134
163
 
@@ -141,38 +170,24 @@ Risk definitions: **Medium risk** = paths involving I/O, external dependencies,
141
170
  **Single spec**: Produce one CHECKLIST.md for one SPEC.md.
142
171
  **Batch spec**: Produce **one** unified CHECKLIST.md covering the behavioral requirements of all SPEC.md files in the batch.
143
172
 
144
- ### 5. Generate Architecture Diff
173
+ ### 6. Generate Architecture Diff
145
174
 
146
175
  Use the `apltk architecture` CLI tool to generate the Architecture Diff, following the C4 model hierarchy.
147
176
 
148
- #### 5a. Survey the project with `apltk codegraph survey`
149
-
150
- **Prerequisite** before any diff work. Survey the project code to establish a code-level baseline for comparison with the atlas.
151
-
152
- Run `apltk codegraph survey --json` to get entry points, function clusters, and cross-boundary edges.
153
-
154
- Consult `references/codegraph.md` for detailed flags.
155
-
156
- #### 5b. Read the Existing Architecture
177
+ #### 6a. Read the Existing Architecture
157
178
 
158
179
  Read the project's existing architecture files (`resources/project-architecture/atlas/atlas.index.yaml` + the affected feature YAML files).
159
180
  Do not read unrelated features or modules — maintain context economy.
160
181
 
161
182
  If no existing architecture exists, skip the baseline comparison and start defining the boundary from System Context level.
162
183
 
163
- **Code health assessment** While reading code to measure the baseline, actively assess code quality:
164
- - Identify code smells, dead code, legacy patterns, and unnecessary complexity in the affected modules
165
- - Classify findings using the T1–T3 framework (see `references/code-smells.md` for patterns to recognize)
166
- - T1 items (module-internal simplification) are safe to refactor immediately — existing tests validate behavioral preservation
167
- - T2 and T3 items feed into the target architecture design in Step 3
168
-
169
- #### 5c. Measure Baseline Drift
184
+ #### 6b. Measure Baseline Drift
170
185
 
171
186
  Compare the existing architecture diagram against the current code to assess its reliability:
172
187
  - If the baseline atlas differs significantly from the code (> 20% entries inconsistent), flag the risk in the architecture diff
173
188
  - If the baseline atlas is reliable, the diff can be layered directly on top of it
174
189
 
175
- #### 5d. Define the Diff by C4 Level
190
+ #### 6c. Define the Diff by C4 Level
176
191
 
177
192
  1. **System Context**: Define external actors, system boundaries, cross-system edges
178
193
  2. **Container level** (features): Define new or modified features and the edges between them
@@ -181,62 +196,85 @@ Compare the existing architecture diagram against the current code to assess its
181
196
 
182
197
  C4 level mapping: System Context → system boundary, Container → feature, Component → submodule, Code → function (selective). See `references/definition.md` for full definitions.
183
198
 
184
- #### 5e. Evidence Tracing
199
+ #### 6d. Evidence Tracing
185
200
 
186
201
  Each component should link to:
187
202
  - The requirement number from SPEC.md (requirement → module)
188
203
  - The technical decision from research findings (decision → dependency choice)
189
204
 
190
- #### 5f. Generate the Diff and Validate
205
+ #### 6e. Generate the Diff and Validate
191
206
 
192
207
  Two alternative workflows — use the **Classic flow** when `codegraph` is not installed, or the **CodeGraph-integrated flow** when it is available.
193
208
 
194
209
  **Classic flow** (manual):
195
210
  Generate and validate the architecture diff using `apltk architecture` commands. Confirm validation passes, then produce a visual comparison. See `references/architecture.md` for all CLI flags.
196
211
 
197
- **New flow (CodeGraph-integrated):**
198
-
199
- 1. **Survey the existing API landscape** — Use `apltk codegraph list-apis` to review the full project API directory (function names, file paths, callers). Understand what existing modules and functions your new feature will interact with.
212
+ **CodeGraph-integrated flow:**
200
213
 
201
- 2. **Fill the proposal skeleton** — Based on your design decisions from steps 5b5e, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
214
+ 1. **Fill the proposal skeleton** — Based on design decisions from steps 6a6d, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
202
215
 
203
- 3. **Apply and verify** — Apply the mutations and verify correctness:
216
+ 2. **Apply and verify** — Apply the mutations and verify correctness:
204
217
  - `apltk architecture apply` processes all mutations with undo protection
205
218
  - `apltk codegraph verify` confirms every symbol and edge reference exists in actual code
206
219
 
207
- 4. **Render diff** (optional) — `apltk architecture diff --spec <spec_dir>` for visual confirmation.
220
+ 3. **Render diff** (optional) — `apltk architecture diff --spec <spec_dir>` for visual confirmation.
208
221
 
209
222
  See `references/architecture.md` for exact CLI flags and mutation commands.
210
223
 
211
224
  **Single spec**: Produce one Architecture Diff for one SPEC.md.
212
225
  **Batch spec**: Produce **one** unified Architecture Diff covering all SPEC.md files in the batch.
213
226
 
214
- ### 6. Pre-delivery Self-Review
227
+ ### 7. Populate references/ Folder
228
+
229
+ Under `<spec_dir>/references/` (single spec) or `<batch_dir>/references/` (batch spec), create reference documents for every external method and API used in the design:
230
+
231
+ #### External Methods
232
+
233
+ For each external method referenced in the design, document:
234
+ - **Method name**: The method or function name
235
+ - **Purpose**: What it does, why it is needed
236
+ - **Required parameters**: Input parameters with types and descriptions
237
+ - **Source**: Where this method is documented (URL or code path)
238
+
239
+ #### External APIs
240
+
241
+ For each external API referenced in the design, document:
242
+ - **API name**: The API or service name
243
+ - **Purpose**: What it does, why it is needed
244
+ - **Required parameters**: Request payload structure, query parameters, headers
245
+ - **Authentication**: How to authenticate (key location, scope)
246
+ - **Rate limits / quotas**: Documented limits
247
+
248
+ **Why this step exists**: Explicit external method/API reference documentation reduces the chance of hallucinated code during implementation. Workers and coordinators can consult these files instead of guessing API shapes.
249
+
250
+ ### 8. Pre-delivery Verification
215
251
 
216
252
  Before delivering, run two passes — completeness then quality.
217
253
 
218
- **Completeness checks** (documentation integrity):
254
+ #### Completeness checks (documentation integrity)
219
255
 
220
256
  - Research results are recorded in DESIGN.md as evidence for technical decisions
221
257
  - Every architecture decision has a trade-off record (rejected alternatives + lock-in effects)
222
258
  - External dependency API facts are traceable to official documentation
223
259
  - CHECKLIST.md completely covers all BDD requirements from SPEC.md
224
260
  - Architecture Diff covers the full change scope
225
- - Design-time refactoring is documented in DESIGN.md Section 8, with T1–T3 findings classified and dispositioned (refactored / scheduled / deferred with rationale)
261
+ - Design-time refactoring is documented in DESIGN.md with T1–T3 findings classified and dispositioned
262
+ - `references/` folder exists with external method and API reference documents
263
+ - DESIGN.md and CHECKLIST.md References sections cite designed code file paths
226
264
 
227
- **Design quality checks** (architectural soundness):
265
+ #### Design quality checks (architectural soundness)
228
266
 
229
267
  - **Requirement traceability**: Can every BDD behavior from SPEC.md be traced to a module, interaction, data flow, or invariant in this design?
230
- - **Internal consistency**: Do the modules listed in Section 2 appear as callers or callees in Section 3? Do the dependencies in Section 4 correspond to module responsibilities in Section 2?
268
+ - **Internal consistency**: Do the modules listed in the architecture appear as callers or callees in the interaction design? Do the dependencies correspond to module responsibilities?
231
269
  - **Design simplicity**: Is this the simplest design that satisfies all requirements? Could any module, abstraction, or dependency be removed without breaking functionality?
232
- - **Risk transparency**: Are all feasibility risks, compatibility concerns, or uncertain technical points from Step 2 either addressed in the design or explicitly documented as accepted risks?
233
- - **Refactoring disposition**: Are all identified code health findings accounted for — either refactored, scheduled in the task plan, or explicitly deferred with rationale? Unaddressed T1/T2 findings represent missed opportunities to reduce technical debt at the cheapest possible time.
270
+ - **Risk transparency**: Are all feasibility risks, compatibility concerns, or uncertain technical points either addressed in the design or explicitly documented as accepted risks?
271
+ - **Refactoring disposition**: Are all identified code health findings accounted for — either refactored, scheduled in the task plan, or explicitly deferred with rationale?
234
272
 
235
273
  ## Examples
236
274
 
237
- - "SPEC.md defines a real-time messaging feature" → Research WebSocket vs SSE vs Polling → Confirm compatibility → Choose SSE → Design architecture → Produce DESIGN.md + CHECKLIST.md + Architecture Diff → During code survey, identify legacy socket wrapper (T2) → schedule extraction in task plan
238
- - "SPEC.md requires CSV export, repo has no CSV library" → Research Node.js CSV libraries (json2csv vs csv-writer vs papaparse) → Confirm compatibility → Choose the lightest option → Design export flow architecture
239
- - "Batch spec: docs/plans/2026-05-29/auth-redesign/ with 3 SPEC.md files (login, permissions, 2FA)" → Read all 3 SPEC.md files → Unified research → Produce **one** DESIGN.md + CHECKLIST.md + Architecture Diff → Identify dead auth middleware during survey (T1) → remove and verify with existing tests
275
+ - "SPEC.md defines a real-time messaging feature" → Research WebSocket vs SSE vs Polling → CodeGraph survey to find existing socket infrastructure → Confirm compatibility → Choose SSE → Design architecture → Produce DESIGN.md + CHECKLIST.md + Architecture Diff → During code survey, identify legacy socket wrapper (T2) → schedule extraction in task plan → Populate references/ with external API docs
276
+ - "SPEC.md requires CSV export, repo has no CSV library" → Research Node.js CSV libraries (json2csv vs csv-writer vs papaparse) → CodeGraph survey to understand export module boundaries → Confirm compatibility → Choose the lightest option → Design export flow architecture → Document CSV library API in references/
277
+ - "Batch spec: docs/plans/2026-05-29/auth-redesign/ with 3 SPEC.md files (login, permissions, 2FA)" → Read all 3 SPEC.md files → Unified research → CodeGraph survey of auth modules → Unified DESIGN.md + CHECKLIST.md + Architecture Diff → Brownfield assessment: identify dead auth middleware during survey (T1) → remove and verify with existing tests → Populate references/ with auth API docs
240
278
 
241
279
  ## References
242
280
 
@@ -42,5 +42,6 @@ Map each BDD requirement from SPEC.md to one or more tests:
42
42
 
43
43
  ## References
44
44
 
45
+ - **Designed code file paths**: [List code file paths that this design touches or references — e.g., `src/auth/login.ts`, `src/api/routes.ts`]
45
46
  - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
46
47
  - **Related documents**: [Links to related SPEC.md, DESIGN.md, or external documentation]
@@ -156,5 +156,6 @@ If none, write **None**.
156
156
 
157
157
  ## 9. References
158
158
 
159
+ - **Designed code file paths**: [List code file paths that this design touches or references — e.g., `src/auth/login.ts`, `src/api/routes.ts`]
159
160
  - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
160
161
  - **Related documents**: [Links to related SPEC.md, other design docs, or external documentation]
@@ -13,6 +13,8 @@ description: >-
13
13
 
14
14
  ## 驗收條件
15
15
 
16
+ - 使用 `apltk codegraph` 完成 repo 深度調查,產出模組邊界與 API 目錄分析
17
+ - 使用 subagents 閱讀關鍵程式碼片段,確保文檔記述可驗證
16
18
  - repo 的所有細節被仔細閱讀,並轉化為標準化的 `docs/features/`、`docs/architecture/`、`docs/principles/` 文檔
17
19
  - 每條文檔記述皆有可追溯的來源證據(檔案路徑 + 行號區間);無法證明的內容標記為 `[INFERRED]`
18
20
  - `AGENTS.md` / `CLAUDE.md` 已被同步更新
@@ -20,21 +22,36 @@ description: >-
20
22
 
21
23
  ## 工作流程
22
24
 
23
- ### 1. 建立對 repo 的基線認知
25
+ ### 1. 使用 CodeGraph 深入調查 Repo
24
26
 
25
- 閱讀項目現有文檔,建立對 repo 的基線認知,制定後續閱讀策略。
27
+ 在開始文檔工作前,先用 `apltk codegraph` 建立對 repo 的深度理解。
26
28
 
27
- ### 2. 比對 repo 及項目文檔
29
+ 1. 執行 `apltk codegraph survey --json` 取得專案的 entry points、function clusters、cross-boundary edges
30
+ 2. 使用 `apltk codegraph list-apis` 檢視完整 API 目錄(函式名稱、檔案路徑、呼叫者)
31
+ 3. 對關鍵模組使用 `apltk codegraph explore` 深入了解內部結構
32
+
33
+ 將調查結果記錄為結構化摘要,供後續文檔撰寫使用。
34
+
35
+ ### 2. 建立對 Repo 的基線認知
36
+
37
+ 閱讀項目現有文檔,並結合 CodeGraph 調查結果,建立對 repo 的基線認知,制定後續閱讀策略。
38
+
39
+ ### 3. 比對 Repo 及項目文檔
28
40
 
29
41
  按照上一步建立的閱讀策略,通過並行調度 subagents 全面搜索整個 repo,驗證並確保現有項目文檔的描述正確、無遺漏。
30
42
 
31
- ### 3. 制定文檔更新策略
43
+ 使用 subagents 深入閱讀關鍵程式碼片段:
44
+ - 每個 subagent 負責一個模組或檔案群組
45
+ - Subagent 閱讀原始碼後回報:模組職責、關鍵函式、資料流程、外部整合點
46
+ - 將 subagent 發現與現有文檔比對,標記差異
47
+
48
+ ### 4. 制定文檔更新策略
32
49
 
33
50
  根據上一步發現的文檔遺漏或脫節之處,制定文檔更新策略。
34
51
  閱讀模板文檔;使用模板規定的格式重寫所有項目文檔。
35
52
  移除舊有說明文檔(必要文檔如 `CHANGELOG.md`、`CONTRIBUTION.md` 除外)。
36
53
 
37
- ### 4. 後續維護指引
54
+ ### 5. 後續維護指引
38
55
 
39
56
  完成初始文檔後,在 `docs/README.md` 中記錄以下維護指引:
40
57
 
@@ -44,4 +61,4 @@ description: >-
44
61
  - **定期 drift detection**(建議):定期(每月或每季)比對文檔與實際程式碼,確認無重大偏離。發現 drift 時只修補受影響章節,不全面重寫。
45
62
 
46
63
  ## 參考資料
47
- - `assets/templates/standardized-docs-template.md` - 三類文檔的目標結構、分類規則與清理檢查表。
64
+ - `assets/templates/standardized-docs-template.md` - 三類文檔的目標結構、分類規則與清理檢查表。
@@ -59,7 +59,7 @@ Report to the user:
59
59
 
60
60
  ## Examples
61
61
 
62
- - FIX.md defines Batch 1 with 2 parallel fixes → Coordinator extracts FIX-01 and FIX-03 worker prompts from Section 6 → Dispatches 2 workers → Waits → Digests results → Runs gate verification → Proceeds to Batch 2
62
+ - FIX.md defines Batch 1 with 2 parallel fixes → Coordinator reads FIX-01 and FIX-03 worker prompts from `fix/` files listed in Section 6 (Worker Prompt Index) → Dispatches 2 workers → Waits → Digests results → Runs gate verification → Proceeds to Batch 2
63
63
  - Worker FIX-02 reports failure → Coordinator retries the worker with more specific guidance → Second attempt still fails → Pauses, preserves FIX-01's success, notifies the user
64
64
  - All batches complete → Regression tests pass → Commit → Cross-check REPORT.md → Report
65
65
 
@@ -56,7 +56,7 @@ Report to the user:
56
56
 
57
57
  ## Examples
58
58
 
59
- - PROMPT.md defines Batch 1 with 2 parallel tasks → Coordinator extracts T1.1 and T1.2 worker prompts from Section 6 → Dispatches 2 workers → Waits for both → Digests results → Runs gate verification → Proceeds to Batch 2
59
+ - PROMPT.md defines Batch 1 with 2 parallel tasks → Coordinator reads T1.1 and T1.2 worker prompts from `plan/` files listed in Section 6 (Worker Prompt Index) → Dispatches 2 workers → Waits for both → Digests results → Runs gate verification → Proceeds to Batch 2
60
60
  - Worker T2.1 reports failure → Coordinator retries the worker with more specific guidance → Second attempt still fails → Pauses, preserves T2.2's success, notifies the user
61
61
  - Merge conflict detected when combining worker results → Coordinator resolves the conflict markers → Re-runs batch gate verification → Proceeds
62
62
 
@@ -13,16 +13,22 @@ This prompt defines a coordinator agent:
13
13
 
14
14
  This skill is responsible for "planning the coordination strategy" — extracting information from SPEC/DESIGN/CHECKLIST, decomposing into concrete tasks, pre-writing worker prompts, and scheduling batch execution order.
15
15
 
16
+ Worker prompts are written to individual files under `<spec_dir>/plan/` (single spec) or `<batch_dir>/plan/` (batch spec) instead of inline in PROMPT.md. This keeps PROMPT.md focused on coordination strategy while each worker prompt is independently dispatchable.
17
+
16
18
  ## Acceptance Criteria
17
19
 
18
20
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/PROMPT.md` is produced and placed at the root of the spec or batch spec directory
19
21
  - PROMPT.md is a **self-contained coordinator prompt**, containing:
20
22
  - Coordinator role definition (what to do, what not to do)
21
23
  - Task decomposition with dependency graph
22
- - Pre-written worker prompts for every dispatchable task (self-contained, ready to send)
24
+ - Worker prompt index referencing `plan/*.md` files
23
25
  - Batch schedule with verification gates
24
26
  - Error recovery strategy
25
27
  - Boundary rules (ALWAYS / ASK FIRST / NEVER)
28
+ - Worker prompts are stored in `<spec_dir>/plan/*.md` or `<batch_dir>/plan/*.md`, one prompt per file
29
+ - PROMPT.md References section cites:
30
+ - Worker prompt file paths (`plan/*.md`)
31
+ - All code file paths that need modification across all tasks
26
32
 
27
33
  ## Workflow
28
34
 
@@ -39,6 +45,7 @@ Read all files thoroughly:
39
45
  - `SPEC.md` — Business requirements and scope (BDD GIVEN/WHEN/THEN), In/Out of Scope
40
46
  - `DESIGN.md` — Module architecture, interaction anchors (INT-###), external dependencies (EXT-###), system invariants, technical trade-offs
41
47
  - `CHECKLIST.md` — Behavior-to-test mapping, hardening requirements, test level choices
48
+ - `<spec_dir>/references/` or `<batch_dir>/references/` — External method/API reference documents (name, purpose, parameters)
42
49
 
43
50
  ### 3. Task Decomposition
44
51
 
@@ -88,7 +95,9 @@ File overlap detection is the **gate that determines parallelism**. Perform this
88
95
 
89
96
  ### 6. Write Worker Prompts (One Per Dispatchable Task)
90
97
 
91
- For each task that needs an independent worker, write a self-contained worker prompt. PROMPT.md Section 6 (Worker Prompt Library).
98
+ For each task that needs an independent worker, write a self-contained worker prompt. Save each prompt to a separate file under `<spec_dir>/plan/` or `<batch_dir>/plan/`.
99
+
100
+ **Worker prompt file naming**: `plan/T{batch}.{sequence}-{kebab-case-name}.md`
92
101
 
93
102
  Each worker prompt must include:
94
103
 
@@ -102,11 +111,11 @@ Each worker prompt must include:
102
111
  ## Boundaries — Constraints (don't touch other workers' files, don't add dependencies, report blockers)
103
112
  ```
104
113
 
105
- **Writing principles:**
106
- - **Self-contained**: Workers do not see the coordinator's context. The prompt must include everything necessary
107
- - **Concrete**: For every file the worker must modify, specify: (1) the exact file path, (2) the function or line range, (3) what to add, delete, or change. Do not write "fix it", "update as needed", or "based on your findings"
108
- - **Declarative**: Describe "what to do", not "which tool to use"
109
- - **Clear boundaries**: Explicitly list allowed and forbidden files
114
+ **Writing principles (move these to your process, not the template):**
115
+ - **Self-contained**: Workers do not see the coordinator's context. The prompt must include everything necessary. Do not rely on shared context or assume the worker has read other documents.
116
+ - **Concrete**: For every file the worker must modify, specify: (1) the exact file path, (2) the function or line range, (3) what to add, delete, or change. Do not write "fix it", "update as needed", or "based on your findings".
117
+ - **Declarative**: Describe "what to do", not "which tool to use".
118
+ - **Clear boundaries**: Explicitly list allowed and forbidden files. A worker should never need to guess which files it can modify.
110
119
 
111
120
  Tasks that do not need a worker (purely procedural operations) do not get a worker prompt. The coordinator handles these directly in the corresponding batch.
112
121
 
@@ -132,7 +141,7 @@ Based on dependency analysis and file overlap detection, build the batch schedul
132
141
 
133
142
  → PROMPT.md Section 10 (Boundaries).
134
143
 
135
- - **ALWAYS**: Run gate verification after every batch, extract worker prompts verbatim from Section 6, digest results before deciding next step
144
+ - **ALWAYS**: Run gate verification after every batch, extract worker prompts verbatim from Section 7, digest results before deciding next step
136
145
  - **ASK FIRST**: Modify files not defined in SPEC/DESIGN, add new dependencies, two worker failures, regression with unclear cause
137
146
  - **NEVER**: Coordinator edits source code directly, workers spawn sub-workers, skip verification, issue vague instructions
138
147
 
@@ -146,13 +155,13 @@ Use `assets/templates/PROMPT.md`. Fill each section according to the table below
146
155
  | 2. Mission | SPEC.md Goal + business value |
147
156
  | 3. Scope & Boundaries | SPEC.md In/Out of Scope |
148
157
  | 4. Technical Context | DESIGN.md: module list with responsibilities, interaction anchors (INT-###) and dependency order, external dependency setup order (EXT-###), system invariants, technical decisions and trade-offs |
149
- | 5. References | Important project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) reduces LLM search overhead |
150
- | 6. Task Units | Step 3 (task decomposition) + Step 4 (dependency analysis) |
151
- | 7. Worker Prompt Library | Step 6 one entry per dispatchable task |
152
- | 8. Batch Schedule | Step 7 (batch schedule) |
153
- | 9. Verification Checkpoints | CHECKLIST.md: behavior-to-test mapping (CL-###), hardening requirements, test execution commands |
154
- | 10. Error Recovery | Fixed template populate spec-specific test commands from CHECKLIST.md |
155
- | 11. Boundaries | Fixed template + spec-specific rules (including worktree cleanup after each batch) |
158
+ | 5. Task Units | Step 3 (task decomposition) + Step 4 (dependency analysis) |
159
+ | 6. Worker Prompt Index | Step 6 list of `plan/*.md` files with task ID mapping |
160
+ | 7. Batch Schedule | Step 7 (batch schedule) |
161
+ | 8. Verification Checkpoints | CHECKLIST.md: behavior-to-test mapping (CL-###), hardening requirements, test execution commands |
162
+ | 9. Error Recovery | Fixed template populate spec-specific test commands from CHECKLIST.md |
163
+ | 10. Boundaries | Fixed template + spec-specific rules (including worktree cleanup after each batch) |
164
+ | 11. References | Worker prompt file paths (`plan/*.md`), all code file paths that need modification across all tasks, project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) |
156
165
 
157
166
  ### 11. Pre-delivery Self-Review
158
167
 
@@ -160,31 +169,34 @@ Before delivering PROMPT.md, verify all of the following.
160
169
 
161
170
  **Worker prompt quality:**
162
171
 
163
- - Every worker prompt in Section 7 is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions. If found, rewrite the prompt to include the necessary information inline.
172
+ - Every worker prompt in `plan/*.md` is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions. If found, rewrite the prompt to include the necessary information inline.
164
173
  - Every worker prompt has a concrete file-level Scope (allowed + forbidden files listed explicitly).
165
174
  - Every worker prompt has a concrete Verify command with an expected output (not just "run tests").
175
+ - Worker prompt filenames match their task IDs (`plan/T{batch}.{sequence}-*.md`).
166
176
 
167
177
  **Coverage completeness:**
168
178
 
169
- - Every BDD requirement from SPEC.md is addressed by at least one task in Section 6. If a requirement has no task, add one or document why it is already satisfied by existing code.
179
+ - Every BDD requirement from SPEC.md is addressed by at least one task in Section 5. If a requirement has no task, add one or document why it is already satisfied by existing code.
170
180
  - Every module from DESIGN.md has a corresponding task or is explicitly noted as unchanged.
171
- - Every hardening requirement from CHECKLIST.md appears in Section 9.
181
+ - Every hardening requirement from CHECKLIST.md appears in Section 8.
172
182
 
173
183
  **Structural consistency:**
174
184
 
175
- - Each task's Depends on field in Section 6 matches the batch ordering in Section 8. No task scheduled in a batch before its dependencies are met.
176
- - Every task listed in Section 8 (Batch Schedule) has a worker prompt in Section 7 — unless it is explicitly marked as coordinator-handled.
177
- - No orphaned tasks (a task listed in Section 6 that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
185
+ - Each task's Depends on field in Section 5 matches the batch ordering in Section 7. No task scheduled in a batch before its dependencies are met.
186
+ - Every task listed in Section 7 (Batch Schedule) has a worker prompt in `plan/*.md` — unless it is explicitly marked as coordinator-handled.
187
+ - No orphaned tasks (a task listed in Section 5 that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
188
+ - PROMPT.md References section lists all worker prompt paths and all code file paths.
178
189
 
179
- ### 12. Produce PROMPT.md
190
+ ### 12. Produce PROMPT.md and Worker Prompts
180
191
 
181
192
  Place the PROMPT.md at the root of the spec or batch spec directory.
193
+ Place worker prompts in `<spec_dir>/plan/` or `<batch_dir>/plan/`.
182
194
 
183
195
  ## Examples
184
196
 
185
- - "Generate a coordinator prompt for a single spec" → Read SPEC.md + DESIGN.md → Decompose into 3 tasks → T1.1 and T1.2 have no file overlap → parallel → Write worker prompts for each → Schedule: Batch 1 parallel T1.1+T1.2 → Batch 2 T1.3 → Output PROMPT.md
186
- - "Generate a coordinator prompt for a batch spec with 4 specs" → Read all SPEC.md + DESIGN.md → Build spec DAG → Detect cross-spec file overlap → Schedule batches → Write worker prompts for each spec's task units → Output PROMPT.md
187
- - "Two tasks modify the same file" → Assign to different batches, each with an independent worker prompt, sequential execution
197
+ - "Generate a coordinator prompt for a single spec" → Read SPEC.md + DESIGN.md + references/ → Decompose into 3 tasks → T1.1 and T1.2 have no file overlap → parallel → Write worker prompts to `plan/` → Schedule: Batch 1 parallel T1.1+T1.2 → Batch 2 T1.3 → Output PROMPT.md + plan/*.md
198
+ - "Generate a coordinator prompt for a batch spec with 4 specs" → Read all SPEC.md + DESIGN.md + references/ → Build spec DAG → Detect cross-spec file overlap → Schedule batches → Write worker prompts to `plan/` → Output PROMPT.md + plan/*.md
199
+ - "Two tasks modify the same file" → Assign to different batches, each with an independent worker prompt in `plan/`, sequential execution → Reference both prompt paths in PROMPT.md
188
200
 
189
201
  ## References
190
202
 
@@ -15,7 +15,7 @@
15
15
  ### What you do
16
16
 
17
17
  - Read and understand the mission, scope, technical context, and task definitions below
18
- - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 7)
18
+ - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 6)
19
19
  - Wait for all workers in a batch to complete, then digest their results
20
20
  - Run verification commands at each checkpoint
21
21
  - Decide whether to proceed to the next batch, retry a failed worker, or halt
@@ -74,14 +74,7 @@
74
74
 
75
75
  ---
76
76
 
77
- ## 5. References
78
-
79
- - **Project context files**: [List important project files the coordinator and workers may need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
80
- - **Related documents**: [Links to related specs, design docs, or external documentation]
81
-
82
- ---
83
-
84
- ## 6. Task Units
77
+ ## 5. Task Units
85
78
 
86
79
  [Each task is an atomic work unit. Task ID format: `T{batch}.{sequence}`.]
87
80
 
@@ -91,15 +84,7 @@
91
84
 
92
85
  - **Goal**: [One sentence]
93
86
  - **Files**: `[file list]`
94
- - **Depends on**: [Task ID, or — (no dependency)]
95
- - **Verify**:
96
- - Command: `[command]`
97
- - Expected: [what you should see]
98
-
99
- #### T{batch}.{sequence}: [Task name]
100
-
101
- - **Goal**: [One sentence]
102
- - **Files**: `[file list]`
87
+ - **Worker prompt**: `plan/T{batch}.{sequence}-[name].md`
103
88
  - **Depends on**: [Task ID, or — (no dependency)]
104
89
  - **Verify**:
105
90
  - Command: `[command]`
@@ -107,53 +92,20 @@
107
92
 
108
93
  ---
109
94
 
110
- ## 7. Worker Prompt Library
111
-
112
- [Each dispatchable task has a pre-written self-contained worker prompt. The coordinator extracts the corresponding block and dispatches it without modification.]
95
+ ## 6. Worker Prompt Index
113
96
 
114
- ### T{batch}.{sequence}: [Task name]
97
+ [Each dispatchable task has a pre-written self-contained worker prompt in a separate file under `plan/`. The coordinator reads the corresponding file and dispatches it without modification.]
115
98
 
116
- ```
117
- ## Mission
118
- [Brief description of what to do and why. Enough context for the worker to understand the task's purpose.]
119
-
120
- ## Input
121
- - Read the following files: [list]
122
-
123
- ## What to do
124
- 1. [Specify the exact file path, the function or line range, and what specific change to make (add/delete/modify). Example: "In src/auth/login.ts, function validateToken() (line 42-58): add a null check for the token parameter before calling decode()."]
125
- 2. [Repeat for each file — never leave the change description vague]
126
-
127
- ## Scope
128
- - Allowed files:
129
- - `[path]` — [explanation]
130
- - Forbidden files:
131
- - `[path]` — (belongs to another worker)
132
-
133
- ## Output
134
- On completion, report:
135
- - Which files were modified (absolute paths)
136
- - Change summary for each file
137
- - Test results (pass/fail)
138
- - Any blockers or risks encountered
139
-
140
- ## Verify
141
- - Run: `[command]`
142
- - Expected: [what you should see]
143
-
144
- ## Boundaries
145
- - Do not modify any file in the forbidden list
146
- - Do not introduce new external dependencies
147
- - If you encounter an unexpected blocker, stop and report — do not invent alternative approaches
148
- ```
149
-
150
- ---
99
+ | Task ID | Worker Prompt File | Description |
100
+ |---|---|---|
101
+ | T1.1 | `plan/T1.1-implement-login.md` | [Brief description] |
102
+ | T1.2 | `plan/T1.2-implement-logout.md` | [Brief description] |
151
103
 
152
- [Repeat the above block for each dispatchable task. Tasks handled directly by the coordinator (purely procedural operations) do not need a worker prompt.]
104
+ [Tasks handled directly by the coordinator (purely procedural operations) do not have an entry here.]
153
105
 
154
106
  ---
155
107
 
156
- ## 8. Batch Schedule
108
+ ## 7. Batch Schedule
157
109
 
158
110
  [Batched according to the dependency graph. Tasks within the same batch have no file overlap and no logical dependency — they can run in parallel.]
159
111
 
@@ -190,7 +142,7 @@ On completion, report:
190
142
 
191
143
  ---
192
144
 
193
- ## 9. Verification Checkpoints
145
+ ## 8. Verification Checkpoints
194
146
 
195
147
  ### Per-batch
196
148
 
@@ -213,7 +165,7 @@ On completion, report:
213
165
 
214
166
  ---
215
167
 
216
- ## 10. Error Recovery
168
+ ## 9. Error Recovery
217
169
 
218
170
  | Scenario | Response |
219
171
  |---|---|
@@ -225,12 +177,12 @@ On completion, report:
225
177
 
226
178
  ---
227
179
 
228
- ## 11. Boundaries
180
+ ## 10. Boundaries
229
181
 
230
182
  ### ALWAYS
231
183
 
232
184
  - Run gate verification immediately after every batch
233
- - Extract worker prompts verbatim from Section 7 — do not rewrite them
185
+ - Extract worker prompts verbatim from `plan/*.md` files — do not rewrite them
234
186
  - After a worker reports, digest the results before deciding next steps
235
187
  - Follow the File Ownership implied by task assignments — do not let two workers modify the same file
236
188
  - **Resolve merge conflicts yourself** — when combining worker results, the coordinator handles conflict resolution. This is coordination, not implementation.
@@ -252,3 +204,14 @@ On completion, report:
252
204
  - Give workers vague instructions (e.g., "fix it" or "based on what you found")
253
205
  - Expand implementation scope beyond Section 3
254
206
  - Proceed to the next batch when the current batch's gate has not passed
207
+
208
+ ---
209
+
210
+ ## 11. References
211
+
212
+ - **Worker prompt files**: [List all `plan/*.md` files — e.g., `plan/T1.1-implement-login.md`, `plan/T1.2-implement-logout.md`]
213
+ - **Code files to modify** (across all tasks):
214
+ - [File path — e.g., `src/auth/login.ts`]
215
+ - [File path — e.g., `src/auth/logout.ts`]
216
+ - **Project context files**: [List important project files — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
217
+ - **Related documents**: [Links to related specs, design docs, or external documentation]
@@ -13,18 +13,25 @@ This prompt defines a fix coordinator agent:
13
13
 
14
14
  This skill is responsible for "planning the fix strategy" — extracting information from REPORT.md + SPEC/DESIGN/CHECKLIST, writing worker prompts for each fix and regression test, and scheduling batch execution order.
15
15
 
16
+ Worker prompts are written to individual files under `<spec_dir>/fix/` (single spec) or `<batch_dir>/fix/` (batch spec) instead of inline in FIX.md. This keeps FIX.md focused on coordination strategy while each fix/regression worker prompt is independently dispatchable.
17
+
16
18
  ## Acceptance Criteria
17
19
 
18
20
  - `docs/plans/<YYYY-MM-DD>/<spec_name>/FIX.md` is produced and placed in the spec directory (same level as REPORT.md)
19
21
  - FIX.md is a **self-contained fix coordinator prompt**, containing:
20
22
  - Coordinator role definition
21
23
  - Issue inventory with dependency analysis
22
- - Pre-written worker prompt for every fix issue
23
- - Regression test design and worker prompt for every fix
24
+ - Worker prompt index referencing `fix/*.md` files
25
+ - Pre-written worker prompts for every fix and regression test (stored in `fix/*.md`)
26
+ - Regression test design for every fix
24
27
  - Batch schedule (fix batches + regression test batches + final verification)
25
28
  - Error recovery strategy
26
29
  - Boundary rules
27
- - **Every issue in REPORT.md (including P2/P3) has a complete fix plan with a corresponding worker prompt in FIX.md.** No issue may be deferred to a future round or marked as "handle later."
30
+ - Worker prompts are stored in `<spec_dir>/fix/*.md` or `<batch_dir>/fix/*.md`, one prompt per file
31
+ - FIX.md References section cites:
32
+ - Worker prompt file paths (`fix/*.md`)
33
+ - All code file paths that need modification across all fixes and regression tests
34
+ - **Every issue in REPORT.md (including P2/P3) has a complete fix plan with a corresponding worker prompt.** No issue may be deferred to a future round or marked as "handle later."
28
35
 
29
36
  ## Workflow
30
37
 
@@ -36,6 +43,7 @@ Read all of the following:
36
43
 
37
44
  - **SPEC.md + DESIGN.md + CHECKLIST.md**: Full spec and design documentation
38
45
  - **REPORT.md**: Review findings (verdict + P0-P3 issue list + dimension summary)
46
+ - `<spec_dir>/references/` or `<batch_dir>/references/` — External method/API reference documents
39
47
 
40
48
  Understand the original design intent of the spec and the nature of each issue in REPORT.md.
41
49
 
@@ -59,7 +67,7 @@ For each issue in REPORT.md (in P0 → P1 → P2 → P3 order) → FIX.md Sectio
59
67
 
60
68
  ### 4. Design Regression Tests for Each Fix
61
69
 
62
- For every fix issue, design a concrete regression test → FIX.md Section 5 (Fix Details, regression test field) → FIX.md Section 6 (Worker Prompt Library, REGTEST entries).
70
+ For every fix issue, design a concrete regression test → FIX.md Section 5 (Fix Details, regression test field) → worker prompt in `fix/*REGtest*.md`.
63
71
 
64
72
  Design principles:
65
73
  - **Every P0/P1 issue needs at least one regression test.** For P2/P3 issues, if automated testing is impractical, define manual verification steps.
@@ -99,9 +107,11 @@ File overlap detection is the **gate that determines parallel vs sequential exec
99
107
 
100
108
  ### 7. Write Worker Prompts
101
109
 
102
- #### 7a. Fix Worker Prompts → FIX.md Section 6
110
+ #### 7a. Fix Worker Prompts
111
+
112
+ Write a self-contained worker prompt for each fix issue. Save each prompt to a separate file under `<spec_dir>/fix/` or `<batch_dir>/fix/`.
103
113
 
104
- Write a self-contained worker prompt for each fix issue.
114
+ **Worker prompt file naming**: `fix/FIX-{sequence}-{kebab-case-name}.md`
105
115
 
106
116
  Each fix worker prompt must include:
107
117
 
@@ -119,10 +129,12 @@ Each fix worker prompt must include:
119
129
  **Simple fixes can be merged**: Multiple simple, non-conflicting fixes can be combined into one worker prompt.
120
130
  **Complex fixes stand alone**: Complex fixes (requiring systematic debug) must have independent worker prompts.
121
131
 
122
- #### 7b. Regression Test Worker Prompts → FIX.md Section 6
132
+ #### 7b. Regression Test Worker Prompts
123
133
 
124
134
  Write a self-contained worker prompt for each regression test. The regression test worker is responsible for **writing test code**.
125
135
 
136
+ **Worker prompt file naming**: `fix/REGTEST-{sequence}-{kebab-case-name}.md`
137
+
126
138
  Each regression test worker prompt must include:
127
139
 
128
140
  ```
@@ -137,6 +149,11 @@ Each regression test worker prompt must include:
137
149
  ## Verify — Run the test, confirm it passes (proving the fix works)
138
150
  ```
139
151
 
152
+ **Writing principles (move these to your process, not the template):**
153
+ - Writing clear worker prompts means being concrete, not declarative. For every file the worker must modify, specify: (1) the exact file path, (2) the function or line range, (3) what to add, delete, or change.
154
+ - Workers do not see the coordinator's context. The prompt must include everything necessary.
155
+ - A regression test that passes before the fix is not a valid test. Always design the oracle so it fails on unfixed code.
156
+
140
157
  #### 7c. Cases That Do Not Need a Worker
141
158
 
142
159
  - Single-line typo fixes (multiple typos can be batched into one worker)
@@ -180,24 +197,46 @@ Use `assets/templates/FIX.md`. Fill according to the table below.
180
197
  | 3. Issue Inventory | REPORT.md issue list (condensed to NL one-liners) |
181
198
  | 4. Fix Dependency Analysis | Steps 5-6 (dependency analysis + file overlap) |
182
199
  | 5. Fix Details (with regression test design) | Step 3 (fix plan) + Step 4 (regression test design) |
183
- | 6. Worker Prompt Library | Step 7a (fix prompts) + Step 7b (regression test prompts) |
200
+ | 6. Worker Prompt Index | Step 7 list of `fix/*.md` files with FIX/REGTEST ID mapping |
184
201
  | 7. Fix Batch Schedule | Step 8 (batch schedule) |
185
202
  | 8. Regression Test Inventory | Step 4 full list. If regtests ≤ 3, omit (Section 5 is sufficient). If ≥ 4, include a condensed NL list. |
186
203
  | 9. Verification Checkpoints | Fixed scaffold, customized with spec-specific commands |
187
204
  | 10. Error Recovery | Fixed scaffold (natural language) |
188
205
  | 11. Fix History | Fixed scaffold (history entries only, no instructions) |
189
- | 12. References | Important project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) reduces LLM search overhead |
206
+ | 12. References | Worker prompt file paths (`fix/*.md`), all code file paths that need modification across all fixes/regtests, project context files |
190
207
  | 13. Boundaries | Fixed scaffold + spec-specific rules (including worktree cleanup after each batch) |
191
208
 
192
- ### 11. Produce FIX.md
209
+ ### 11. Pre-delivery Self-Review
210
+
211
+ Before delivering FIX.md, verify all of the following.
212
+
213
+ **Worker prompt quality:**
214
+
215
+ - Every worker prompt in `fix/*.md` is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions.
216
+ - Every fix worker prompt has concrete file-level Scope and a specific Verify command.
217
+ - Worker prompt filenames match their fix IDs (`fix/FIX-{sequence}-*.md`, `fix/REGTEST-{sequence}-*.md`).
218
+
219
+ **Coverage completeness:**
220
+
221
+ - Every issue in REPORT.md (P0–P3) has a corresponding worker prompt. No deferred issues.
222
+ - Every fix has a corresponding regression test (or documented manual verification steps for P2/P3 where automated testing is impractical).
223
+
224
+ **Structural consistency:**
225
+
226
+ - Each fix's dependency analysis matches the batch ordering. No fix scheduled before its dependencies are met.
227
+ - Regression tests are scheduled after all fix batches complete.
228
+ - FIX.md References section lists all worker prompt paths and all code file paths.
229
+
230
+ ### 12. Produce FIX.md and Worker Prompts
193
231
 
194
- Place FIX.md in the spec directory (same level as REPORT.md).
232
+ Place the FIX.md in the spec directory (same level as REPORT.md).
233
+ Place worker prompts in `<spec_dir>/fix/` or `<batch_dir>/fix/`.
195
234
 
196
235
  ## Examples
197
236
 
198
- - REPORT.md has 3 P0 issues (hallucinated code, deviation, omission) and 2 P1 issues → Each P0/P1 gets 1+ regression test → FIX.md has 3 fix workers + 5 regression test workers → Schedule: Batch 1 parallel fix 3 P0 → Batch 2 fix 2 P1 → Batch 3 parallel 5 regtests → Batch 4 final
199
- - Two P0 issues both modify `src/auth.ts` → File overlap → Separate into sequential batches → Regression tests run after all fix batches complete
200
- - A P0 logic error: `getDiscount()` does not handle negative input → Regression test: unit test with GIVEN negative input WHEN calling getDiscount THEN return 0 (before fix, returns incorrect negative discount)
237
+ - REPORT.md has 3 P0 issues (hallucinated code, deviation, omission) and 2 P1 issues → Each P0/P1 gets 1+ regression test → FIX.md + fix/ with 3 fix workers + 5 regression test workers → Schedule: Batch 1 parallel fix 3 P0 → Batch 2 fix 2 P1 → Batch 3 parallel 5 regtests → Batch 4 final
238
+ - Two P0 issues both modify `src/auth.ts` → File overlap → Separate into sequential batches → Regression tests run after all fix batches complete → Worker prompts in `fix/FIX-01-*.md` and `fix/FIX-02-*.md`
239
+ - A P0 logic error: `getDiscount()` does not handle negative input → Regression test: unit test with GIVEN negative input WHEN calling getDiscount THEN return 0 (before fix, returns incorrect negative discount) → Worker prompt in `fix/REGTEST-01-discount.md`
201
240
 
202
241
  ## References
203
242
 
@@ -100,112 +100,23 @@
100
100
 
101
101
  ---
102
102
 
103
- ## 6. Worker Prompt Library
103
+ ## 6. Worker Prompt Index
104
104
 
105
- ### Fix Worker Prompts
106
-
107
- [Each dispatchable fix task has a pre-written self-contained worker prompt.]
108
-
109
- #### FIX-01: [Issue title]
110
-
111
- ```
112
- ## Mission
113
- [Brief description: what to fix and why.]
114
-
115
- ## Context
116
- - Review dimension: [Hallucinated code / Omission / Deviation / Architecture / Performance / Redundancy]
117
- - Spec requirement: [Related SPEC requirement]
118
-
119
- ## Input
120
- - Read the following files: [list]
121
-
122
- ## What to do
123
- 1. [Specify the exact file path, the function or line range, and what specific change to make (add/delete/modify). Example: "In src/auth/login.ts, function validateToken() (line 42-58): add a null check for the token parameter before calling decode()."]
124
- 2. [Repeat for each file — never leave the change description vague]
105
+ [Each dispatchable fix and regression test has a pre-written self-contained worker prompt in a separate file under `fix/`. The coordinator reads the corresponding file and dispatches it without modification.]
125
106
 
126
- ## Scope
127
- - Allowed files:
128
- - `[path]` — [explanation]
129
- - Forbidden files:
130
- - `[path]` — (belongs to another worker)
131
-
132
- ## Output
133
- On completion, report:
134
- - Which files were modified (absolute paths)
135
- - Change summary for each file
136
- - Test results (pass/fail)
137
- - Any blockers or risks encountered
138
-
139
- ## Verify
140
- - Run: `[command]`
141
- - Expected: [what you should see]
142
-
143
- ## Boundaries
144
- - Do not modify any file in the forbidden list
145
- - Fix must not conflict with the original spec requirements
146
- - Preserve existing test behavior semantics (unless the spec explicitly requires a change)
147
- - Do not write regression tests — that is handled by another worker
148
- - If you encounter an unexpected blocker, stop and report — do not invent alternative approaches
149
- ```
150
-
151
- ---
107
+ ### Fix Worker Prompts
152
108
 
153
- [Repeat the above block for each fix worker. Multiple simple fixes with no overlap can be merged into one worker prompt by combining their What to do sections.]
109
+ | Fix ID | Worker Prompt File | Description |
110
+ |---|---|---|
111
+ | FIX-01 | `fix/FIX-01-[name].md` | [Brief description] |
112
+ | FIX-02 | `fix/FIX-02-[name].md` | [Brief description] |
154
113
 
155
114
  ### Regression Test Worker Prompts
156
115
 
157
- [Each regression test has a pre-written self-contained worker prompt. The regression test worker's task is to **write test code**.]
158
-
159
- #### REGTEST-01: [Test name] (related to FIX-01)
160
-
161
- ```
162
- ## Mission
163
- Create a regression test for FIX-01 ([brief description]). This test ensures the issue never reappears.
164
-
165
- ## Context
166
- - Fix summary: [What FIX-01 fixed]
167
- - Root cause: [Root cause explanation]
168
- - Fix files involved: [list]
169
-
170
- ## Input
171
- - Read fix-related files: [list]
172
- - Read existing test files as format reference: `[existing test path]`
173
-
174
- ## What to do
175
- Create a regression test at `[test location]`:
176
-
177
- Test scenario:
178
- - GIVEN [specific precondition and input]
179
- - WHEN [specific trigger]
180
- - THEN [expected output or behavior]
181
-
182
- Oracle: This test must fail on the unfixed code and pass after the fix is applied.
183
-
184
- ## Scope
185
- - Allowed files:
186
- - `[test file path]` — create/modify regression test
187
- - Forbidden files:
188
- - All non-test source files (fixes are handled by another worker)
189
-
190
- ## Output
191
- On completion, report:
192
- - The test file and test function name
193
- - Test execution result (must pass)
194
- - If the test cannot pass, explain why (may indicate an incomplete fix)
195
-
196
- ## Verify
197
- - Run: `[test command]`
198
- - Expected: REGTEST-01 passes
199
-
200
- ## Boundaries
201
- - Do not modify any source code files
202
- - The test must be independently executable, not dependent on external state
203
- - Follow the existing test file's formatting and naming conventions
204
- ```
205
-
206
- ---
207
-
208
- [Repeat the above block for each regression test worker. Multiple regressions in the same file can be merged into one worker prompt.]
116
+ | Test ID | Worker Prompt File | Related Fix | Description |
117
+ |---|---|---|---|
118
+ | REGTEST-01 | `fix/REGTEST-01-[name].md` | FIX-01 | [Brief description] |
119
+ | REGTEST-02 | `fix/REGTEST-02-[name].md` | FIX-02 | [Brief description] |
209
120
 
210
121
  ---
211
122
 
@@ -313,6 +224,10 @@ If there are no entries here, see Section 5 for each fix's regression test desig
313
224
 
314
225
  ## 12. References
315
226
 
227
+ - **Worker prompt files**: [List all `fix/*.md` files — e.g., `fix/FIX-01-*.md`, `fix/REGTEST-01-*.md`]
228
+ - **Code files to modify** (across all fixes and regression tests):
229
+ - [File path — e.g., `src/auth/login.ts`]
230
+ - [File path — e.g., `src/auth/logout.ts`]
316
231
  - **Project context files**: [List important project files the fix coordinator and workers may need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
317
232
  - **Related documents**: [Links to REPORT.md, SPEC.md, DESIGN.md, or external documentation]
318
233
 
@@ -323,7 +238,7 @@ If there are no entries here, see Section 5 for each fix's regression test desig
323
238
  ### ALWAYS
324
239
 
325
240
  - Run gate verification immediately after every batch
326
- - Extract worker prompts verbatim from Section 6 — do not rewrite them
241
+ - Extract worker prompts verbatim from `fix/*.md` files — do not rewrite them
327
242
  - After a worker reports, digest the results before deciding next steps
328
243
  - Fixes must not conflict with the original spec requirements
329
244
  - Regression tests must not start before all fix batches pass
@@ -17,33 +17,46 @@ Execution methodology (task breakdown, coordination routing) belongs to the `pla
17
17
 
18
18
  - SPEC.md follows the template format strictly
19
19
  - SPEC.md includes: clear business goal, scope (In/Out), BDD behaviors, error and edge cases, clarification questions
20
+ - SPEC.md References section cites key code file paths affected by the requirements
20
21
  - High-uncertainty requirements are marked with Uncertainty Level and reflected in Clarification Questions
21
- - For non-greenfield repos: subagent repo research is complete, and every requirement's boundary is calibrated against the actual code
22
- - Single spec generated at `docs/plans/<YYYY-MM-DD>/<spec_name>/SPEC.md` or batch spec generated at `docs/plans/<YYYY-MM-DD>/<batch-name>/<spec_name>/SPEC.md`.
22
+ - For non-greenfield repos: `apltk codegraph` survey completed, subagent repo research complete, and every requirement's boundary calibrated against the actual code
23
+ - Single spec generated at `docs/plans/<YYYY-MM-DD>/<spec_name>/SPEC.md` or batch spec generated at `docs/plans/<YYYY-MM-DD>/<batch-name>/<spec_name>/SPEC.md`
23
24
 
24
25
  ## Workflow
25
26
 
26
- ### 1. Understand Requirements and Research the Repo
27
+ ### 1. Survey the Repo with CodeGraph
27
28
 
28
- Analyze the user's requirements from the PROPOSAL.md.
29
+ Before reading requirements, use `apltk codegraph` to deeply understand the repo.
30
+
31
+ **Greenfield repo (no existing code)**: Skip this step. Proceed to Step 2.
32
+
33
+ **Non-greenfield repo**:
34
+
35
+ 1. Run `apltk codegraph survey --json` to get entry points, function clusters, and cross-boundary edges across the project
36
+ 2. Use `apltk codegraph list-apis` to review API directory — function names, file paths, callers — in modules potentially affected by the requirements
37
+ 3. Use `apltk codegraph explore` or `apltk codegraph search` to dig into specific areas of interest
29
38
 
30
- **Greenfield repo (no existing code)**: Skip repo research. Proceed to Step 2.
39
+ Consult `references/codegraph.md` for detailed flags.
40
+
41
+ **Purpose of this step**: Establish code-level understanding of module boundaries, existing APIs, and data structures BEFORE reading requirements. This ensures every BDD requirement is scoped correctly against real code.
42
+
43
+ ### 2. Read PROPOSAL.md and Understand Requirements
44
+
45
+ Analyze the user's requirements from the PROPOSAL.md.
31
46
 
32
- **Non-greenfield repo**: Research the repo to ensure SPEC.md aligns with actual code.
47
+ **Bridge from Step 1**: Compare codegraph findings against PROPOSAL.md. If the actual code contradicts or constrains what PROPOSAL.md describes, note these calibrations explicitly — they represent the core value the spec skill adds over simple template filling.
33
48
 
34
- Research method:
35
- - Dispatch multiple subagents in parallel to deeply investigate:
36
- - Affected modules and their responsibility boundaries
37
- - Existing data structures and persistence patterns
38
- - Existing API contracts and call relationships
39
- - Existing features that overlap or conflict with the requirements
40
- - Document findings for the next step
49
+ For complex repos, dispatch multiple subagents in parallel to deeply investigate:
50
+ - Affected modules and their responsibility boundaries
51
+ - Existing data structures and persistence patterns
52
+ - Existing API contracts and call relationships
53
+ - Existing features that overlap or conflict with the requirements
41
54
 
42
- **Bridge to Step 2**: Compare research findings against PROPOSAL.md. If the actual code contradicts or constrains what PROPOSAL.md describes, adjust the requirement boundaries accordingly. Note these calibrations explicitly — they represent the core value the spec skill adds over simple template filling.
55
+ Document findings for the next step.
43
56
 
44
- ### 2. Refine, Combine, Split Requirements into BDD
57
+ ### 3. Refine, Combine, Split Requirements into BDD
45
58
 
46
- Transform requirements into clearly-bounded BDD business requirements (GIVEN/WHEN/THEN). Use your research findings from Step 1 to correctly scope each requirement.
59
+ Transform requirements into clearly-bounded BDD business requirements (GIVEN/WHEN/THEN). Use your codegraph findings from Step 1 and research from Step 2 to correctly scope each requirement.
47
60
 
48
61
  Process:
49
62
  - **Refine**: Convert vague descriptions into precise BDD behavior statements
@@ -78,7 +91,7 @@ Define:
78
91
 
79
92
  If a requirement remains unclear after research and it affects scope definition, record it and wait for the user's answer before proceeding.
80
93
 
81
- ### 3. Generate SPEC.md
94
+ ### 4. Generate SPEC.md
82
95
 
83
96
  Generate SPEC.md using the template at `assets/templates/SPEC.md`.
84
97
 
@@ -91,12 +104,12 @@ Generate SPEC.md using the template at `assets/templates/SPEC.md`.
91
104
 
92
105
  2. Fill in each section of the generated template:
93
106
  - **Goal** → One sentence from the PROPOSAL.md's Problem Statement and your research context. State the business goal, not the implementation.
94
- - **Scope (In/Out)** → Directly from Step 2. Be precise: ambiguous boundaries cause scope creep.
95
- - **Functional Behaviors** → One BDD block per requirement from Step 2.
107
+ - **Scope (In/Out)** → Directly from Step 3. Be precise: ambiguous boundaries cause scope creep.
108
+ - **Functional Behaviors** → One BDD block per requirement from Step 3.
96
109
  - **Uncertainty Level** → Per requirement, mark Known or Exploratory.
97
- - **Error and Edge Cases** → List specific cases. Free-form list; no fixed categories needed in the template (the five categories from Step 2 guide your thinking, not the output format).
110
+ - **Error and Edge Cases** → List specific cases. Free-form list; no fixed categories needed in the template (the five categories from Step 3 guide your thinking, not the output format).
98
111
  - **Clarification Questions** → List questions for the user. Must be populated when any requirement is Exploratory. Omit only if all requirements are fully clear.
99
- - **References** → List important project context files the LLM will need (e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`), plus official docs and related code files for traceability.
112
+ - **References** → Cite key code file paths affected by the requirements, plus project context files and official docs. The code file paths serve as traceability anchors linking requirements to actual code.
100
113
 
101
114
  **BDD writing guidelines**:
102
115
  - **GIVEN** states the precondition and actor role
@@ -108,22 +121,24 @@ Generate SPEC.md using the template at `assets/templates/SPEC.md`.
108
121
 
109
122
  3. If creating a batch spec, repeat the template-filling process for each group of requirements, producing one SPEC.md per group.
110
123
 
111
- ### 4. Pre-delivery Self-Review
124
+ ### 5. Pre-delivery Verification
112
125
 
113
126
  Before delivering, verify all of the following. Fix any issues found before proceeding.
114
127
 
115
128
  - **BDD verifiability**: Every requirement has a clear verification condition — THEN is observable and specific, not vague or qualitative
116
129
  - **Scope clarity**: In Scope and Out of Scope are unambiguous and do not overlap
117
- - **Error case completeness**: All five categories from Step 2 are substantively covered (individual cases, not category names)
130
+ - **Error case completeness**: All five categories from Step 3 are substantively covered (individual cases, not category names)
118
131
  - **Uncertainty reflected**: High-uncertainty requirements are marked Exploratory AND mentioned in Clarification Questions
119
132
  - **Internal consistency**: No contradictions or overlaps between requirements
133
+ - **Code traceability**: References section cites specific code file paths that each requirement maps to
134
+ - **CodeGraph data used**: Boundary scoping decisions reference codegraph findings (what exists vs what needs to be built)
120
135
 
121
136
  Only deliver SPEC.md to the user after passing self-review.
122
137
 
123
138
  ## Examples
124
139
 
125
- - "Build a web-based Texas Hold'em game" → Research existing code → 4 BDD items (deal, bet, judge, chips). ≤5, single SPEC.md.
126
- - "Rewrite the user system: register, login, permissions, password reset, 2FA, session management" → Research existing auth code → 6 BDD items. >5, batch spec: Auth spec (register, login, password reset — 3 items) and Security spec (permissions, 2FA, sessions — 3 items).
140
+ - "Build a web-based Texas Hold'em game" → CodeGraph survey to check for existing game engine → 4 BDD items (deal, bet, judge, chips). ≤5, single SPEC.md. → References cite game engine code paths
141
+ - "Rewrite the user system: register, login, permissions, password reset, 2FA, session management" → CodeGraph survey of existing auth modules → 6 BDD items. >5, batch spec: Auth spec (register, login, password reset — 3 items) and Security spec (permissions, 2FA, sessions — 3 items). → References cite auth module code paths
127
142
 
128
143
  ## References
129
144
 
@@ -44,7 +44,9 @@
44
44
 
45
45
  ## References
46
46
 
47
+ - **Key code file paths** (affected by this spec):
48
+ - [File path — e.g., `src/auth/login.ts`]
47
49
  - Official docs:
48
50
  - [Link or document]
49
- - Related code files:
50
- - [File path]
51
+ - Related project context files:
52
+ - [File path — e.g., `CLAUDE.md`, `AGENTS.md`]