agile-context-engineering 0.1.0 → 0.2.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 (83) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +272 -78
  3. package/agents/ace-code-discovery-analyst.md +245 -0
  4. package/agents/ace-code-integration-analyst.md +248 -0
  5. package/agents/ace-code-reviewer.md +375 -0
  6. package/agents/ace-product-owner.md +361 -0
  7. package/agents/ace-project-researcher.md +606 -0
  8. package/agents/ace-research-synthesizer.md +228 -0
  9. package/agents/ace-technical-application-architect.md +287 -0
  10. package/agents/ace-wiki-mapper.md +334 -0
  11. package/agile-context-engineering/src/ace-tools.js +2881 -0
  12. package/agile-context-engineering/src/ace-tools.test.js +1089 -0
  13. package/agile-context-engineering/templates/_command.md +54 -0
  14. package/agile-context-engineering/templates/_workflow.xml +17 -0
  15. package/agile-context-engineering/templates/config.json +0 -0
  16. package/agile-context-engineering/templates/product/external-solution.xml +832 -0
  17. package/agile-context-engineering/templates/product/feature.xml +361 -0
  18. package/agile-context-engineering/templates/product/integration-solution.xml +0 -0
  19. package/agile-context-engineering/templates/product/product-backlog.xml +231 -0
  20. package/agile-context-engineering/templates/product/product-vision.xml +227 -0
  21. package/agile-context-engineering/templates/product/story-integration-solution.xml +1014 -0
  22. package/agile-context-engineering/templates/product/story-technical-solution.xml +1025 -0
  23. package/agile-context-engineering/templates/product/story-wiki.xml +190 -0
  24. package/agile-context-engineering/templates/product/story.xml +451 -0
  25. package/agile-context-engineering/templates/wiki/coding-standards.xml +493 -0
  26. package/agile-context-engineering/templates/wiki/decizions.xml +115 -0
  27. package/agile-context-engineering/templates/wiki/guide.xml +137 -0
  28. package/agile-context-engineering/templates/wiki/module-discovery.xml +174 -0
  29. package/agile-context-engineering/templates/wiki/pattern.xml +159 -0
  30. package/agile-context-engineering/templates/wiki/subsystem-architecture.xml +343 -0
  31. package/agile-context-engineering/templates/wiki/subsystem-structure.xml +235 -0
  32. package/agile-context-engineering/templates/wiki/system-architecture.xml +254 -0
  33. package/agile-context-engineering/templates/wiki/system-cross-cutting.xml +197 -0
  34. package/agile-context-engineering/templates/wiki/system-structure.xml +178 -0
  35. package/agile-context-engineering/templates/wiki/system.xml +381 -0
  36. package/agile-context-engineering/templates/wiki/tech-debt-index.xml +125 -0
  37. package/agile-context-engineering/templates/wiki/testing-framework.xml +283 -0
  38. package/agile-context-engineering/utils/questioning.xml +111 -0
  39. package/agile-context-engineering/utils/ui-formatting.md +300 -0
  40. package/agile-context-engineering/workflows/execute-story.xml +1145 -0
  41. package/agile-context-engineering/workflows/help.xml +540 -0
  42. package/agile-context-engineering/workflows/init-coding-standards.xml +386 -0
  43. package/agile-context-engineering/workflows/map-story.xml +797 -0
  44. package/agile-context-engineering/workflows/map-subsystem.xml +1177 -0
  45. package/agile-context-engineering/workflows/map-system.xml +647 -0
  46. package/agile-context-engineering/workflows/plan-backlog.xml +1356 -0
  47. package/agile-context-engineering/workflows/plan-feature.xml +1495 -0
  48. package/agile-context-engineering/workflows/plan-product-vision.xml +342 -0
  49. package/agile-context-engineering/workflows/plan-story.xml +909 -0
  50. package/agile-context-engineering/workflows/research-external-solution.xml +659 -0
  51. package/agile-context-engineering/workflows/research-integration-solution.xml +712 -0
  52. package/agile-context-engineering/workflows/research-story-wiki.xml +474 -0
  53. package/agile-context-engineering/workflows/research-technical-solution.xml +762 -0
  54. package/agile-context-engineering/workflows/review-story.xml +281 -0
  55. package/bin/install.js +102 -166
  56. package/commands/ace/execute-story.md +137 -0
  57. package/commands/ace/help.md +93 -0
  58. package/commands/ace/init-coding-standards.md +83 -0
  59. package/commands/ace/map-story.md +156 -0
  60. package/commands/ace/map-subsystem.md +138 -0
  61. package/commands/ace/map-system.md +90 -0
  62. package/commands/ace/plan-backlog.md +83 -0
  63. package/commands/ace/plan-feature.md +89 -0
  64. package/commands/ace/plan-product-vision.md +81 -0
  65. package/commands/ace/plan-story.md +145 -0
  66. package/commands/ace/research-external-solution.md +138 -0
  67. package/commands/ace/research-integration-solution.md +135 -0
  68. package/commands/ace/research-story-wiki.md +116 -0
  69. package/commands/ace/research-technical-solution.md +147 -0
  70. package/commands/ace/review-story.md +109 -0
  71. package/package.json +5 -8
  72. package/agents/executor.md +0 -88
  73. package/agents/planner.md +0 -78
  74. package/agents/researcher.md +0 -77
  75. package/agents/verifier.md +0 -116
  76. package/commands/ace-execute-story.md +0 -114
  77. package/commands/ace-init.md +0 -254
  78. package/commands/ace-plan-epic.md +0 -79
  79. package/commands/ace-plan-feature.md +0 -78
  80. package/commands/ace-plan-project.md +0 -205
  81. package/commands/ace-plan-story.md +0 -97
  82. package/commands/ace-refine-story.md +0 -90
  83. package/commands/ace-verify-story.md +0 -127
@@ -0,0 +1,1356 @@
1
+ <workflow>
2
+
3
+ <purpose>
4
+ Orchestrate product backlog creation or update through environment detection, GitHub issue
5
+ import, product-vision loading, optional wiki analysis (parallel sub-agents for brownfield
6
+ projects), optional domain research, deep questioning, document writing, and optional
7
+ GitHub sync. Produces `.ace/artifacts/product/product-backlog.md` — the ordered backlog
8
+ of Epics and Features that defines what the product will deliver.
9
+
10
+ The product vision's High-Level Capabilities are the primary input — each capability
11
+ maps to one or more Epics. For brownfield projects with wiki documentation, parallel
12
+ analysis agents extract existing feature inventories and status from the wiki, keeping
13
+ raw content out of the main context window. When GitHub Project integration is enabled,
14
+ existing issues are imported and new items can be synced back to GitHub.
15
+ </purpose>
16
+
17
+ <mandatory-context>
18
+ Read all files referenced by the invoking command's execution-context before starting.
19
+ Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
20
+ </mandatory-context>
21
+
22
+ <process>
23
+
24
+ <!-- ══════════════════════════════════════════════════════════════════ -->
25
+ <!-- STEP 1: SETUP -->
26
+ <!-- ══════════════════════════════════════════════════════════════════ -->
27
+
28
+ <step name="setup" order="1">
29
+ **MANDATORY FIRST STEP — Execute environment detection before any user interaction:**
30
+
31
+ ```bash
32
+ INIT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js init plan-backlog)
33
+ ```
34
+
35
+ Parse JSON for: `product_owner_model`, `researcher_model`, `commit_docs`,
36
+ `has_product_vision`, `has_product_backlog`,
37
+ `has_features_research`, `has_architecture_research`, `has_wiki_analysis`,
38
+ `is_brownfield`, `is_greenfield`,
39
+ `has_existing_code`, `has_package_file`, `has_wiki`, `has_wiki_system_wide`,
40
+ `has_wiki_subsystems`, `wiki_subsystem_names`, `has_system_architecture`,
41
+ `has_system_structure`, `has_testing_framework`, `has_git`, `has_gh_cli`,
42
+ `github_project` (object: `enabled`, `gh_installed`, `repo`, `project_number`, `owner`).
43
+
44
+ Also resolve the product owner model for spawning the writing agent:
45
+ ```bash
46
+ PO_MODEL=$(node ~/.claude/agile-context-engineering/src/ace-tools.js resolve-model ace-product-owner --raw)
47
+ ```
48
+
49
+ Display stage banner:
50
+
51
+ ```
52
+ ╔══════════════════════════════════════════════════╗
53
+ ║ ACE > Plan Backlog ║
54
+ ╚══════════════════════════════════════════════════╝
55
+ ```
56
+
57
+ **If `has_product_backlog` is true:**
58
+
59
+ Use AskUserQuestion:
60
+ - header: "Backlog exists"
61
+ - question: "A product backlog already exists at `.ace/artifacts/product/product-backlog.md`. What would you like to do?"
62
+ - options:
63
+ - "Update it" — Review and refine the existing backlog
64
+ - "Start fresh" — Discard and create a new backlog from scratch
65
+ - "Skip" — Keep the current backlog as-is
66
+
67
+ If "Update": Read existing file, hold as EXISTING_BACKLOG context, continue to step 2.
68
+ If "Start fresh": Set EXISTING_BACKLOG = null, continue to step 2.
69
+ If "Skip": Exit workflow.
70
+
71
+ **If `has_git` is false:** Initialize git:
72
+ ```bash
73
+ git init
74
+ ```
75
+ </step>
76
+
77
+ <!-- ══════════════════════════════════════════════════════════════════ -->
78
+ <!-- STEP 2: FETCH GITHUB ISSUES -->
79
+ <!-- ══════════════════════════════════════════════════════════════════ -->
80
+
81
+ <step name="fetch-github-issues" order="2">
82
+
83
+ **If `github_project.enabled` is false AND `has_gh_cli` is true:**
84
+
85
+ GitHub CLI is installed but GitHub Project integration isn't configured in ACE.
86
+ Check if this is a GitHub repo:
87
+ ```bash
88
+ gh repo view --json name,owner 2>/dev/null
89
+ ```
90
+
91
+ If the command succeeds (this IS a GitHub repo):
92
+
93
+ Use AskUserQuestion:
94
+ - header: "GitHub"
95
+ - question: "I detected a GitHub repo but GitHub Project integration isn't configured in ACE. If you have epics/features in a GitHub Project, I can import them. How would you like to proceed?"
96
+ - options:
97
+ - "Configure GitHub first" — Run /ace:help to set up GitHub Project integration, then re-run
98
+ - "Skip GitHub" — Continue without GitHub import
99
+
100
+ If "Configure GitHub first":
101
+ - Display:
102
+ ```
103
+ ┌──────────────────────────────────────────────────┐
104
+ │ Next > /ace:help │
105
+ │ Configure GitHub Project integration, │
106
+ │ then re-run /ace:plan-backlog │
107
+ └──────────────────────────────────────────────────┘
108
+ ```
109
+ - Exit workflow.
110
+
111
+ If "Skip GitHub":
112
+ - Set GITHUB_ISSUES = null.
113
+ - Continue to step 3.
114
+
115
+ If the command fails (not a GitHub repo), or if `has_gh_cli` is false:
116
+ - Set GITHUB_ISSUES = null.
117
+ - Continue to step 3.
118
+
119
+ **If `github_project.enabled` is true AND `github_project.gh_installed` is false:**
120
+
121
+ GitHub Project is configured but `gh` CLI is not installed. Warn the user:
122
+ - Display:
123
+ ```
124
+ ! GitHub Project integration is enabled but `gh` CLI is not installed.
125
+ Install it: https://cli.github.com/
126
+ Continuing without GitHub import.
127
+ ```
128
+ - Set GITHUB_ISSUES = null.
129
+ - Continue to step 3.
130
+
131
+ **If `github_project.enabled` is true AND `github_project.gh_installed` is true:**
132
+
133
+ Extract settings: REPO = `github_project.repo`, PROJECT_NUMBER = `github_project.project_number`, OWNER = `github_project.owner`.
134
+
135
+ Display:
136
+ ```
137
+ ┌──────────────────────────────────────────────────┐
138
+ │ ACE > Plan Backlog > GitHub Import │
139
+ └──────────────────────────────────────────────────┘
140
+
141
+ i Fetching epics and features from GitHub Project #{PROJECT_NUMBER}...
142
+ Repo: {REPO} | Owner: {OWNER}
143
+ ```
144
+
145
+ **Fetch all epics and features with full field data (single command):**
146
+
147
+ ```bash
148
+ GITHUB_ISSUES=$(node ~/.claude/agile-context-engineering/src/ace-tools.js github fetch-issues \
149
+ repo={REPO} owner={OWNER} project={PROJECT_NUMBER})
150
+ ```
151
+
152
+ This uses a single paginated GraphQL query to return all Epics and Features with:
153
+ - **number** — GitHub issue number
154
+ - **title** — issue title (preserved as-is)
155
+ - **status** — from the project's Status field (Todo, Refined, In Progress, Done)
156
+ - **priority** — from the project's Priority field (P0–P4)
157
+ - **estimate** — from the project's Estimate field (number)
158
+ - **sprint** — from the project's Sprint/Iteration field
159
+ - **milestone** — from the issue's milestone
160
+ - **url** — full GitHub issue URL
161
+ - **state** — issue state (OPEN/CLOSED)
162
+ - **parent_number** / **parent_title** — parent issue (features only)
163
+
164
+ Type detection uses this priority order (handled by ace-tools):
165
+ 1. If native `issueType` is set → use it (Epic / Feature)
166
+ 2. If title starts with `[Epic]` → type = Epic
167
+ 3. If title starts with `[Feature]` → type = Feature
168
+ 4. Otherwise → skipped (not an epic or feature)
169
+
170
+ The command returns structured JSON:
171
+ ```json
172
+ {
173
+ "epics": [{ number, title, status, priority, estimate, sprint, milestone, url, state }],
174
+ "features": [{ number, title, status, priority, estimate, sprint, milestone, parent_number, parent_title, url, state }],
175
+ "counts": { total, epics, features, skipped }
176
+ }
177
+ ```
178
+
179
+ Features without a parent Epic are "unparented" — present them separately
180
+ during questioning.
181
+
182
+ Hold the parsed JSON as GITHUB_ISSUES.
183
+
184
+ Display summary:
185
+ ```
186
+ + Found {N} epics and {M} features in GitHub Project #{PROJECT_NUMBER}.
187
+ [list epic titles with issue numbers]
188
+ ```
189
+
190
+ Continue to step 3.
191
+ </step>
192
+
193
+ <!-- ══════════════════════════════════════════════════════════════════ -->
194
+ <!-- STEP 3: PREREQUISITE — PRODUCT VISION -->
195
+ <!-- ══════════════════════════════════════════════════════════════════ -->
196
+
197
+ <step name="prerequisite-vision" order="3">
198
+
199
+ **If `has_product_vision` is false:**
200
+
201
+ Inform the user:
202
+ "The product vision is the foundation for backlog planning. It defines the
203
+ high-level capabilities that become epics. Without it, I'd be guessing at
204
+ the product's direction."
205
+
206
+ Use AskUserQuestion:
207
+ - header: "Product Vision"
208
+ - question: "No product vision found. The vision drives backlog structure — each capability becomes an epic. How would you like to proceed?"
209
+ - options:
210
+ - "Run /ace:plan-product-vision first" — Create the vision, then come back
211
+ - "Continue without vision" — I'll describe capabilities during questioning
212
+
213
+ If "Run /ace:plan-product-vision first":
214
+ - Display:
215
+ ```
216
+ ┌──────────────────────────────────────────────────┐
217
+ │ Next > /ace:plan-product-vision │
218
+ │ Then re-run /ace:plan-backlog │
219
+ └──────────────────────────────────────────────────┘
220
+ ```
221
+ - Exit workflow.
222
+
223
+ If "Continue without vision":
224
+ - Set VISION = null
225
+ - Continue to step 4.
226
+
227
+ **If `has_product_vision` is true:**
228
+
229
+ Read `.docs/product/product-vision.md`.
230
+
231
+ Extract and hold as VISION context:
232
+ - **Vision Statement** — the north star (1-2 sentences)
233
+ - **Target Audience** — who uses this product
234
+ - **High-Level Capabilities** — these map directly to epic candidates
235
+ - **Key Objectives** — measurable outcomes (epics should trace to these)
236
+ - **Constraints** — tech, timeline, budget (affects sizing and milestones)
237
+
238
+ The High-Level Capabilities list is the **primary seed for epic discovery**.
239
+ Each capability is a candidate epic. Some may split into multiple epics,
240
+ some may merge. The questioning step will refine this.
241
+
242
+ Continue to step 4.
243
+ </step>
244
+
245
+ <!-- ══════════════════════════════════════════════════════════════════ -->
246
+ <!-- STEP 4: BROWNFIELD WIKI ANALYSIS (Parallel Sub-Agents) -->
247
+ <!-- ══════════════════════════════════════════════════════════════════ -->
248
+
249
+ <step name="wiki-analysis" order="4">
250
+
251
+ **If `is_greenfield` OR `has_wiki` is false:**
252
+
253
+ Set WIKI_ANALYSIS = null.
254
+ Continue to step 5.
255
+
256
+ **If `is_brownfield` AND `has_wiki` is true:**
257
+
258
+ Check `has_wiki_analysis` from INIT (already resolved — do NOT use shell commands to check file existence):
259
+
260
+ If `has_wiki_analysis` is TRUE:
261
+ - Use AskUserQuestion:
262
+ - header: "Wiki Analysis"
263
+ - question: "A previous wiki analysis exists (`.ace/artifacts/wiki/wiki-analysis.md`). What would you like to do?"
264
+ - options:
265
+ - "Reuse it" — Skip wiki analysis, load the existing file
266
+ - "Re-run analysis" — Delete and re-analyze from wiki docs
267
+ - If "Reuse it": read `.ace/artifacts/wiki/wiki-analysis.md`, hold as WIKI_ANALYSIS, continue to step 5.
268
+ - If "Re-run analysis": delete the file and proceed below.
269
+
270
+ Display:
271
+ ```
272
+ ┌──────────────────────────────────────────────────┐
273
+ │ ACE > Plan Backlog > Wiki Analysis │
274
+ └──────────────────────────────────────────────────┘
275
+
276
+ i Analyzing wiki documentation to infer existing
277
+ epics, features, and their status...
278
+ ```
279
+
280
+ Spawn parallel analysis agents using `run_in_background=true`. Each agent reads wiki
281
+ content and APPENDS its summary directly to a shared file on disk.
282
+
283
+ **CRITICAL — Context Window Protection:**
284
+ The `ace-product-owner` agent has a built-in `<structured-returns>` protocol:
285
+ when spawned as a background agent, it writes to disk and returns ONLY a ~10-line
286
+ confirmation (file path + line count). This prevents agent output from inflating
287
+ the main context window.
288
+
289
+ **CRITICAL — Do NOT call TaskOutput:**
290
+ After spawning background agents, do NOT call TaskOutput to read their results.
291
+ You will be automatically notified when each agent completes — IGNORE those notifications.
292
+ The agents write to `.ace/artifacts/wiki/wiki-analysis.md` on disk. You do not need their return messages.
293
+ After all notifications arrive, verify the file with `wc -l .ace/artifacts/wiki/wiki-analysis.md`,
294
+ then proceed directly to the synthesizer.
295
+
296
+ Scale agents by subsystem count: 1 system-wide + 1 per subsystem, up to 10 total.
297
+ If subsystems exceed 9, batch 2-3 per agent.
298
+
299
+ All agents write to the same file: `.ace/artifacts/wiki/wiki-analysis.md`
300
+
301
+ First, create the file with a header:
302
+ ```bash
303
+ mkdir -p .ace/artifacts/wiki
304
+ echo "# Wiki Analysis for Backlog Planning" > .ace/artifacts/wiki/wiki-analysis.md
305
+ echo "" >> .ace/artifacts/wiki/wiki-analysis.md
306
+ ```
307
+
308
+ Display:
309
+ ```
310
+ i Spawning [N] wiki analysis agents in background
311
+ (1 system-wide + [M] subsystem-specific)...
312
+ Agents write directly to .ace/artifacts/wiki/wiki-analysis.md
313
+ ```
314
+
315
+ **Agent 1: System-Wide Analyst** (always, if `has_wiki_system_wide`):
316
+
317
+ Task tool parameters:
318
+ ```
319
+ subagent_type: "ace-product-owner"
320
+ model: "{PO_MODEL}"
321
+ run_in_background: true
322
+ description: "Analyze system-wide wiki"
323
+ ```
324
+
325
+ Prompt:
326
+ ```
327
+ You are analyzing wiki documentation to extract backlog-relevant information.
328
+
329
+ **Read these files (if they exist):**
330
+ - .docs/wiki/system-wide/system-architecture.md
331
+ - .docs/wiki/system-wide/system-structure.md
332
+
333
+ **APPEND the following structured summary to `.ace/artifacts/wiki/wiki-analysis.md`:**
334
+
335
+ ## System-Wide
336
+
337
+ - **System overview:** [1-2 sentences from system overview]
338
+ - **Subsystem count:** [N]
339
+ - **Subsystem responsibilities:**
340
+ - [Subsystem Name]: [Responsibility from matrix]
341
+ - [Subsystem Name]: [Responsibility from matrix]
342
+ - **Tech stack:** [comma-separated list of key technologies]
343
+ - **Communication patterns:** [sync/async/hybrid]
344
+ - **Capability areas inferred:** [list of broad capability areas derived from subsystem responsibilities]
345
+
346
+ IMPORTANT: Use Bash with `>> .ace/artifacts/wiki/wiki-analysis.md` to APPEND — do NOT overwrite.
347
+ If a file does not exist, note 'not found' for that section in the appended output.
348
+ ```
349
+
350
+ **1 agent per subsystem** (if `has_wiki_subsystems` AND `wiki_subsystem_names` is non-empty):
351
+
352
+ For each subsystem name (or batch of 2-3 if more than 9 subsystems):
353
+
354
+ Task tool parameters:
355
+ ```
356
+ subagent_type: "ace-product-owner"
357
+ model: "{PO_MODEL}"
358
+ run_in_background: true
359
+ description: "Analyze {subsystem_name} wiki"
360
+ ```
361
+
362
+ Prompt:
363
+ ```
364
+ You are analyzing subsystem wiki documentation to extract features and their status.
365
+
366
+ **Subsystem to analyze:** {subsystem_name}
367
+
368
+ **Read these files (if they exist):**
369
+ - .docs/wiki/subsystems/{subsystem_name}/architecture.md
370
+ - .docs/wiki/subsystems/{subsystem_name}/structure.md
371
+
372
+ **APPEND the following structured summary to `.ace/artifacts/wiki/wiki-analysis.md`:**
373
+
374
+ ## Subsystem: {subsystem_name}
375
+
376
+ - **Responsibility:** [from architecture.md system context or overview]
377
+ - **Components:** [list of L3 components from architecture.md]
378
+ - **Inferred features:**
379
+ - [Feature name]: [status] — [evidence]
380
+ (Status inference logic:
381
+ - 'Done' if architecture doc shows component with documented flows AND structure shows implementation files
382
+ - 'In Progress' if partially documented — structure exists but architecture incomplete, or vice versa
383
+ - 'Todo' if mentioned in responsibilities but no components or flows documented)
384
+ - **Data ownership:** [what data this subsystem owns]
385
+ - **Key dependencies:** [inbound/outbound from dependency inventory]
386
+
387
+ IMPORTANT: Use Bash with `>> .ace/artifacts/wiki/wiki-analysis.md` to APPEND — do NOT overwrite.
388
+ If a file does not exist, note 'not found' for that section in the appended output.
389
+ ```
390
+
391
+ **After all background notifications arrive:**
392
+
393
+ Do NOT call TaskOutput. Just verify the file:
394
+ ```bash
395
+ wc -l .ace/artifacts/wiki/wiki-analysis.md
396
+ ```
397
+
398
+ **Synthesize wiki analysis:**
399
+
400
+ The raw `.ace/artifacts/wiki/wiki-analysis.md` contains appended outputs from all agents —
401
+ useful data but unstructured. Spawn a synthesizer agent to read it and produce
402
+ a concise, opinionated summary focused on backlog implications.
403
+
404
+ Task tool parameters:
405
+ ```
406
+ subagent_type: "ace-product-owner"
407
+ model: "{PO_MODEL}"
408
+ description: "Synthesize wiki analysis"
409
+ ```
410
+
411
+ Prompt:
412
+ ```
413
+ You are synthesizing wiki analysis for backlog planning.
414
+
415
+ **Read:** `.ace/artifacts/wiki/wiki-analysis.md`
416
+
417
+ This file contains raw structured summaries from multiple wiki analysis agents
418
+ (1 system-wide + N subsystem-specific). Your job: synthesize into a single
419
+ concise backlog-relevant summary.
420
+
421
+ **Write a synthesized summary to `.ace/artifacts/wiki/wiki-analysis.md` (overwrite the raw version):**
422
+
423
+ # Wiki Analysis Summary
424
+
425
+ ## System Overview
426
+ [2-3 sentences: what is this system, what does it do]
427
+
428
+ ## Tech Stack
429
+ [comma-separated key technologies found]
430
+
431
+ ## Capability Areas
432
+ [List of broad capability areas derived from subsystem responsibilities — these become epic candidates]
433
+
434
+ ## Feature Inventory
435
+ | Subsystem | Feature | Status | Evidence |
436
+ |-----------|---------|--------|----------|
437
+ [One row per inferred feature across ALL subsystems. Status: Done/In Progress/Todo]
438
+
439
+ ## Cross-Cutting Concerns
440
+ [Patterns that span multiple subsystems — communication, shared data, etc.]
441
+
442
+ ## Gaps & Unknowns
443
+ [What couldn't be determined from wiki docs alone]
444
+
445
+ RULES:
446
+ - Synthesize, don't concatenate — integrate findings across subsystems
447
+ - Feature inventory table must be comprehensive (every feature from every subsystem)
448
+ - Be opinionated: 'This system has N capability areas suggesting N epics'
449
+ - Keep it concise — this will be held in the main context window
450
+ ```
451
+
452
+ After synthesis completes, read `.ace/artifacts/wiki/wiki-analysis.md` and hold as WIKI_ANALYSIS.
453
+
454
+ Continue to step 5.
455
+ </step>
456
+
457
+ <!-- ══════════════════════════════════════════════════════════════════ -->
458
+ <!-- STEP 5: OPTIONAL DOMAIN RESEARCH -->
459
+ <!-- ══════════════════════════════════════════════════════════════════ -->
460
+
461
+ <step name="domain-research-decision" order="5a">
462
+
463
+ Use `has_features_research` and `has_architecture_research` from INIT
464
+ (already resolved — do NOT use shell commands to check file existence).
465
+
466
+ <!-- ── 5a-1: Existing research found ─────────────────────────────── -->
467
+
468
+ **If `has_features_research` is TRUE:**
469
+
470
+ Read `.ace/research/FEATURES.md` and display a brief summary (table stakes count,
471
+ differentiator count, key categories). If `has_architecture_research` is also TRUE,
472
+ read `.ace/research/ARCHITECTURE.md` and summarize (capability areas, component count).
473
+
474
+ Use AskUserQuestion:
475
+ - header: "Research"
476
+ - question: "I found existing domain research. Would you like to reuse it or regenerate?"
477
+ - options:
478
+ - "Use existing research (Recommended)" — Reuse the current FEATURES.md and ARCHITECTURE.md
479
+ - "Regenerate research" — Discard and re-run domain research from scratch
480
+ - "Skip research" — Don't use any research for this backlog
481
+
482
+ If "Use existing research":
483
+ - Hold `.ace/research/FEATURES.md` content as RESEARCH.features
484
+ - If `has_architecture_research` is TRUE AND `has_system_architecture` is FALSE,
485
+ hold `.ace/research/ARCHITECTURE.md` content as RESEARCH.architecture
486
+ - Display the "Research Complete" banner (same as step 5b) with findings from existing files
487
+ - Continue to step 6.
488
+
489
+ If "Skip research":
490
+ - Set RESEARCH = null.
491
+ - Continue to step 6.
492
+
493
+ If "Regenerate research":
494
+ - Continue to step 5b (execute research).
495
+
496
+ <!-- ── 5a-2: No existing research ────────────────────────────────── -->
497
+
498
+ **If `has_features_research` is FALSE:**
499
+
500
+ If VISION is null AND WIKI_ANALYSIS is null AND no $ARGUMENTS provided:
501
+ - Research is strongly recommended (bare context). Skip the question and
502
+ auto-recommend: "I have very little context. Let me research the domain first."
503
+ - Continue to step 5b (execute research).
504
+
505
+ Otherwise:
506
+
507
+ Use AskUserQuestion:
508
+ - header: "Research"
509
+ - question: "Would you like me to research standard features and capability areas for this domain before planning the backlog?"
510
+ - options:
511
+ - "Research first (Recommended)" — Discover standard stacks, expected features, common epic structures
512
+ - "Skip research" — I know this domain well, go straight to questioning
513
+
514
+ If "Research first" (or auto-recommended):
515
+ - Continue to step 5b (execute research).
516
+
517
+ If "Skip research":
518
+ - Set RESEARCH = null.
519
+ - Continue to step 6.
520
+
521
+ </step>
522
+
523
+ <step name="domain-research-execute" order="5b">
524
+
525
+ Infer the domain from VISION (if available) or from the user's earlier description.
526
+
527
+ Determine which researchers to spawn based on existing wiki documentation:
528
+
529
+ - **Features Researcher** — ALWAYS spawned (domain feature landscape is distinct from wiki docs)
530
+ - **Architecture Patterns Researcher** — ONLY if `has_system_architecture` is FALSE.
531
+ If the wiki already has system-architecture.md (from /ace:map-system), that architecture
532
+ context was already captured in WIKI_ANALYSIS (step 4). Spawning a domain architecture
533
+ researcher would produce redundant or conflicting content.
534
+
535
+ Display (adapts to researcher count):
536
+ ```
537
+ ┌──────────────────────────────────────────────────┐
538
+ │ ACE > Plan Backlog > Domain Research │
539
+ └──────────────────────────────────────────────────┘
540
+
541
+ i Researching [domain] ecosystem...
542
+ Spawning [1 or 2] researcher(s):
543
+ → Features research
544
+ [→ Architecture patterns research] ← only if no wiki architecture exists
545
+ ```
546
+
547
+ If `has_system_architecture` is TRUE, also display:
548
+ ```
549
+ i Skipping architecture research — wiki architecture already captured in step 4.
550
+ ```
551
+
552
+ Resolve the researcher model:
553
+ ```bash
554
+ RESEARCHER_MODEL=$(node ~/.claude/agile-context-engineering/src/ace-tools.js resolve-model ace-project-researcher --raw)
555
+ ```
556
+
557
+ **Features Researcher (always spawned):**
558
+
559
+ Task tool parameters:
560
+ ```
561
+ subagent_type: "general-purpose"
562
+ model: "{RESEARCHER_MODEL}"
563
+ run_in_background: true
564
+ description: "Features research"
565
+ ```
566
+
567
+ Prompt:
568
+ ```
569
+ First, read ~/.claude/agents/ace-project-researcher.md for your role and instructions.
570
+
571
+ <research_type>
572
+ Project Research — Features dimension for [domain].
573
+ </research_type>
574
+
575
+ <question>
576
+ What features do [domain] products have? What's table stakes vs differentiating?
577
+ </question>
578
+
579
+ <project_context>
580
+ [VISION summary if available, or user's product description]
581
+ </project_context>
582
+
583
+ <downstream_consumer>
584
+ Your FEATURES.md feeds into backlog creation. Categorize clearly:
585
+ - Table stakes (must have or users leave)
586
+ - Differentiators (competitive advantage)
587
+ - Anti-features (things to deliberately NOT build)
588
+ - Feature dependencies (what depends on what)
589
+ </downstream_consumer>
590
+
591
+ <output>
592
+ Write to: .ace/research/FEATURES.md
593
+ </output>
594
+
595
+ **WRITE TO FILE DIRECTLY. RETURN ONLY CONFIRMATION.**
596
+ Your response must be ~5 lines max. Just confirm what was written and the line count.
597
+ Do NOT return file contents or research findings in your response.
598
+ ```
599
+
600
+ **Architecture Patterns Researcher (only if `has_system_architecture` is FALSE):**
601
+
602
+ Task tool parameters:
603
+ ```
604
+ subagent_type: "general-purpose"
605
+ model: "{RESEARCHER_MODEL}"
606
+ run_in_background: true
607
+ description: "Architecture patterns research"
608
+ ```
609
+
610
+ Prompt:
611
+ ```
612
+ First, read ~/.claude/agents/ace-project-researcher.md for your role and instructions.
613
+
614
+ <research_type>
615
+ Project Research — Architecture/Epic structure dimension for [domain].
616
+ </research_type>
617
+
618
+ <question>
619
+ How are [domain] systems typically structured? What are common capability
620
+ boundaries that translate to epics? What are the major components?
621
+ </question>
622
+
623
+ <project_context>
624
+ [VISION summary if available, or user's product description]
625
+ </project_context>
626
+
627
+ <downstream_consumer>
628
+ Your ARCHITECTURE.md informs epic structure in the backlog. Include:
629
+ - Component boundaries (what talks to what)
630
+ - Suggested epic/capability groupings
631
+ - Data flow (how information moves)
632
+ - Suggested build order (dependencies between components)
633
+ </downstream_consumer>
634
+
635
+ <output>
636
+ Write to: .ace/research/ARCHITECTURE.md
637
+ </output>
638
+
639
+ **WRITE TO FILE DIRECTLY. RETURN ONLY CONFIRMATION.**
640
+ Your response must be ~5 lines max. Just confirm what was written and the line count.
641
+ Do NOT return file contents or research findings in your response.
642
+ ```
643
+
644
+ **After all background notifications arrive:**
645
+
646
+ Do NOT call TaskOutput. Just verify the files exist:
647
+ ```bash
648
+ wc -l .ace/research/FEATURES.md .ace/research/ARCHITECTURE.md 2>/dev/null
649
+ ```
650
+
651
+ Read the research files and hold combined results as RESEARCH:
652
+ - features: key findings from .ace/research/FEATURES.md (table stakes, differentiators, anti-features)
653
+ - architecture: IF .ace/research/ARCHITECTURE.md was created, include its key findings
654
+ (capability boundaries, suggested epics). Otherwise, architecture context comes from
655
+ WIKI_ANALYSIS (step 3) — do NOT duplicate it into RESEARCH.
656
+
657
+ Display key findings:
658
+ ```
659
+ ┌──────────────────────────────────────────────────┐
660
+ │ ACE > Plan Backlog > Research Complete │
661
+ └──────────────────────────────────────────────────┘
662
+
663
+ + Research complete.
664
+
665
+ Table stakes: [comma-separated list]
666
+ Differentiators: [comma-separated list]
667
+ [Suggested capability areas: [comma-separated list]] ← only if architecture was researched
668
+
669
+ Files: .ace/research/
670
+ ```
671
+
672
+ Continue to step 6.
673
+ </step>
674
+
675
+ <!-- ══════════════════════════════════════════════════════════════════ -->
676
+ <!-- STEP 6: ABSORB INPUT -->
677
+ <!-- ══════════════════════════════════════════════════════════════════ -->
678
+
679
+ <step name="absorb-input" order="6">
680
+
681
+ **If $ARGUMENTS is provided (user passed text or file):**
682
+
683
+ Read/absorb the input content. Hold as INPUT_CONTEXT.
684
+
685
+ Do NOT summarize it back to the user. Do NOT restructure it yet.
686
+ Simply hold it for use in step 7 questioning.
687
+
688
+ Note what kind of input it is:
689
+ - Contains suggested epics/features? Hold as SUGGESTED_ITEMS.
690
+ - Contains product description? Hold as PRODUCT_DESCRIPTION.
691
+ - Contains PRD or specs? Hold as SPECS.
692
+ - Contains a mix? Categorize each section.
693
+
694
+ **If no $ARGUMENTS:**
695
+
696
+ Set INPUT_CONTEXT = null.
697
+
698
+ Continue to step 7.
699
+ </step>
700
+
701
+ <!-- ══════════════════════════════════════════════════════════════════ -->
702
+ <!-- STEP 7: DEEP QUESTIONING -->
703
+ <!-- ══════════════════════════════════════════════════════════════════ -->
704
+
705
+ <step name="deep-questioning" order="7">
706
+ Follow the questioning guide from `questioning.xml`. You are a thinking partner,
707
+ not an interviewer.
708
+
709
+ <!-- ── 7a: Determine run mode ─────────────────────────────────────── -->
710
+
711
+ **Determine RUN_MODE:**
712
+
713
+ - **UPDATE** — EXISTING_BACKLOG is set (user chose "Update it" in step 1)
714
+ - **CREATE** — EXISTING_BACKLOG is null (first run or "Start fresh")
715
+
716
+ <!-- ── 7b: UPDATE mode — start from existing backlog ──────────────── -->
717
+
718
+ **If RUN_MODE is UPDATE:**
719
+
720
+ Read EXISTING_BACKLOG and build a current inventory:
721
+ - Parse all epics (IDs, titles, feature counts, statuses, GitHub links)
722
+ - Parse all features (IDs, titles, parent epic, statuses, GitHub links)
723
+
724
+ If GITHUB_ISSUES is set, cross-reference:
725
+ - **Backlog-only items** — items in backlog without a GitHub link
726
+ - **GitHub-only items** — epics/features in GitHub NOT found in the backlog
727
+ (match by issue number in Link column; unmatched GitHub items are new)
728
+ - **Status drift** — items where backlog status differs from GitHub status
729
+ - **New GitHub items** — epics/features added directly in GitHub since last sync
730
+
731
+ Present the current state:
732
+ ```
733
+ Your backlog has [N] epics with [M] features.
734
+ [If GitHub: [X] items linked to GitHub, [Y] not yet linked.]
735
+ [If drift: [Z] items have status changes in GitHub.]
736
+ [If new GH items: [W] new items found in GitHub not in the backlog.]
737
+ ```
738
+
739
+ Use AskUserQuestion:
740
+ - header: "Update"
741
+ - question: "What would you like to change?"
742
+ - options:
743
+ - "Add new epics/features" — Expand the backlog with new items
744
+ - "Sync from GitHub" — Import new GitHub items and update statuses
745
+ - "Reorganize" — Reorder, merge, split, or remove items
746
+ - "Full review" — Walk through all epics and refine
747
+
748
+ If "Add new epics/features":
749
+ - Ask what to add. Follow natural conversation. Then proceed to decision gate.
750
+
751
+ If "Sync from GitHub":
752
+ - If there are GitHub-only items: present them and ask which to add to backlog.
753
+ - If there are status drifts: present them and ask which to accept.
754
+ - Merge accepted changes into the backlog plan. Then proceed to decision gate.
755
+
756
+ If "Reorganize":
757
+ - Present the epic index. Ask what to change. Iterate. Then proceed to decision gate.
758
+
759
+ If "Full review":
760
+ - Fall through to the epic-by-epic refinement below (same as CREATE mode).
761
+
762
+ <!-- ── 7c: CREATE mode — context-aware opening ────────────────────── -->
763
+
764
+ **If RUN_MODE is CREATE:**
765
+
766
+ Assess available context richness:
767
+
768
+ Compute CONTEXT_RICHNESS:
769
+ - RICH: VISION is set AND (WIKI_ANALYSIS is set OR RESEARCH is set OR GITHUB_ISSUES is set)
770
+ - MODERATE: VISION is set OR (WIKI_ANALYSIS is set AND INPUT_CONTEXT is set) OR (RESEARCH is set AND INPUT_CONTEXT is set) OR GITHUB_ISSUES is set
771
+ - LEAN: INPUT_CONTEXT only (no vision, no wiki, no research, no GitHub issues)
772
+ - BARE: Nothing available
773
+
774
+ **Opening — adapt based on context richness:**
775
+
776
+ If RICH (vision + wiki/research/github + possibly input):
777
+ - Synthesize what you know: "Based on your product vision and
778
+ [codebase analysis / domain research / GitHub issues], I see these capability areas..."
779
+ - Present a draft epic list derived from:
780
+ 1. Vision High-Level Capabilities (primary source)
781
+ 2. GitHub Issues — use EXACT GitHub titles and #[issue_number] as ID (if exists)
782
+ 3. Subsystem responsibilities from WIKI_ANALYSIS (if exists)
783
+ 4. Research findings — table stakes and suggested capability areas (if exists)
784
+ 5. INPUT_CONTEXT suggested items (if any)
785
+ - For GitHub issues: present with EXACT titles (do NOT rephrase), #N as ID, and their GitHub status/priority
786
+ - For brownfield with wiki: note inferred feature statuses (Done/In Progress/Todo)
787
+ - For research: highlight table stakes that aren't yet covered
788
+ - Probe: "Does this match your mental model? What's missing? What should be
789
+ reordered or merged?"
790
+
791
+ If MODERATE (some context, not the full picture):
792
+ - If vision exists: "Your product vision lists these capability areas:
793
+ [list from High-Level Capabilities]. Let's turn these into epics with
794
+ concrete features. Starting with the first — what are the specific
795
+ things it needs to deliver?"
796
+ - If no vision but wiki + input: "I've analyzed your codebase documentation
797
+ and your input. Here's what I see as the current state: [summary].
798
+ Let's structure this into a backlog."
799
+ - If research + input: "Domain research suggests these capability areas:
800
+ [list]. Combined with your input, let me propose an initial structure."
801
+
802
+ If LEAN (input doc only):
803
+ - Absorb the input. Probe structure: "I've read your document. It mentions
804
+ [key themes]. Let me make sure I understand the scope before we structure
805
+ the backlog."
806
+
807
+ If BARE (nothing):
808
+ - Open with: "What are the major things this product needs to do?"
809
+ - Wait for their response. This gives you context for intelligent follow-ups.
810
+
811
+ **Follow the thread:**
812
+
813
+ Based on what they said (and what you absorbed), ask follow-up questions that dig
814
+ into their response. Use AskUserQuestion with options that probe what they mentioned —
815
+ interpretations, clarifications, concrete examples.
816
+
817
+ Keep following threads. Each answer opens new threads to explore:
818
+ - What capability area is this feature part of?
819
+ - What does this feature actually deliver to the user?
820
+ - Is this already partially built? (use wiki analysis to confirm)
821
+ - What's the relative priority?
822
+ - What depends on what?
823
+ - What's MVP vs future?
824
+
825
+ **Map answers to backlog template structure (background, not out loud):**
826
+
827
+ **CRITICAL — GitHub identity preservation:**
828
+ Items from GITHUB_ISSUES use #[issue_number] as their ID and their EXACT GitHub title.
829
+ Do NOT assign E[N]/F[N] IDs to GitHub-linked items. Do NOT rephrase their titles.
830
+ Only new items (not in GitHub) get E[N]/F[N] IDs and new titles.
831
+
832
+ As you question, mentally track coverage against backlog needs:
833
+ - [ ] Capability areas (epics) identified — as many as the product naturally requires
834
+ - [ ] Each epic has features — as many as naturally emerge (Agile scoping, not arbitrary limits)
835
+ - [ ] Features are concrete deliverables (what it delivers, not how)
836
+ - [ ] Status understood for each (Todo / Refined / In Progress / Done)
837
+ - [ ] Size estimated using Fibonacci×10 (10, 20, 30, 50, 80, 130)
838
+ - [ ] Milestones assigned (mvp, v0.1.0, v0.2.0, etc.)
839
+ - [ ] Cross-epic dependencies identified
840
+ - [ ] Vision capability coverage validated (every capability maps to at least 1 epic)
841
+
842
+ Don't walk through this as a checklist. Weave questions naturally based on
843
+ the conversation. If gaps remain after the conversation feels complete, probe
844
+ those specific areas.
845
+
846
+ **Epic-by-epic refinement:**
847
+
848
+ Once the initial epic list is established, go through each epic:
849
+
850
+ Use AskUserQuestion for each epic:
851
+ - header: "[Epic Title]"
852
+ - question: "Here are the features I have for [Epic Title]. Confirm, add, or remove:"
853
+ - options:
854
+ - "Looks good" — Features are complete for this epic
855
+ - "Add more" — I have more features to add
856
+ - "Remove some" — Some of these don't belong
857
+ - "Split this epic" — This is too broad, let's break it apart
858
+
859
+ For each feature in the epic, confirm or discuss:
860
+ - Title and description
861
+ - Status (if brownfield with wiki, present inferred status for confirmation)
862
+ - Size (Fibonacci×10: 10, 20, 30, 50, 80, 130)
863
+ - Milestone
864
+
865
+ **Gap check:**
866
+
867
+ After all epics are refined:
868
+ - "Any capability areas we haven't covered?"
869
+ - If VISION exists, validate: "Every vision capability should map to at least one
870
+ epic. Let me check..." Present any unmapped capabilities.
871
+ - If RESEARCH exists, validate: "Research identified these table stakes:
872
+ [list]. Are they all covered?" Surface any missing table stakes.
873
+ - "Any cross-cutting concerns that need their own epic? (e.g., DevOps/CI,
874
+ Monitoring, Documentation, Security)"
875
+
876
+ **Decision gate:**
877
+
878
+ When the backlog feels complete:
879
+
880
+ Use AskUserQuestion:
881
+ - header: "Ready?"
882
+ - question: "I have [N] epics with [M] total features. Ready to create the product backlog?"
883
+ - options:
884
+ - "Create product backlog" — Let's write it
885
+ - "Keep exploring" — I want to add more or adjust
886
+ - "Show me what you have" — Present a summary before deciding
887
+
888
+ If "Show me what you have":
889
+ - Display epic index as a quick table:
890
+ ```
891
+ | ID | Epic | Features | Milestone |
892
+ |----|------|----------|-----------|
893
+ | E1 | [Title] | [count] features | [milestone] |
894
+ | E2 | [Title] | [count] features | [milestone] |
895
+ ...
896
+ ```
897
+ - Return to decision gate.
898
+
899
+ If "Keep exploring" — ask what they want to add, or identify gaps and probe naturally.
900
+
901
+ Loop until "Create product backlog" selected.
902
+ </step>
903
+
904
+ <!-- ══════════════════════════════════════════════════════════════════ -->
905
+ <!-- STEP 8: WRITE BACKLOG -->
906
+ <!-- ══════════════════════════════════════════════════════════════════ -->
907
+
908
+ <step name="write-backlog" order="8">
909
+
910
+ **Determine WRITE_MODE based on RUN_MODE and what changed:**
911
+
912
+ - **CREATE** — RUN_MODE is CREATE, or user chose "Start fresh" in step 1.
913
+ Writes a new backlog from scratch.
914
+ - **UPDATE** — RUN_MODE is UPDATE. Edits the existing backlog in place,
915
+ preserving IDs, GitHub links, and unchanged items.
916
+
917
+ <!-- ── 8a: CREATE mode — write new backlog ────────────────────────── -->
918
+
919
+ **If WRITE_MODE is CREATE:**
920
+
921
+ Create directory structure:
922
+ ```bash
923
+ mkdir -p .ace/artifacts/product
924
+ ```
925
+
926
+ Prepare a context brief (500 words max) that distills:
927
+ - Product direction summary (from vision if available, else from questioning)
928
+ - Complete epic list with: ID, Title, Description, Status, Priority, Size (Fibonacci×10), Sprint, Milestone, Link
929
+ - ID = #[issue_number] for GitHub-linked epics, E[N] for new epics
930
+ - Title = EXACT GitHub title for GitHub-linked items (verbatim)
931
+ - For each epic, complete feature list with: ID, Title, Description, Status, Priority, Size, Sprint, Milestone, Link
932
+ - ID = #[issue_number] for GitHub-linked features, F[N] for new features
933
+ - Title = EXACT GitHub title for GitHub-linked items (verbatim)
934
+ - Local Feature ID numbering: sequential across entire backlog (F1, F2, ... FN) — only for non-GitHub items
935
+ - Epic ordering rationale (strategic priority)
936
+ - Any cross-epic dependencies noted
937
+ - If RESEARCH exists: flag any table stakes that were included and their coverage
938
+ - If GITHUB_ISSUES exists: include GitHub issue numbers and URLs for items that already
939
+ have corresponding GitHub issues. Map GitHub Status/Priority/Sprint/Estimate to our columns.
940
+
941
+ Spawn the backlog-writing agent:
942
+
943
+ ```
944
+ Task(
945
+ prompt="You are an Agile Product Owner writing a product backlog document.
946
+
947
+ **Context brief from questioning session:**
948
+ {paste the context brief here}
949
+
950
+ **Instructions:**
951
+ 1. Read the product backlog template: ~/.claude/agile-context-engineering/templates/product/product-backlog.xml
952
+ 2. Write `.ace/artifacts/product/product-backlog.md` following the template structure exactly
953
+ 3. Include the header paragraph explaining product direction
954
+ 4. Write the Epic Index table (ordered by strategic priority)
955
+ 5. Write each Epic Detail section with its Feature table
956
+ 6. Follow all column definitions from the template:
957
+ - ID: #[issue_number] for GitHub-linked items, E[N] for local epics, F[N] for local features
958
+ - Title: EXACT GitHub title for GitHub-linked items (do NOT rephrase); 5-10 words for new items
959
+ - Description: 1-2 sentences
960
+ - Status: Todo | Refined | In Progress | Done
961
+ - Priority: Critical | High | Medium | Low
962
+ - Size: Fibonacci×10 values only (10, 20, 30, 50, 80, 130)
963
+ - Sprint: Sprint name/iteration or '—' if unassigned
964
+ - Milestone: mvp | v0.1.0 | v0.2.0 | etc.
965
+ - Link: [#N](url) if GitHub issue exists, otherwise '—'
966
+ 7. Apply ordering rules: epics by strategic priority, features by delivery sequence
967
+ 8. Apply Agile scoping principles:
968
+ - Epics are broad capability categories — as many as the product naturally requires
969
+ - Features are concrete deliverables within epics — as many as naturally emerge
970
+ - Local Feature IDs (F[N]) are globally sequential (F1, F2, F3... not restarting per epic)
971
+ - Epic status reflects aggregate of features
972
+ - 130-point items flagged for potential splitting
973
+ 9. GitHub integration (CRITICAL — identity preservation):
974
+ - GitHub-linked items: ID = #[issue_number], Title = EXACT GitHub title (verbatim, no rephrasing)
975
+ - Epic detail section headers: ### #45: Exact GitHub Title (not ### E1: ...)
976
+ - Link column: [#N](url) for GitHub items, '—' for local items
977
+ - Map GitHub Priority/Status/Sprint/Estimate to our columns
978
+ - Only items without a GitHub issue get E[N]/F[N] IDs
979
+
980
+ 10. Table formatting (CRITICAL for readability):
981
+ - Pad ALL cells with spaces so column separators | align vertically
982
+ - Separator row dashes must match column widths
983
+ - Follow the table-formatting guideline in the template for minimum column widths
984
+ - Every row in a table must have the same total width
985
+
986
+ Write the file using the Write tool.
987
+
988
+ **Return format — ONLY this, nothing else:**
989
+ DONE
990
+ - Epic count: [N]
991
+ - Feature count: [N]
992
+ - MVP scope: [number of features in mvp milestone]
993
+ - Epics: [comma-separated list of epic titles]
994
+ - GitHub-linked items: [N]",
995
+ subagent_type="ace-product-owner",
996
+ model="{PO_MODEL}",
997
+ description="Write product backlog document"
998
+ )
999
+ ```
1000
+
1001
+ <!-- ── 8b: UPDATE mode — edit existing backlog ────────────────────── -->
1002
+
1003
+ **If WRITE_MODE is UPDATE:**
1004
+
1005
+ Prepare a change brief that describes exactly what to change:
1006
+ - **Additions:** new epics/features to add (with all columns populated)
1007
+ - New Feature IDs continue from the highest existing F[N] in the backlog
1008
+ - New Epic IDs continue from the highest existing E[N]
1009
+ - **Removals:** items to delete (by ID)
1010
+ - **Modifications:** items to update (by ID, with field changes — e.g., status, size, milestone, priority)
1011
+ - **Status syncs from GitHub:** items where GitHub status should overwrite backlog status
1012
+ - **New GitHub imports:** items from GitHub to add to the backlog
1013
+ (include issue number and URL for the Link column)
1014
+ - **Reorders:** if epic ordering changed
1015
+
1016
+ Spawn the backlog-editing agent:
1017
+
1018
+ ```
1019
+ Task(
1020
+ prompt="You are an Agile Product Owner editing an existing product backlog.
1021
+
1022
+ **Read the current backlog:** `.ace/artifacts/product/product-backlog.md`
1023
+ **Read the template for reference:** `~/.claude/agile-context-engineering/templates/product/product-backlog.xml`
1024
+
1025
+ **Changes to apply:**
1026
+ {paste the change brief here}
1027
+
1028
+ **Rules:**
1029
+ - PRESERVE all existing IDs (#N for GitHub-linked, E[N]/F[N] for local), titles, and unchanged items exactly as-is
1030
+ - GitHub-linked items keep their #[issue_number] ID and EXACT GitHub title — never change these
1031
+ - New local Feature IDs continue sequentially from the highest existing F[N]
1032
+ - New local Epic IDs continue sequentially from the highest existing E[N]
1033
+ - Update the Epic Index table to reflect any additions, removals, or reorders
1034
+ - Update Epic status to reflect aggregate of its features
1035
+ - Size values must be Fibonacci×10 only: 10, 20, 30, 50, 80, 130
1036
+ - Maintain all template formatting — especially table column alignment:
1037
+ pad cells with spaces so | separators align vertically across all rows.
1038
+ Follow the table-formatting guideline in the template for minimum column widths.
1039
+ - If adding items with GitHub issue numbers, set Link = [#N](url)
1040
+ - Do NOT change items that aren't in the change brief
1041
+
1042
+ Use the Edit tool to modify in place. If changes are extensive (new epics added,
1043
+ major reorders), use the Write tool to rewrite the file completely.
1044
+
1045
+ **Return format — ONLY this, nothing else:**
1046
+ DONE
1047
+ - Added: [N] epics, [M] features
1048
+ - Modified: [X] items
1049
+ - Removed: [Y] items
1050
+ - Total: [N] epics, [M] features
1051
+ - GitHub-linked items: [Z]",
1052
+ subagent_type="ace-product-owner",
1053
+ model="{PO_MODEL}",
1054
+ description="Update product backlog document"
1055
+ )
1056
+ ```
1057
+ </step>
1058
+
1059
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1060
+ <!-- STEP 9: REVIEW AND APPROVE -->
1061
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1062
+
1063
+ <step name="review" order="9">
1064
+ Show the agent's returned summary to the user. Then:
1065
+
1066
+ Use AskUserQuestion:
1067
+ - header: "Backlog"
1068
+ - question: "Product backlog written to `.ace/artifacts/product/product-backlog.md`. Does this look right? Review the full file in your editor for details."
1069
+ - options:
1070
+ - "Approve" — Looks good, commit it
1071
+ - "Adjust" — I want to change some things
1072
+ - "Redo questioning" — Let's go back and explore more
1073
+
1074
+ **If "Adjust":**
1075
+ - Ask what they want to change (add/remove epics, reorder, change milestones, etc.)
1076
+ - Spawn a Task agent to edit:
1077
+ ```
1078
+ Task(
1079
+ prompt="Read `.ace/artifacts/product/product-backlog.md` and make these changes:
1080
+ {user's requested changes}.
1081
+
1082
+ **Rules:**
1083
+ - Maintain all template formatting — especially table column alignment:
1084
+ pad cells with spaces so | separators align vertically across all rows
1085
+ - Keep Feature IDs globally sequential — if adding new features, use the next available F[N]
1086
+ - Update Epic status to reflect aggregate feature status
1087
+ - Size values must be Fibonacci×10 only: 10, 20, 30, 50, 80, 130
1088
+ - Re-read the template for reference: ~/.claude/agile-context-engineering/templates/product/product-backlog.xml
1089
+
1090
+ Use the Edit tool to modify in place. Return only a confirmation of what changed.",
1091
+ subagent_type="general-purpose",
1092
+ model="{PO_MODEL}",
1093
+ description="Adjust product backlog"
1094
+ )
1095
+ ```
1096
+ - Present for review again. Loop until approved.
1097
+
1098
+ **If "Redo questioning":**
1099
+ - Return to step 7 (deep-questioning)
1100
+ - Preserve VISION, WIKI_ANALYSIS, RESEARCH, GITHUB_ISSUES, and INPUT_CONTEXT
1101
+ - Hold previous answers as additional context
1102
+
1103
+ **If "Approve":**
1104
+ Continue to step 10.
1105
+ </step>
1106
+
1107
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1108
+ <!-- STEP 10: GITHUB SYNC -->
1109
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1110
+
1111
+ <step name="github-sync" order="10">
1112
+
1113
+ **If `github_project.enabled` is false OR `github_project.gh_installed` is false:**
1114
+
1115
+ Skip to step 11.
1116
+
1117
+ **If `github_project.enabled` is true AND `github_project.gh_installed` is true:**
1118
+
1119
+ Read the approved `.ace/artifacts/product/product-backlog.md` and cross-reference
1120
+ with GITHUB_ISSUES (from step 2) to identify sync actions:
1121
+
1122
+ - **Unlinked items** — backlog items with Link = "—" → candidates for GitHub creation
1123
+ - **Linked but modified** — backlog items whose status/priority/estimate changed
1124
+ during this session vs their GitHub values → candidates for GitHub update
1125
+ - **Already synced** — backlog items with Link that match GitHub exactly → no action
1126
+
1127
+ If no sync actions needed (all items linked, nothing changed):
1128
+ - Display: "All backlog items are already synced with GitHub."
1129
+ - Continue to step 11.
1130
+
1131
+ If there are unlinked items:
1132
+
1133
+ Build a sync summary and present it:
1134
+ ```
1135
+ GitHub Sync Summary:
1136
+ - New (unlinked): [N] epics, [M] features
1137
+ [- Modified: [X] items with field changes to push]
1138
+ ```
1139
+
1140
+ Use AskUserQuestion:
1141
+ - header: "GitHub Sync"
1142
+ - question: "How would you like to sync with GitHub?"
1143
+ - options:
1144
+ - "Sync all (Recommended)" — Create new issues and update modified ones
1145
+ - "Create new only" — Create unlinked items, don't update existing
1146
+ - "Create epics only" — Only create Epic issues, skip features and updates
1147
+ - "Skip" — Don't sync to GitHub
1148
+
1149
+ **If "Skip":**
1150
+ Continue to step 11.
1151
+
1152
+ **If any sync option selected:**
1153
+
1154
+ Display:
1155
+ ```
1156
+ ┌──────────────────────────────────────────────────┐
1157
+ │ ACE > Plan Backlog > GitHub Sync │
1158
+ └──────────────────────────────────────────────────┘
1159
+
1160
+ i Creating GitHub issues...
1161
+ Repo: {REPO} | Project: #{PROJECT_NUMBER}
1162
+ ```
1163
+
1164
+ **Prerequisite — Resolve all field and type IDs (once, before creating any issues):**
1165
+
1166
+ ```bash
1167
+ GH_FIELDS=$(node ~/.claude/agile-context-engineering/src/ace-tools.js github resolve-fields repo={REPO} owner={OWNER} project={PROJECT_NUMBER})
1168
+ ```
1169
+
1170
+ Parse the JSON response. Extract and cache:
1171
+ - `issue_types.Epic` → EPIC_TYPE_ID
1172
+ - `issue_types.Feature` → FEATURE_TYPE_ID
1173
+ - `project_id` → PROJECT_ID
1174
+ - `fields.Status.id` → STATUS_FIELD_ID
1175
+ - `fields.Status.options` → STATUS_OPTIONS map (e.g., `{ "Todo": "id", "In Progress": "id", ... }`)
1176
+ - `fields.Priority.id` → PRIORITY_FIELD_ID (if exists)
1177
+ - `fields.Priority.options` → PRIORITY_OPTIONS map (e.g., `{ "P0": "id", "P1": "id", ... }`)
1178
+ - `fields.Estimate.id` → ESTIMATE_FIELD_ID (if exists)
1179
+
1180
+ If Epic or Feature type doesn't exist in `issue_types`, log a warning and skip type-setting.
1181
+
1182
+ **For each unlinked Epic (in order):**
1183
+
1184
+ ```bash
1185
+ EPIC_RESULT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js github create-issue \
1186
+ type=Epic \
1187
+ "title={Epic Title}" \
1188
+ "body={Epic Description}" \
1189
+ repo={REPO} \
1190
+ owner={OWNER} \
1191
+ project={PROJECT_NUMBER} \
1192
+ project_id={PROJECT_ID} \
1193
+ type_id={EPIC_TYPE_ID} \
1194
+ [priority_field_id={PRIORITY_FIELD_ID} priority_option_id={PRIORITY_OPTIONS[priority]}])
1195
+ ```
1196
+
1197
+ Epics do NOT get Status or Estimate — only Priority (optional).
1198
+ Parse the JSON response: `number`, `url`, `item_id`, and status flags.
1199
+ Store the epic's issue number for use as parent when creating features.
1200
+
1201
+ Display progress:
1202
+ ```
1203
+ + Created [Epic] {Title} → #{number}
1204
+ ```
1205
+
1206
+ **If "Create new only" or "Sync all" was selected, for each unlinked Feature (in order):**
1207
+
1208
+ ```bash
1209
+ FEATURE_RESULT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js github create-issue \
1210
+ type=Feature \
1211
+ "title={Feature Title}" \
1212
+ "body={Feature Description}" \
1213
+ repo={REPO} \
1214
+ owner={OWNER} \
1215
+ project={PROJECT_NUMBER} \
1216
+ project_id={PROJECT_ID} \
1217
+ type_id={FEATURE_TYPE_ID} \
1218
+ status_field_id={STATUS_FIELD_ID} \
1219
+ status_option_id={STATUS_OPTIONS[status]} \
1220
+ estimate_field_id={ESTIMATE_FIELD_ID} \
1221
+ estimate={size_value} \
1222
+ [priority_field_id={PRIORITY_FIELD_ID} priority_option_id={PRIORITY_OPTIONS[priority]}] \
1223
+ [parent={epic_issue_number}] \
1224
+ [milestone={Milestone}])
1225
+ ```
1226
+
1227
+ Status and Estimate are ALWAYS set for Features. Priority, parent, and milestone are optional.
1228
+ Parse the JSON response: `number`, `url`, status flags.
1229
+
1230
+ Display progress:
1231
+ ```
1232
+ + Created [Feature] {Title} → #{number} (parent: #{epic_number})
1233
+ ```
1234
+
1235
+ **If "Sync all" was selected, update modified existing issues:**
1236
+
1237
+ For each linked item whose fields changed during this session
1238
+ (status, priority, estimate differ from GITHUB_ISSUES values fetched in step 2):
1239
+
1240
+ Use `gh project item-edit` to update the changed fields:
1241
+ - Status change → `gh project item-edit --project-id {PROJECT_ID} --id {ITEM_ID} --field-id {STATUS_FIELD_ID} --single-select-option-id {STATUS_OPTIONS[new_status]}`
1242
+ - Priority change → `gh project item-edit --project-id {PROJECT_ID} --id {ITEM_ID} --field-id {PRIORITY_FIELD_ID} --single-select-option-id {PRIORITY_OPTIONS[new_priority]}`
1243
+ - Estimate change → `gh project item-edit --project-id {PROJECT_ID} --id {ITEM_ID} --field-id {ESTIMATE_FIELD_ID} --number {new_estimate}`
1244
+
1245
+ Note: To get the ITEM_ID for existing linked issues, use:
1246
+ ```bash
1247
+ ITEM_ID=$(gh project item-list {PROJECT_NUMBER} --owner {OWNER} --format json --limit 500 | jq -r '.items[] | select(.content.number == {issue_number}) | .id')
1248
+ ```
1249
+
1250
+ Display progress for each update:
1251
+ ```
1252
+ ~ Updated [Feature] {Title} #{number} — status: {old} → {new}
1253
+ ```
1254
+
1255
+ **After all creates and updates, update the backlog file:**
1256
+
1257
+ Read `.ace/artifacts/product/product-backlog.md` and update every newly created
1258
+ item's Link column from "—" to `[#N](https://github.com/{REPO}/issues/N)`.
1259
+
1260
+ Use the Edit tool to make targeted replacements in the markdown tables.
1261
+
1262
+ Display summary:
1263
+ ```
1264
+ + Created {N} GitHub issues.
1265
+ [~ Updated {X} existing issues.]
1266
+ Backlog Link column updated.
1267
+ ```
1268
+
1269
+ Continue to step 11.
1270
+ </step>
1271
+
1272
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1273
+ <!-- STEP 11: COMMIT -->
1274
+ <!-- ══════════════════════════════════════════════════════════════════ -->
1275
+
1276
+ <step name="commit" order="11">
1277
+ Stage and commit all changed files in a single commit.
1278
+ Only stage files that actually changed (use `git diff` / `git status` to check).
1279
+
1280
+ Files that may have changed:
1281
+ - `.ace/artifacts/product/product-backlog.md` — always (this is the main output)
1282
+ - `.ace/research/FEATURES.md` — if research was regenerated in step 5b
1283
+ - `.ace/research/ARCHITECTURE.md` — if research was regenerated in step 5b
1284
+ - `.ace/artifacts/wiki/wiki-analysis.md` — if wiki analysis was re-run in step 4
1285
+
1286
+ ```bash
1287
+ git add .ace/artifacts/product/product-backlog.md
1288
+ ```
1289
+
1290
+ If research files were created or regenerated this session:
1291
+ ```bash
1292
+ git add .ace/research/
1293
+ ```
1294
+
1295
+ If wiki analysis was re-run this session:
1296
+ ```bash
1297
+ git add .ace/artifacts/wiki/wiki-analysis.md
1298
+ ```
1299
+
1300
+ Commit with a message that reflects what happened:
1301
+ - CREATE mode: `git commit -m "docs: initialize product backlog"`
1302
+ - UPDATE mode: `git commit -m "docs: update product backlog — [brief summary of changes]"`
1303
+ Examples:
1304
+ - "docs: update product backlog — add 2 epics, 5 features"
1305
+ - "docs: update product backlog — sync status from GitHub"
1306
+ - "docs: update product backlog — reorganize epic order"
1307
+
1308
+ Display completion (adapt banner to mode):
1309
+
1310
+ ```
1311
+ ╔══════════════════════════════════════════════════╗
1312
+ ║ ACE > Product Backlog [Created | Updated] ║
1313
+ ╚══════════════════════════════════════════════════╝
1314
+
1315
+ + .ace/artifacts/product/product-backlog.md committed.
1316
+ [If UPDATE: Changes: +N epics, +M features, ~X modified]
1317
+
1318
+ Summary:
1319
+ ────────
1320
+ [N] epics, [M] features
1321
+ MVP scope: [X] features across [Y] epics
1322
+
1323
+ i This backlog will be used as context by ACE commands
1324
+ when planning features, stories, and sprints.
1325
+
1326
+ Next > /ace:plan-feature E1
1327
+ Break the first epic into detailed stories.
1328
+ > /ace:help
1329
+ Check project status and available commands.
1330
+ ```
1331
+ </step>
1332
+
1333
+ </process>
1334
+
1335
+ <success_criteria>
1336
+ - Init function executed (environment detected, wiki state checked, GitHub settings loaded)
1337
+ - GitHub issues fetched via `github fetch-issues` if GitHub Project integration is enabled
1338
+ - Product vision loaded as primary input (if exists)
1339
+ - Brownfield with wiki: analysis reused from cache or re-run with parallel agents
1340
+ - Domain research reused from cache or regenerated if selected
1341
+ - User-provided input absorbed and integrated
1342
+ - Deep questioning adapted to run mode (CREATE = from scratch, UPDATE = targeted changes)
1343
+ - Every vision capability mapped to at least one epic (if vision exists)
1344
+ - Research table stakes validated against backlog (if research exists)
1345
+ - Epics and features scoped using Agile methodology (no arbitrary count limits)
1346
+ - Size estimated using Fibonacci×10 (10, 20, 30, 50, 80, 130)
1347
+ - Priority, status, size, sprint, milestone, and link assigned to every item
1348
+ - product-backlog.md written (CREATE) or edited in place (UPDATE) following template structure
1349
+ - Existing IDs, GitHub links, and unchanged items preserved during updates
1350
+ - User reviewed and approved the document
1351
+ - GitHub sync: new issues created, modified issues updated (if user chose to sync)
1352
+ - Link column updated with GitHub issue numbers and URLs
1353
+ - Document committed with mode-appropriate message (initialize vs update + summary)
1354
+ </success_criteria>
1355
+
1356
+ </workflow>