agile-context-engineering 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/LICENSE +51 -51
  3. package/README.md +324 -323
  4. package/agents/ace-research-synthesizer.md +228 -228
  5. package/agents/ace-technical-application-architect.md +28 -0
  6. package/agents/ace-wiki-mapper.md +445 -334
  7. package/agile-context-engineering/src/ace-tools.test.js +1089 -1089
  8. package/agile-context-engineering/templates/_command.md +53 -53
  9. package/agile-context-engineering/templates/_workflow.xml +16 -16
  10. package/agile-context-engineering/templates/product/product-backlog.xml +231 -231
  11. package/agile-context-engineering/templates/product/story-integration-solution.xml +1 -0
  12. package/agile-context-engineering/templates/product/story-wiki.xml +4 -0
  13. package/agile-context-engineering/templates/wiki/coding-standards.xml +38 -0
  14. package/agile-context-engineering/templates/wiki/decizions.xml +115 -115
  15. package/agile-context-engineering/templates/wiki/guide.xml +137 -137
  16. package/agile-context-engineering/templates/wiki/module-discovery.xml +174 -174
  17. package/agile-context-engineering/templates/wiki/pattern.xml +159 -159
  18. package/agile-context-engineering/templates/wiki/system-architecture.xml +254 -254
  19. package/agile-context-engineering/templates/wiki/system-cross-cutting.xml +197 -197
  20. package/agile-context-engineering/templates/wiki/system.xml +381 -381
  21. package/agile-context-engineering/templates/wiki/walkthrough.xml +255 -0
  22. package/agile-context-engineering/templates/wiki/wiki-readme.xml +297 -276
  23. package/agile-context-engineering/utils/questioning.xml +110 -110
  24. package/agile-context-engineering/workflows/execute-story.xml +1219 -1145
  25. package/agile-context-engineering/workflows/help.xml +540 -540
  26. package/agile-context-engineering/workflows/init-coding-standards.xml +386 -386
  27. package/agile-context-engineering/workflows/map-story.xml +1046 -797
  28. package/agile-context-engineering/workflows/map-subsystem.xml +2 -1
  29. package/agile-context-engineering/workflows/map-walkthrough.xml +457 -0
  30. package/agile-context-engineering/workflows/plan-feature.xml +1495 -1495
  31. package/agile-context-engineering/workflows/plan-story.xml +36 -1
  32. package/agile-context-engineering/workflows/research-integration-solution.xml +1 -0
  33. package/agile-context-engineering/workflows/research-story-wiki.xml +2 -1
  34. package/agile-context-engineering/workflows/research-technical-solution.xml +1 -0
  35. package/agile-context-engineering/workflows/review-story.xml +281 -281
  36. package/agile-context-engineering/workflows/update.xml +238 -207
  37. package/bin/install.js +8 -0
  38. package/commands/ace/execute-story.md +1 -0
  39. package/commands/ace/help.md +93 -93
  40. package/commands/ace/init-coding-standards.md +83 -83
  41. package/commands/ace/map-story.md +165 -156
  42. package/commands/ace/map-subsystem.md +140 -138
  43. package/commands/ace/map-system.md +92 -92
  44. package/commands/ace/map-walkthrough.md +127 -0
  45. package/commands/ace/plan-feature.md +89 -89
  46. package/commands/ace/plan-story.md +15 -1
  47. package/commands/ace/review-story.md +109 -109
  48. package/commands/ace/update.md +56 -54
  49. package/hooks/ace-check-update.js +62 -62
  50. package/hooks/ace-statusline.js +89 -89
  51. package/package.json +4 -3
@@ -1,1145 +1,1219 @@
1
- <workflow>
2
-
3
- <purpose>
4
- Orchestrate story execution: load a fully-planned story (with AC + Technical Solution),
5
- create an execution plan via Claude Code Plan Mode, execute the plan (solo or agent teams),
6
- run code review, present results for user verification, update state across all ACE
7
- artifacts, and trigger wiki mapping.
8
-
9
- The story file IS the plan — AC + Technical Solution = the specification.
10
- Claude Code Plan Mode creates a tactical execution plan on top of that.
11
-
12
- Two execution modes:
13
- - **Solo Mode** (default): Main plans → executor subagent implements (fresh 200k context)
14
- - **Agent Teams Mode** (when enabled + assessment recommends it): Lead + teammates for parallel work
15
-
16
- NO intermediary commits during implementation. Only ONE commit after user approval.
17
- </purpose>
18
-
19
- <mandatory-context>
20
- Read all files referenced by the invoking command's execution-context before starting.
21
- Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
22
- </mandatory-context>
23
-
24
- <process>
25
-
26
- **STRICT STEP-BY-STEP EXECUTION. This workflow is NOT a reference document — it is a
27
- script you MUST follow in order. Complete each step and ALL its substeps before moving
28
- to the next step. Do NOT read ahead and freestyle. Do NOT explore the codebase or read
29
- the story file before running the init command. Do NOT create your own plan or ask
30
- "Shall I proceed?" — follow the workflow steps exactly as written.**
31
-
32
- <!-- ══════════════════════════════════════════════════════════════════ -->
33
- <!-- STEP 1: INIT & VALIDATE -->
34
- <!-- ══════════════════════════════════════════════════════════════════ -->
35
-
36
- <step name="init-and-validate" order="1">
37
-
38
- **MANDATORY FIRST STEP — Run the init command (substep 1.2) BEFORE any other action.
39
- Do NOT read the story file. Do NOT explore code. Do NOT start planning.
40
- Run init FIRST, parse the output, THEN proceed through substeps 1.3-1.7 in order.**
41
-
42
- <substep order="1.1" name="parse-arguments">
43
- Parse `$ARGUMENTS` to extract:
44
- - `story` (REQUIRED): file path or GitHub URL/issue number
45
- - `--agent-teams-off` (OPTIONAL FLAG): force solo mode
46
- </substep>
47
-
48
- <substep order="1.2" name="run-init">
49
- Execute environment detection:
50
-
51
- ```bash
52
- INIT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js init execute-story {story_param})
53
- ```
54
-
55
- Parse INIT JSON for:
56
- - `executor_model`, `reviewer_model`
57
- - `commit_docs`, `has_git`, `has_gh_cli`, `github_project`
58
- - `agent_teams`
59
- - `story_source`, `story_valid`, `story_error`, `story_content`
60
- - `story` (id, title, status, size), `feature` (id, title), `epic` (id, title)
61
- - `has_acceptance_criteria`, `acceptance_criteria_count`
62
- - `has_technical_solution`, `has_wiki_refs`, `has_coding_standards`
63
- - `paths.*`
64
- </substep>
65
-
66
- <substep order="1.3" name="display-banner">
67
- ```
68
- ╔══════════════════════════════════════════════════╗
69
- ║ ACE > Execute Story ║
70
- ╚══════════════════════════════════════════════════╝
71
- ```
72
-
73
- If `has_git` is false: `git init`
74
- </substep>
75
-
76
- <substep order="1.4" name="validate-story">
77
- <validation-gate condition="INIT.story_valid is false">
78
- Display `INIT.story_error` and STOP:
79
- ```
80
- x {INIT.story_error}
81
- Provide a valid story file path or GitHub issue.
82
- ```
83
- </validation-gate>
84
-
85
- <validation-gate condition="INIT.has_acceptance_criteria is false">
86
- STOP:
87
- ```
88
- x Story has no acceptance criteria.
89
- Run /ace:plan-story first to define AC scenarios.
90
- ```
91
- </validation-gate>
92
-
93
- <validation-gate condition="INIT.has_technical_solution is false">
94
- STOP:
95
- ```
96
- x Story has no technical solution.
97
- Run /ace:plan-story first to generate the technical solution.
98
- ```
99
- </validation-gate>
100
-
101
- <validation-gate condition="INIT.story.status is 'Done'">
102
- STOP:
103
- ```
104
- x Story is already marked as Done. Nothing to execute.
105
- ```
106
- </validation-gate>
107
-
108
- <validation-gate condition="INIT.story.status is 'DevReady'">
109
- Story was previously implemented and approved as DevReady (pending manual testing).
110
- Resuming from verification to allow promoting to Done.
111
-
112
- ```
113
- i Story status: DevReady — previously implemented, pending verification.
114
- Resuming from verification (step 5.2).
115
- Skipping planning, execution, and code review.
116
- ```
117
-
118
- Set `RESUME_FROM_DEVREADY = true`.
119
- After displaying context (substep 1.7), jump DIRECTLY to step 5.2.
120
- Skip substeps 1.5, 1.6 and steps 2, 3, 4, 5.1 entirely.
121
- </validation-gate>
122
- </substep>
123
-
124
- <substep order="1.5" name="detect-existing-implementation">
125
- First check if there are any uncommitted changes (staged or unstaged):
126
- ```bash
127
- git status --short
128
- ```
129
-
130
- <variant condition="git status output is EMPTY (no uncommitted changes)">
131
- Fresh start — no uncommitted changes detected. Proceed normally to step 2.
132
- </variant>
133
-
134
- <variant condition="git status output is NOT EMPTY (uncommitted changes exist)">
135
- Uncommitted changes detected. Check if they relate to this story's implementation.
136
-
137
- Extract the list of expected files from the Technical Solution section
138
- of the story file (component breakdown — file paths).
139
-
140
- Check which of these files already exist in the working tree:
141
- ```bash
142
- for file in [expected_files_from_technical_solution]; do
143
- [ -f "$file" ] &amp;&amp; echo "EXISTS: $file" || echo "MISSING: $file"
144
- done
145
- ```
146
-
147
- <variant condition="ALL expected files exist">
148
- ```
149
- ! Implementation appears complete — all expected files exist.
150
- Uncommitted changes detected in working tree.
151
- ```
152
-
153
- Display the file check results (EXISTS/MISSING for each expected file).
154
-
155
- Use AskUserQuestion:
156
- - header: "Resume?"
157
- - question: "All files from the Technical Solution already exist and there are uncommitted changes. Is the implementation done? Do you want to skip to code review (step 4)?"
158
- - options:
159
- - "Yes, skip to review" — Implementation is done, continue from step 4 (code review → approval → state → wiki → commit)
160
- - "No, start fresh" — Plan and execute from scratch (I'll handle the working tree)
161
-
162
- <option value="Yes, skip to review">
163
- Skip steps 2 and 3 entirely.
164
- Jump DIRECTLY to step 4 (code review).
165
- </option>
166
- <option value="No, start fresh">
167
- Proceed normally from step 2 (user is responsible for cleaning working tree).
168
- </option>
169
- </variant>
170
-
171
- <variant condition="SOME expected files exist (partial implementation)">
172
- ```
173
- ! Partial implementation detected — some expected files exist.
174
- ```
175
-
176
- Display the file check results (EXISTS/MISSING for each expected file).
177
-
178
- Use AskUserQuestion:
179
- - header: "Resume?"
180
- - question: "Some files from the Technical Solution already exist. What would you like to do?"
181
- - options:
182
- - "Continue from plan" — Create a plan that accounts for existing files
183
- - "Start fresh" — Plan and execute from scratch (I'll handle the working tree)
184
-
185
- <option value="Continue from plan">
186
- Proceed to step 2. The plan must account for already-existing files
187
- and only implement what's missing.
188
- </option>
189
- <option value="Start fresh">
190
- Proceed normally from step 2 (user is responsible for cleaning working tree).
191
- </option>
192
- </variant>
193
-
194
- <variant condition="NO expected files from Technical Solution exist">
195
- Uncommitted changes exist but none match expected story files.
196
- Proceed normally to step 2.
197
- </variant>
198
- </variant>
199
- </substep>
200
-
201
- <substep order="1.6" name="resolve-agent-teams">
202
- <rule condition="--agent-teams-off flag present">Set `USE_AGENT_TEAMS = false` regardless of setting.</rule>
203
- <rule condition="flag not present">Set `USE_AGENT_TEAMS = INIT.agent_teams`.</rule>
204
- </substep>
205
-
206
- <substep order="1.7" name="display-context">
207
- ```
208
- i Story: {INIT.story.id} — {INIT.story.title}
209
- Feature: {INIT.feature.id} — {INIT.feature.title}
210
- Status: {INIT.story.status} | Size: {INIT.story.size}
211
- AC scenarios: {INIT.acceptance_criteria_count}
212
- Technical solution: present
213
- Agent teams: {USE_AGENT_TEAMS ? "enabled" : "disabled"}
214
- ```
215
- </substep>
216
-
217
- </step>
218
-
219
- <!-- ═══ CHECKPOINT: Step 1 MUST be complete. Init MUST have run. Banner MUST be displayed. Context MUST be shown. ═══ -->
220
-
221
- <!-- ══════════════════════════════════════════════════════════════════ -->
222
- <!-- STEP 2: LOAD CONTEXT & CHOOSE EXECUTION MODE -->
223
- <!-- ══════════════════════════════════════════════════════════════════ -->
224
-
225
- <step name="load-and-decide" order="2">
226
-
227
- <substep order="2.1" name="display-banner">
228
- ```
229
- ┌──────────────────────────────────────────────────┐
230
- │ ACE > Execute Story > Planning │
231
- └──────────────────────────────────────────────────┘
232
- ```
233
- </substep>
234
-
235
- <substep order="2.2" name="read-story-sections">
236
- Read `INIT.paths.story_file` and extract:
237
- - **Acceptance Criteria** — Gherkin scenarios (WHAT to build)
238
- - **Technical Solution** — component breakdown, sequence diagrams (HOW)
239
- - **Relevant Wiki** — file references for codebase context (WHERE)
240
- - **Out of Scope** — explicit exclusions (what NOT to build)
241
- - **Dependencies** — what must exist before this story
242
- - **Definition of Done** — quality checklist
243
- </substep>
244
-
245
- <substep order="2.3" name="read-coding-standards">
246
- <variant condition="INIT.has_coding_standards is true">
247
- Read `INIT.paths.coding_standards` in full — coding standards are mandatory context.
248
- </variant>
249
- </substep>
250
-
251
- <substep order="2.4" name="assess-and-choose-execution-mode">
252
- **BEFORE any planning — analyze the story and ask the user to choose execution mode.**
253
-
254
- Analyze the Technical Solution to assess complexity. Count ALL of the following signals:
255
-
256
- <complexity-signals>
257
- <signal weight="high" name="story-size">Story size >= 5 SP</signal>
258
- <signal weight="high" name="file-count">Technical solution touches 6+ files</signal>
259
- <signal weight="high" name="new-code-volume">Technical solution estimates 100+ new lines of code</signal>
260
- <signal weight="high" name="implementation-phases">Technical solution defines 3+ implementation phases</signal>
261
- <signal weight="medium" name="cross-cutting">Changes span multiple layers (state + UI + services + tests)</signal>
262
- <signal weight="medium" name="complex-patterns">Story involves concurrency, cancellation, retry logic, race conditions, or state machines</signal>
263
- <signal weight="medium" name="independent-components">Technical solution shows 3+ independent components that could be built in parallel</signal>
264
- <signal weight="medium" name="ac-count">Story has 5+ acceptance criteria scenarios</signal>
265
- <signal weight="low" name="multi-subsystem">Changes touch multiple backend/frontend subsystems via API calls</signal>
266
- <signal weight="low" name="context-window-risk">Estimated implementation would exceed ~140k tokens (70% of 200k context)</signal>
267
- </complexity-signals>
268
-
269
- <assessment-rules>
270
- **Recommend Agent Teams** when ANY of:
271
- - 3+ HIGH signals present
272
- - 2+ HIGH signals AND 2+ MEDIUM signals
273
- - Story has independent components that can genuinely be built in parallel
274
-
275
- **Recommend Solo** when:
276
- - Mostly sequential work with tight dependencies between components
277
- - Small story (1-3 SP) with few files
278
- - Simple CRUD or single-file changes
279
-
280
- **When in doubt → recommend Agent Teams.** It's better to have teammates
281
- that finish early than a solo session that runs out of context window.
282
- </assessment-rules>
283
-
284
- **MANDATORY: Always present this choice to the user using AskUserQuestion — NEVER skip it, NEVER auto-decide.**
285
-
286
- Present your complexity assessment summary, then ask:
287
-
288
- <variant condition="USE_AGENT_TEAMS is true">
289
- Use AskUserQuestion:
290
- - header: "Execution"
291
- - question: "How should this story be executed?\n\nComplexity: {count high/medium/low signals hit}\n{list the signals that matched}\n\nMy recommendation: {Solo|Agent Teams} because {reasoning}"
292
- - options:
293
- - "{Recommended option} (Recommended)" — with reasoning
294
- - "{Other option}" — with reasoning
295
- - The recommended option goes first with "(Recommended)" suffix
296
- </variant>
297
-
298
- <variant condition="USE_AGENT_TEAMS is false">
299
- Agent teams are disabled by configuration. Use AskUserQuestion:
300
- - header: "Execution"
301
- - question: "Agent teams are disabled.\n\nComplexity: {count signals hit}\n{list the signals that matched}\n\nExecute in solo mode?"
302
- - options:
303
- - "Solo (Confirmed)" — proceed with solo execution
304
- - "Enable Agent Teams" — I want agent teams for this story (override the setting)
305
-
306
- <variant condition="user chose Enable Agent Teams">
307
- Override: set `USE_AGENT_TEAMS = true` and re-present the full
308
- Solo vs Agent Teams choice as in the variant above.
309
- </variant>
310
- </variant>
311
-
312
- Store the user's choice as `EXECUTION_MODE` (solo | agent-teams).
313
- </substep>
314
-
315
- <!-- ─────────────────────────────────────────────────── -->
316
- <!-- SOLO PATH: Main creates plan, executor agent runs -->
317
- <!-- ─────────────────────────────────────────────────── -->
318
-
319
- <substep order="2.5" name="solo-plan-mode" condition="EXECUTION_MODE is solo">
320
- **BEFORE entering Plan Mode, display this highlighted warning to the user:**
321
-
322
- ```
323
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
324
- ┃ ⚠️ IMPORTANT — READ BEFORE EXITING PLAN MODE ┃
325
- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
326
- ┃ ┃
327
- ┃ When Claude Code wants to exit plan mode, do NOT choose ┃
328
- ┃ the option with "clear context" no matter how filled ┃
329
- ┃ the context is! This will interrupt our command! ┃
330
- ┃ ┃
331
- ┃ The implementation in solo mode is done by a different ┃
332
- ┃ subagent with a fresh context window — no need to clear it. ┃
333
- ┃ ┃
334
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
335
- ```
336
-
337
- Enter Plan Mode using the EnterPlanMode tool.
338
-
339
- Feed into Plan Mode context:
340
-
341
- ```
342
- Create an execution plan for this story based on the technical solution.
343
-
344
- STORY: {INIT.story.id} — {INIT.story.title}
345
-
346
- ACCEPTANCE CRITERIA:
347
- {extracted AC scenarios}
348
-
349
- TECHNICAL SOLUTION:
350
- {extracted technical solution}
351
-
352
- RELEVANT WIKI:
353
- {extracted wiki references}
354
-
355
- CODING STANDARDS:
356
- {full coding standards document}
357
-
358
- OUT OF SCOPE:
359
- {extracted out-of-scope items}
360
- ```
361
-
362
- <plan-rules>
363
- <rule>Follow the technical solution's component breakdown and sequence diagrams</rule>
364
- <rule>Each task must map to one or more AC scenarios</rule>
365
- <rule>Include verification steps (tests, build checks) after implementation tasks</rule>
366
- <rule>Follow coding standards from wiki</rule>
367
- <rule>DO NOT implement anything outside the AC scenarios (respect Out of Scope)</rule>
368
- <rule>NO intermediary commits — all changes accumulate as working tree changes</rule>
369
- <rule>ONE commit happens AFTER user approval at the end</rule>
370
- </plan-rules>
371
-
372
- <deviation-rules>
373
- <rule id="1" name="Auto-fix Bugs" approval="auto">Broken behavior, errors, type errors, security → fix inline, track as [Rule 1 - Bug]</rule>
374
- <rule id="2" name="Auto-add Missing Critical" approval="auto">Missing validation, error handling, auth → add, track as [Rule 2 - Missing Critical]</rule>
375
- <rule id="3" name="Auto-fix Blocking" approval="auto">Missing deps, broken imports, build errors → fix, track as [Rule 3 - Blocking]</rule>
376
- <rule id="4" name="Architectural Changes" approval="user">New DB tables, switching libraries, breaking API → STOP and ask user</rule>
377
- </deviation-rules>
378
-
379
- <self-verification>
380
- After each significant step:
381
- - Build check: run build command — must pass
382
- - Test check: run relevant tests — must pass
383
- - File existence: verify created files exist
384
- - Import check: verify new modules are imported/used where expected
385
- </self-verification>
386
- </substep>
387
-
388
- <substep order="2.6" name="solo-approve-plan" condition="EXECUTION_MODE is solo">
389
- User approves the plan (standard Plan Mode approval flow via ExitPlanMode).
390
-
391
- After plan approval, **read the plan file** that Plan Mode created.
392
- Store its contents as `APPROVED_PLAN` — this will be passed to the executor agent.
393
-
394
- Proceed to step 3b (solo execution via executor agent).
395
- </substep>
396
-
397
- <!-- ─────────────────────────────────────────────────── -->
398
- <!-- AGENT TEAMS PATH: Main stays out of Plan Mode -->
399
- <!-- Teammates plan their own work — lead approves -->
400
- <!-- ─────────────────────────────────────────────────── -->
401
-
402
- <substep order="2.7" name="teams-task-decomposition" condition="EXECUTION_MODE is agent-teams">
403
- **Main does NOT enter Plan Mode.** The Technical Solution IS the high-level plan.
404
-
405
- Decompose the Technical Solution into teammate assignments:
406
- - Identify 2-4 independent work streams from the implementation phases/components
407
- - Assign each stream to a teammate role (e.g., "state-layer", "ui-layer", "integration", "tests")
408
- - Map AC scenarios to teammates (each AC must be covered by at least one teammate)
409
- - Identify shared interfaces/contracts between teammates
410
- - Identify task dependencies (which teammate's work blocks another)
411
-
412
- Present the team composition to the user using AskUserQuestion:
413
- - header: "Team"
414
- - question: "Proposed agent team:\n\n{for each teammate: role, files owned, tasks, AC coverage}\n\nDoes this look right?"
415
- - options:
416
- - "Approve team" — create the team as proposed
417
- - "Adjust" — I want to change the team composition
418
-
419
- <variant condition="user chose Adjust">
420
- Ask what they want to change → adjust → re-present.
421
- </variant>
422
-
423
- Proceed to step 3a (agent teams execution).
424
- </substep>
425
-
426
- </step>
427
-
428
- <!-- ═══ CHECKPOINT: Step 2 MUST be complete. Execution mode MUST be chosen via AskUserQuestion. Plan MUST be approved (solo) or team MUST be approved (teams). ═══ -->
429
-
430
- <!-- ══════════════════════════════════════════════════════════════════ -->
431
- <!-- STEP 3a: AGENT TEAMS EXECUTION -->
432
- <!-- ══════════════════════════════════════════════════════════════════ -->
433
-
434
- <step name="agent-teams-execution" order="3a">
435
- **This step only runs when agent teams mode is selected.**
436
- **Main (lead) does NOT enter Plan Mode — teammates plan their own work.**
437
-
438
- <substep order="3a.1" name="display-banner">
439
- ```
440
- ┌──────────────────────────────────────────────────┐
441
- │ ACE > Execute Story > Agent Teams │
442
- └──────────────────────────────────────────────────┘
443
-
444
- i Creating agent team for story implementation...
445
- ```
446
- </substep>
447
-
448
- <substep order="3a.2" name="create-team">
449
- Create an agent team using the decomposition from step 2.7.
450
-
451
- Tell Claude Code to create the team in natural language:
452
-
453
- ```
454
- Create an agent team for implementing story {INIT.story.id} {INIT.story.title}.
455
-
456
- Teammates:
457
- {For each teammate from the approved decomposition:}
458
- N. "{role}" — {description of work}
459
- Files owned: {list of files this teammate owns — NO overlap with other teammates}
460
- Tasks: {task list from decomposition}
461
- Require plan approval before they make any changes.
462
-
463
- {If coding standards exist:}
464
- N+1. "reviewer" Review code written by other teammates
465
- Watches for: TODOs, stubs, placeholders, hardcoded values, missing tests,
466
- deviation from coding standards, missing error handling, dead code,
467
- backwards-compatible shims.
468
- Messages teammates directly when issues found.
469
- Creates tasks in shared task list for issues requiring fixes.
470
- Does a final sweep when all teammates are done.
471
-
472
- All teammates must follow:
473
- - Coding standards from {INIT.paths.coding_standards}
474
- - Technical solution from story file
475
- - NO intermediary commits — changes accumulate as working tree changes
476
- - Deviation rules: auto-fix bugs/critical/blocking (Rules 1-3), STOP for architectural (Rule 4)
477
-
478
- Only approve plans that:
479
- - Follow the technical solution's component design exactly
480
- - Include verification steps (build check, type check) after implementation
481
- - Do NOT touch files owned by another teammate
482
- - Map to AC scenarios from the story
483
- ```
484
-
485
- Each teammate enters plan mode automatically (via "Require plan approval").
486
- The lead reviews and approves/rejects each teammate's plan autonomously.
487
- </substep>
488
-
489
- <substep order="3a.3" name="monitor-execution">
490
- After plans are approved, teammates execute in parallel:
491
-
492
- <task>Each teammate implements their approved plan</task>
493
- <task>Teammates message each other for coordination on shared interfaces</task>
494
- <task>Reviewer teammate monitors — checks code as it's written, messages others about issues</task>
495
- <task>User can interact with any teammate via `Shift+Down`</task>
496
- <task>If lead starts implementing tasks itself, tell it: "Wait for your teammates to complete their tasks before proceeding"</task>
497
- <task>When all teammates idle lead collects results</task>
498
- </substep>
499
-
500
- <substep order="3a.4" name="final-verification">
501
- After all teammates complete:
502
- <task>Run `git status` to see all changes</task>
503
- <task>Run build + test suite to verify everything works together</task>
504
- <task>If build/tests fail → coordinate fixes with relevant teammate</task>
505
-
506
- Proceed to step 4 (reviewer teammate's final sweep serves as the review).
507
- </substep>
508
-
509
- </step>
510
-
511
- <!-- ═══ CHECKPOINT: Step 3a runs ONLY if agent-teams mode was chosen. Otherwise skip to 3b. ═══ -->
512
-
513
- <!-- ══════════════════════════════════════════════════════════════════ -->
514
- <!-- STEP 3b: SOLO EXECUTION -->
515
- <!-- ══════════════════════════════════════════════════════════════════ -->
516
-
517
- <step name="solo-execution" order="3b">
518
- **This step runs when solo mode is selected.**
519
- **Main spawns an executor subagent with a FRESH context window.**
520
-
521
- <substep order="3b.1" name="display-banner">
522
- ```
523
- ┌──────────────────────────────────────────────────┐
524
- │ ACE > Execute Story > Implementing │
525
- └──────────────────────────────────────────────────┘
526
-
527
- i Spawning executor agent with fresh context...
528
- ```
529
- </substep>
530
-
531
- <substep order="3b.2" name="spawn-executor-agent">
532
- Spawn a subagent to execute the approved plan in a **fresh 200k context window**.
533
- The main session's context is preserved for post-implementation steps (review, state, wiki).
534
-
535
- ```
536
- Agent(
537
- prompt="You are the ACE Story Executor. Implement this story by following
538
- the approved execution plan EXACTLY.
539
-
540
- STORY: {INIT.story.id} {INIT.story.title}
541
- STORY FILE: {INIT.paths.story_file}
542
-
543
- Read the story file to get the full Acceptance Criteria and Technical Solution.
544
-
545
- {If INIT.has_coding_standards:}
546
- CODING STANDARDS: {INIT.paths.coding_standards}
547
- Read coding standards in full before starting implementation.
548
-
549
- APPROVED EXECUTION PLAN:
550
- {APPROVED_PLAN}
551
-
552
- RULES:
553
- - Follow the plan step by step — do NOT skip steps or reorder
554
- - After each significant step: run build check + test check
555
- - NO commits — all changes stay as working tree changes
556
- - Auto-fix bugs, missing critical code, and blocking issues (Rules 1-3)
557
- - For architectural changes beyond story scope (Rule 4): STOP and include
558
- in your return report main will ask the user
559
- - Respect Out of Scope do NOT implement anything not in the AC
560
-
561
- SELF-VERIFICATION (after ALL implementation is complete):
562
- - Verify all key files from the plan exist
563
- - Run full build — must pass
564
- - Run full test suite — must pass
565
- - If verification fails, fix before returning
566
-
567
- **Return format ONLY this, nothing else:**
568
- IMPLEMENTATION COMPLETE
569
- - Files created: {list}
570
- - Files modified: {list}
571
- - Build: {pass/fail}
572
- - Tests: {pass/fail — include test command and result}
573
- - Deviations: {list of [Rule N] deviations, or 'None'}
574
- - Rule 4 blockers: {list of architectural issues needing user decision, or 'None'}
575
- - Notes: {anything the main session needs to know}",
576
- subagent_type="general-purpose",
577
- model="{INIT.executor_model}",
578
- description="Execute {INIT.story.id}"
579
- )
580
- ```
581
-
582
- Parse the executor's return report.
583
- </substep>
584
-
585
- <substep order="3b.3" name="handle-executor-result">
586
- <variant condition="Rule 4 blockers reported">
587
- The executor hit architectural issues it couldn't auto-resolve.
588
- Present each blocker to the user:
589
-
590
- ```
591
- ! Executor reported architectural issue(s) requiring your decision:
592
-
593
- {For each Rule 4 blocker:}
594
- ? {description}
595
- Proposed change: {what the executor wants to do}
596
- Impact: {what it affects}
597
- ```
598
-
599
- Use AskUserQuestion for each blocker:
600
- - header: "Rule 4"
601
- - question: "{blocker description} — approve this change?"
602
- - options:
603
- - "Approve" — allow the change
604
- - "Reject"find an alternative approach
605
- - "Reject and stop" — stop implementation entirely
606
-
607
- If approved: spawn a follow-up executor agent to apply the approved changes.
608
- If rejected: spawn a follow-up executor agent with alternative instructions.
609
- If stopped: proceed to step 5 with partial implementation for user review.
610
- </variant>
611
-
612
- <variant condition="Build or tests failed">
613
- ```
614
- x Executor reported build/test failures.
615
- Spawning follow-up agent to fix...
616
- ```
617
- Spawn a follow-up executor agent focused on fixing the failures.
618
- Include the failure output in the prompt.
619
- </variant>
620
-
621
- <variant condition="All clear implementation complete">
622
- Proceed to step 4 (code review).
623
- </variant>
624
- </substep>
625
-
626
- <substep order="3b.4" name="no-intermediary-commits">
627
- **CRITICAL: Do NOT commit during implementation.**
628
- All changes accumulate as working tree changes (unstaged/staged).
629
- Only ONE commit happens after user approval in step 5.
630
-
631
- Store the executor's deviation list for the Summary &amp; State section.
632
- </substep>
633
-
634
- </step>
635
-
636
- <!-- ═══ CHECKPOINT: Implementation MUST be complete (step 3a or 3b). Executor report MUST be parsed. ═══ -->
637
-
638
- <!-- ══════════════════════════════════════════════════════════════════ -->
639
- <!-- STEP 4: CODE REVIEW -->
640
- <!-- ══════════════════════════════════════════════════════════════════ -->
641
-
642
- <step name="code-review" order="4">
643
-
644
- <substep order="4.1" name="display-banner">
645
- ```
646
- ┌──────────────────────────────────────────────────┐
647
- │ ACE > Execute Story > Code Review │
648
- └──────────────────────────────────────────────────┘
649
-
650
- i Running code review...
651
- ```
652
- </substep>
653
-
654
- <substep order="4.2" name="determine-review-mode">
655
- <variant condition="Agent Teams mode">
656
- The reviewer teammate's final sweep serves as the review.
657
- Skip the subagent spawn — use the reviewer teammate's report.
658
- If the reviewer has already flagged and resolved all issues, proceed to step 5.
659
- </variant>
660
-
661
- <variant condition="Solo mode">
662
- Dispatch /ace:review-story as a subagent (see substep 4.3).
663
- </variant>
664
- </substep>
665
-
666
- <substep order="4.3" name="dispatch-review-story">
667
- **Solo mode only.** Dispatch the review-story command:
668
-
669
- ```
670
- Agent(
671
- prompt="/ace:review-story story={INIT.paths.story_file}
672
-
673
- Execute the review-story workflow end-to-end.
674
-
675
- **Return format — ONLY this, nothing else:**
676
- REVIEW COMPLETE
677
- Status: {passed | issues_found}
678
- - Blockers: {count}
679
- - Warnings: {count}
680
- - Files reviewed: {count}
681
- - Artifacts verified: {passed}/{total} (3-level)
682
- - AC coverage: {covered}/{total} scenarios
683
- - Tech debt items discovered: {count}
684
-
685
- [Blocker list with file:line, description, severity, suggested fix]
686
- [Warning list with file:line, description, severity, suggested fix]
687
- [Tech debt list in YAML format]",
688
- subagent_type="ace-code-reviewer",
689
- model="{INIT.reviewer_model}",
690
- description="Code review for {INIT.story.id}"
691
- )
692
- ```
693
- </substep>
694
-
695
- <substep order="4.4" name="fix-verify-loop">
696
- **If blockers found → auto-fix cycle:**
697
-
698
- <loop max-iterations="3">
699
- <task>Review reports blockers</task>
700
- <task>Fix them (deviation rules 1-3 apply — most blocker fixes are auto-approved)</task>
701
- <task>Re-run review (focused on previously-failed items only)</task>
702
- <task>Repeat until zero blockers</task>
703
- </loop>
704
-
705
- <escalation condition="blockers persist after 3 rounds">
706
- Escalate to user (Rule 4 behavior).
707
- </escalation>
708
-
709
- Warnings don't block — they're presented to user alongside verification.
710
- Each fix round is tracked as a deviation in the summary.
711
- Store the code review results (including tech debt YAML) for later steps.
712
- </substep>
713
-
714
- </step>
715
-
716
- <!-- ═══ CHECKPOINT: Code review MUST be complete with zero blockers before proceeding. ═══ -->
717
-
718
- <!-- ══════════════════════════════════════════════════════════════════ -->
719
- <!-- STEP 5: USER VERIFICATION & COMMIT -->
720
- <!-- ══════════════════════════════════════════════════════════════════ -->
721
-
722
- <step name="user-verification" order="5">
723
-
724
- <substep order="5.1" name="display-verification">
725
- <variant condition="RESUME_FROM_DEVREADY is true">
726
- ```
727
- ╔══════════════════════════════════════════════════╗
728
- ║ ACE > Execute Story > Verification ║
729
- ╚══════════════════════════════════════════════════╝
730
-
731
- Story: {INIT.story.id} — {INIT.story.title}
732
-
733
- Previously implemented and marked DevReady.
734
- Ready to promote to Done after manual verification.
735
- ```
736
- </variant>
737
-
738
- <variant condition="RESUME_FROM_DEVREADY is false (normal execution)">
739
- ```
740
- ╔══════════════════════════════════════════════════╗
741
- ║ ACE > Execute Story > Verification ║
742
- ╚══════════════════════════════════════════════════╝
743
-
744
- Story: {INIT.story.id} — {INIT.story.title}
745
-
746
- Implementation complete. Please verify:
747
-
748
- Acceptance Criteria Walkthrough:
749
- ────────────────────────────────
750
- 1. ✓ {scenario name} — [auto-verified: tests pass]
751
- 2. ? {scenario name} — [needs manual check: {instructions}]
752
- ...
753
-
754
- Code Review Results:
755
- ────────────────────
756
- ✓ No blockers found
757
- {⚠ N warning(s): {brief descriptions}}
758
-
759
- Deviations:
760
- ────────────
761
- {deviation list or "None — plan executed as written"}
762
- ```
763
- </variant>
764
- </substep>
765
-
766
- <substep order="5.2" name="ask-user">
767
- <variant condition="RESUME_FROM_DEVREADY is true">
768
- Use AskUserQuestion:
769
- - header: "Verify"
770
- - question: "Story was previously implemented as DevReady. Has manual testing passed?"
771
- - options:
772
- - "Approve (Done)" — Manual testing passed, promote to Done
773
- - "Fix issues" Something still needs to be changed
774
-
775
- <option value="Fix issues">
776
- Ask what needs fixing apply fixes (deviation rules apply) →
777
- return to this verification prompt.
778
- </option>
779
-
780
- <option value="Approve (Done)">
781
- Set `FINAL_STATUS = Done`.
782
- Proceed to step 6 (state updates) → step 7 (wiki + commit).
783
- </option>
784
- </variant>
785
-
786
- <variant condition="RESUME_FROM_DEVREADY is false (normal execution)">
787
- Use AskUserQuestion:
788
- - header: "Verify"
789
- - question: "Implementation and code review complete. Does everything look correct?"
790
- - options:
791
- - "Approve (Done)" — All AC verified, mark story as Done
792
- - "Approve (DevReady)"Implementation done but I need to test manually first
793
- - "Fix issues" — Something needs to be changed
794
-
795
- <option value="Fix issues">
796
- Ask what needs fixing apply fixes (deviation rules apply) →
797
- re-run code review (focused) → return to verification prompt.
798
- </option>
799
-
800
- <option value="Approve (Done)">
801
- Set `FINAL_STATUS = Done`.
802
- Proceed to step 6 (state updates) → step 7 (wiki + commit).
803
- </option>
804
-
805
- <option value="Approve (DevReady)">
806
- Set `FINAL_STATUS = DevReady`.
807
-
808
- Present manual testing instructions:
809
- ```
810
- ! Manual testing required before wiki mapping.
811
- The following scenarios need manual verification:
812
-
813
- {For each AC scenario that was NOT auto-verified by tests:}
814
- ? {scenario name}
815
- How to test: {step-by-step manual test instructions}
816
-
817
- After testing, run /ace:execute-story again with this story.
818
- It will detect DevReady status and skip directly to verification.
819
- ```
820
-
821
- **DevReady path: skip wiki, commit code + state only.**
822
- Proceed to step 6 (state updates) → step 7.6 (commit) directly.
823
- Do NOT run step 7.1-7.5 (wiki mapping) — the code may still change
824
- after manual testing. Wiki mapping happens when the story reaches Done.
825
- </option>
826
- </variant>
827
- </substep>
828
-
829
- </step>
830
-
831
- <!-- ═══ CHECKPOINT: User MUST have approved via AskUserQuestion (Done or DevReady). ═══ -->
832
-
833
- <!-- ══════════════════════════════════════════════════════════════════ -->
834
- <!-- STEP 6: STATE UPDATES -->
835
- <!-- ══════════════════════════════════════════════════════════════════ -->
836
-
837
- <step name="state-updates" order="6">
838
-
839
- <substep order="6.1" name="display-banner">
840
- ```
841
- ┌──────────────────────────────────────────────────┐
842
- │ ACE > Execute Story > State Updates │
843
- └──────────────────────────────────────────────────┘
844
- ```
845
- </substep>
846
-
847
- <substep order="6.2" name="write-summary-section">
848
- Write `## Summary &amp; State` section into the story file at the
849
- `&lt;section name="summary-and-state"&gt;` location:
850
-
851
- ```markdown
852
- ## Summary &amp; State
853
-
854
- **Status**: {FINAL_STATUS}
855
- **Executed**: {current date YYYY-MM-DD}
856
- **Duration**: {execution duration}
857
-
858
- ### Implementation Summary
859
- {Substantive one-liner — e.g., "OAuth buttons with Google/GitHub using next-auth providers"}
860
-
861
- ### Commits
862
- | # | Hash | Type | Description |
863
- |---|---------|----------|--------------------------------------|
864
- | 1 | {hash} | feat | {description} |
865
-
866
- ### Deviations
867
- {None plan executed as written}
868
- OR
869
- {1. [Rule N] description of deviation}
870
-
871
- ### Code Review
872
- - Blockers found: {count} (all resolved)
873
- - Warnings: {count}
874
- - AC coverage: {covered}/{total} scenarios
875
- - Tech debt discovered: {count} items
876
- ```
877
- </substep>
878
-
879
- <substep order="6.3" name="update-state-via-tools">
880
- ```bash
881
- node ~/.claude/agile-context-engineering/src/ace-tools.js story update-state \
882
- story={INIT.paths.story_file} \
883
- status={FINAL_STATUS}
884
- ```
885
-
886
- Parse result for: `story_updated`, `feature_updated`, `backlog_updated`, `feature_status_changed`.
887
-
888
- ```
889
- + Story status updated to {FINAL_STATUS}
890
- {+ Feature file updated (if feature_updated)}
891
- {+ Product backlog updated (if backlog_updated)}
892
- {+ Feature status changed to Done! (if feature_status_changed)}
893
- ```
894
- </substep>
895
-
896
- <substep order="6.4" name="update-github">
897
- <variant condition="INIT.github_project.enabled is false OR INIT.has_gh_cli is false">
898
- ```
899
- — GitHub sync skipped (not configured or gh CLI unavailable).
900
- ```
901
- </variant>
902
-
903
- <variant condition="INIT.github_project.enabled is true AND INIT.has_gh_cli is true">
904
- Sync story and feature GitHub issues in a single call.
905
- This command prints status lines directly to the console (stderr)
906
- so the user ALWAYS sees whether each issue was updated or not.
907
-
908
- ```bash
909
- node ~/.claude/agile-context-engineering/src/ace-tools.js github sync-story \
910
- repo={INIT.github_project.repo} \
911
- story_file={INIT.paths.story_file} \
912
- feature_file={INIT.paths.feature_file} \
913
- owner={INIT.github_project.owner} \
914
- project={INIT.github_project.project_number}
915
- ```
916
-
917
- The command handles all cases:
918
- - Story/feature has no GitHub issue linked → prints skip message
919
- - Update succeeds → prints success message with issue number
920
- - Update fails prints error message with details
921
- </variant>
922
- </substep>
923
-
924
- </step>
925
-
926
- <!-- ═══ CHECKPOINT: State updates MUST be complete (story, feature, backlog, GitHub). ═══ -->
927
-
928
- <!-- ══════════════════════════════════════════════════════════════════ -->
929
- <!-- STEP 7: WIKI UPDATE -->
930
- <!-- ══════════════════════════════════════════════════════════════════ -->
931
-
932
- <step name="wiki-and-commit" order="7">
933
-
934
- <!-- ─────────────────────────────────────────────────── -->
935
- <!-- WIKI MAPPING: Only when FINAL_STATUS = Done -->
936
- <!-- DevReady skips straight to commit (7.6) -->
937
- <!-- ─────────────────────────────────────────────────── -->
938
-
939
- <substep order="7.1" name="display-banner" condition="FINAL_STATUS is Done">
940
- ```
941
- ┌──────────────────────────────────────────────────┐
942
- │ ACE > Execute Story > Wiki Update │
943
- └──────────────────────────────────────────────────┘
944
-
945
- i Wiki mapper running (background agent)...
946
- ```
947
- </substep>
948
-
949
- <substep order="7.2" name="dispatch-map-story" condition="FINAL_STATUS is Done">
950
- Dispatch /ace:map-story as a background agent.
951
- Pass tech debt from the code review output as a parameter — map-story
952
- handles all tech debt integration (wiki docs + index).
953
-
954
- **CRITICAL Context Window Protection:**
955
- The agent writes directly to wiki files and returns ONLY a confirmation.
956
- Do NOT call TaskOutput on the background agent — it pollutes the main context.
957
-
958
- ```
959
- Agent(
960
- prompt="/ace:map-story story-context={INIT.paths.story_file} tech-debt=\"{tech_debt_yaml from code review output}\"
961
-
962
- Execute the map-story workflow end-to-end.
963
-
964
- **Return format — ONLY this, nothing else:**
965
- WIKI UPDATE COMPLETE
966
- - Updated: {list of updated wiki docs}
967
- - Created: {list of new wiki docs}
968
- - Tech debt integrated: {count} items across {count} wiki docs
969
- - No change needed: {list}",
970
- subagent_type="ace-wiki-mapper",
971
- run_in_background=true,
972
- description="Wiki update for {INIT.story.id}"
973
- )
974
- ```
975
-
976
- Store the agent task ID as `WIKI_TASK`.
977
- </substep>
978
-
979
- <substep order="7.3" name="wait-for-wiki-completion" condition="FINAL_STATUS is Done">
980
- **BLOCKING WAIT — Do NOT proceed to substep 7.4 until the wiki mapper has finished.**
981
-
982
- Poll using TaskGet until the background agent completes:
983
- ```
984
- Loop (max 60 iterations, 10 second intervals):
985
- TaskGet(id=WIKI_TASK)
986
- If status is "completed" break, proceed to 7.4
987
- If status is "failed" → log warning, proceed to 7.4 (commit without wiki)
988
- Otherwise continue polling
989
- ```
990
-
991
- Once complete, verify wiki files exist:
992
- ```bash
993
- git status --short .docs/wiki/
994
- ```
995
-
996
- **IMPORTANT: Do NOT call TaskOutput on WIKI_TASK. The output pollutes the main
997
- context window. The wiki mapper writes directly to files — git status is sufficient
998
- to enumerate what changed.**
999
- </substep>
1000
-
1001
- <substep order="7.4" name="write-wiki-updates-section" condition="FINAL_STATUS is Done">
1002
- Write `## Wiki Updates` section into the story file:
1003
-
1004
- ```markdown
1005
- ## Wiki Updates
1006
-
1007
- **Updated**: {current date}
1008
-
1009
- | Document | Action | Path |
1010
- |----------|--------|------|
1011
- | {doc name} | Updated | {path} |
1012
- | {doc name} | Created | {path} |
1013
- | {doc name} | No change | {path} |
1014
- ```
1015
- </substep>
1016
-
1017
- <substep order="7.5" name="update-github-with-wiki" condition="FINAL_STATUS is Done">
1018
- <variant condition="INIT.github_project.enabled is true AND INIT.has_gh_cli is true">
1019
- Update GitHub issues again (story file now includes the Wiki Updates section):
1020
-
1021
- ```bash
1022
- node ~/.claude/agile-context-engineering/src/ace-tools.js github sync-story \
1023
- repo={INIT.github_project.repo} \
1024
- story_file={INIT.paths.story_file} \
1025
- feature_file={INIT.paths.feature_file} \
1026
- owner={INIT.github_project.owner} \
1027
- project={INIT.github_project.project_number}
1028
- ```
1029
- </variant>
1030
- </substep>
1031
-
1032
- <!-- ─────────────────────────────────────────────────── -->
1033
- <!-- COMMIT: Always runs (both Done and DevReady) -->
1034
- <!-- ─────────────────────────────────────────────────── -->
1035
-
1036
- <substep order="7.6" name="create-story-commit">
1037
- **ONE single commit for the entire story — code + state {+ wiki if Done}.**
1038
-
1039
- Stage all files individually (NEVER `git add .` or `git add -A`):
1040
- ```bash
1041
- git status --short
1042
- git add {each implementation file}
1043
- git add {INIT.paths.story_file} {INIT.paths.feature_file} .ace/artifacts/product/product-backlog.md
1044
- ```
1045
-
1046
- <variant condition="FINAL_STATUS is Done">
1047
- Also stage wiki files:
1048
- ```bash
1049
- git add .docs/wiki/
1050
- ```
1051
- </variant>
1052
-
1053
- Commit with conventional format:
1054
- ```
1055
- feat({INIT.story.id}): {INIT.story.title}
1056
-
1057
- - {key change 1}
1058
- - {key change 2}
1059
- - {key change 3}
1060
- ```
1061
-
1062
- Record commit hash:
1063
- ```bash
1064
- COMMIT_HASH=$(git rev-parse --short HEAD)
1065
- ```
1066
-
1067
- ```
1068
- + Story committed: {COMMIT_HASH}
1069
- ```
1070
- </substep>
1071
-
1072
- <substep order="7.7" name="display-completion">
1073
- <variant condition="FINAL_STATUS is Done">
1074
- ```
1075
- ╔══════════════════════════════════════════════════╗
1076
- ║ ACE > Story Executed ║
1077
- ║ {INIT.story.id} "{INIT.story.title}" ║
1078
- ╚══════════════════════════════════════════════════╝
1079
-
1080
- + Story execution complete.
1081
-
1082
- Status: Done
1083
- Commit: {COMMIT_HASH}
1084
- AC coverage: {covered}/{total} scenarios
1085
- Deviations: {count}
1086
- Wiki docs updated: {count}
1087
-
1088
- Next > /ace:execute-story story={next story path}
1089
- Execute the next story in the feature.
1090
- > /ace:plan-story story={next story path}
1091
- Plan the next story.
1092
- ```
1093
- </variant>
1094
-
1095
- <variant condition="FINAL_STATUS is DevReady">
1096
- ```
1097
- ╔══════════════════════════════════════════════════╗
1098
- ║ ACE > Story Implemented (DevReady) ║
1099
- ║ {INIT.story.id} "{INIT.story.title}" ║
1100
- ╚══════════════════════════════════════════════════╝
1101
-
1102
- ! Implementation committed. Manual testing required.
1103
-
1104
- Status: DevReady
1105
- Commit: {COMMIT_HASH}
1106
- AC coverage: {covered}/{total} scenarios
1107
- Deviations: {count}
1108
- Wiki: skipped (waiting for Done)
1109
-
1110
- After manual testing:
1111
- > /ace:execute-story story={INIT.paths.story_file}
1112
- Re-run to promote to Done (will detect DevReady status
1113
- and skip directly to verification → approve as Done → wiki mapping).
1114
- ```
1115
- </variant>
1116
- </substep>
1117
-
1118
- </step>
1119
-
1120
- </process>
1121
-
1122
- <success_criteria>
1123
- <criterion>Init function executed (environment detected, story validated, paths computed)</criterion>
1124
- <criterion>Acceptance criteria present — STOPPED if missing</criterion>
1125
- <criterion>Technical solution present — STOPPED if missing</criterion>
1126
- <criterion>Plan Mode entered and execution plan created</criterion>
1127
- <criterion>User approved execution plan</criterion>
1128
- <criterion>Agent teams vs solo decision correctly made</criterion>
1129
- <criterion>Implementation executed following technical solution</criterion>
1130
- <criterion>Deviation rules applied correctly (Rules 1-3 auto, Rule 4 asks)</criterion>
1131
- <criterion>Self-verification passed (build, tests, file existence, imports)</criterion>
1132
- <criterion>Code review completed with zero blockers</criterion>
1133
- <criterion>All coding standards violations resolved (mandatory check)</criterion>
1134
- <criterion>Dead code and backwards-compatible shims DELETED (zero tolerance)</criterion>
1135
- <criterion>User verified and approved implementation</criterion>
1136
- <criterion>Story file updated with Summary &amp; State section</criterion>
1137
- <criterion>Story status updated in story file, feature file, product backlog</criterion>
1138
- <criterion>GitHub issue updated (if applicable)</criterion>
1139
- <criterion>Feature status updated to Done if all stories are Done</criterion>
1140
- <criterion>Wiki mapper dispatched (background) with tech debt integration</criterion>
1141
- <criterion>Wiki Updates section written to story file</criterion>
1142
- <criterion>ONE single commit created after everything is done (code + state + wiki)</criterion>
1143
- </success_criteria>
1144
-
1145
- </workflow>
1
+ <workflow>
2
+
3
+ <purpose>
4
+ Orchestrate story execution: load a fully-planned story (with AC + Technical Solution),
5
+ create an execution plan via Claude Code Plan Mode, execute the plan (solo or agent teams),
6
+ run code review, present results for user verification, update state across all ACE
7
+ artifacts, and trigger wiki mapping.
8
+
9
+ The story file IS the plan — AC + Technical Solution = the specification.
10
+ Claude Code Plan Mode creates a tactical execution plan on top of that.
11
+
12
+ Two execution modes:
13
+ - **Solo Mode** (default): Main plans → executor subagent implements (fresh 200k context)
14
+ - **Agent Teams Mode** (when enabled + assessment recommends it): Lead + teammates for parallel work
15
+
16
+ NO intermediary commits during implementation. Only ONE commit after user approval.
17
+ </purpose>
18
+
19
+ <mandatory-context>
20
+ Read all files referenced by the invoking command's execution-context before starting.
21
+ Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
22
+ </mandatory-context>
23
+
24
+ <process>
25
+
26
+ **STRICT STEP-BY-STEP EXECUTION. This workflow is NOT a reference document — it is a
27
+ script you MUST follow in order. Complete each step and ALL its substeps before moving
28
+ to the next step. Do NOT read ahead and freestyle. Do NOT explore the codebase or read
29
+ the story file before running the init command. Do NOT create your own plan or ask
30
+ "Shall I proceed?" — follow the workflow steps exactly as written.**
31
+
32
+ <!-- ══════════════════════════════════════════════════════════════════ -->
33
+ <!-- STEP 1: INIT & VALIDATE -->
34
+ <!-- ══════════════════════════════════════════════════════════════════ -->
35
+
36
+ <step name="init-and-validate" order="1">
37
+
38
+ **MANDATORY FIRST STEP — Run the init command (substep 1.2) BEFORE any other action.
39
+ Do NOT read the story file. Do NOT explore code. Do NOT start planning.
40
+ Run init FIRST, parse the output, THEN proceed through substeps 1.3-1.7 in order.**
41
+
42
+ <substep order="1.1" name="parse-arguments">
43
+ Parse `$ARGUMENTS` to extract:
44
+ - `story` (REQUIRED): file path or GitHub URL/issue number
45
+ - `--agent-teams-off` (OPTIONAL FLAG): force solo mode
46
+ </substep>
47
+
48
+ <substep order="1.2" name="run-init">
49
+ Execute environment detection:
50
+
51
+ ```bash
52
+ INIT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js init execute-story {story_param})
53
+ ```
54
+
55
+ Parse INIT JSON for:
56
+ - `executor_model`, `reviewer_model`
57
+ - `commit_docs`, `has_git`, `has_gh_cli`, `github_project`
58
+ - `agent_teams`
59
+ - `story_source`, `story_valid`, `story_error`, `story_content`
60
+ - `story` (id, title, status, size), `feature` (id, title), `epic` (id, title)
61
+ - `has_acceptance_criteria`, `acceptance_criteria_count`
62
+ - `has_technical_solution`, `has_wiki_refs`, `has_coding_standards`
63
+ - `paths.*`
64
+ </substep>
65
+
66
+ <substep order="1.3" name="display-banner">
67
+ ```
68
+ ╔══════════════════════════════════════════════════╗
69
+ ║ ACE > Execute Story ║
70
+ ╚══════════════════════════════════════════════════╝
71
+ ```
72
+
73
+ If `has_git` is false: `git init`
74
+ </substep>
75
+
76
+ <substep order="1.4" name="validate-story">
77
+ <validation-gate condition="INIT.story_valid is false">
78
+ Display `INIT.story_error` and STOP:
79
+ ```
80
+ x {INIT.story_error}
81
+ Provide a valid story file path or GitHub issue.
82
+ ```
83
+ </validation-gate>
84
+
85
+ <validation-gate condition="INIT.has_acceptance_criteria is false">
86
+ STOP:
87
+ ```
88
+ x Story has no acceptance criteria.
89
+ Run /ace:plan-story first to define AC scenarios.
90
+ ```
91
+ </validation-gate>
92
+
93
+ <validation-gate condition="INIT.has_technical_solution is false">
94
+ STOP:
95
+ ```
96
+ x Story has no technical solution.
97
+ Run /ace:plan-story first to generate the technical solution.
98
+ ```
99
+ </validation-gate>
100
+
101
+ <validation-gate condition="INIT.story.status is 'Done'">
102
+ STOP:
103
+ ```
104
+ x Story is already marked as Done. Nothing to execute.
105
+ ```
106
+ </validation-gate>
107
+
108
+ <validation-gate condition="INIT.story.status is 'DevReady'">
109
+ Story was previously implemented and approved as DevReady (pending manual testing).
110
+ Resuming from verification to allow promoting to Done.
111
+
112
+ ```
113
+ i Story status: DevReady — previously implemented, pending verification.
114
+ Resuming from verification (step 5.2).
115
+ Skipping planning, execution, and code review.
116
+ ```
117
+
118
+ Set `RESUME_FROM_DEVREADY = true`.
119
+ After displaying context (substep 1.7), jump DIRECTLY to step 5.2.
120
+ Skip substeps 1.5, 1.6 and steps 2, 3, 4, 5.1 entirely.
121
+ </validation-gate>
122
+ </substep>
123
+
124
+ <substep order="1.5" name="detect-existing-implementation">
125
+ First check if there are any uncommitted changes (staged or unstaged):
126
+ ```bash
127
+ git status --short
128
+ ```
129
+
130
+ <variant condition="git status output is EMPTY (no uncommitted changes)">
131
+ Fresh start — no uncommitted changes detected. Proceed normally to step 2.
132
+ </variant>
133
+
134
+ <variant condition="git status output is NOT EMPTY (uncommitted changes exist)">
135
+ Uncommitted changes detected. Check if they relate to this story's implementation.
136
+
137
+ Extract the list of expected files from the Technical Solution section
138
+ of the story file (component breakdown — file paths).
139
+
140
+ Check which of these files already exist in the working tree:
141
+ ```bash
142
+ for file in [expected_files_from_technical_solution]; do
143
+ [ -f "$file" ] &amp;&amp; echo "EXISTS: $file" || echo "MISSING: $file"
144
+ done
145
+ ```
146
+
147
+ <variant condition="ALL expected files exist">
148
+ ```
149
+ ! Implementation appears complete — all expected files exist.
150
+ Uncommitted changes detected in working tree.
151
+ ```
152
+
153
+ Display the file check results (EXISTS/MISSING for each expected file).
154
+
155
+ Use AskUserQuestion:
156
+ - header: "Resume?"
157
+ - question: "All files from the Technical Solution already exist and there are uncommitted changes. Is the implementation done? Do you want to skip to code review (step 4)?"
158
+ - options:
159
+ - "Yes, skip to review" — Implementation is done, continue from step 4 (code review → approval → state → wiki → commit)
160
+ - "No, start fresh" — Plan and execute from scratch (I'll handle the working tree)
161
+
162
+ <option value="Yes, skip to review">
163
+ Skip steps 2 and 3 entirely.
164
+ Jump DIRECTLY to step 4 (code review).
165
+ </option>
166
+ <option value="No, start fresh">
167
+ Proceed normally from step 2 (user is responsible for cleaning working tree).
168
+ </option>
169
+ </variant>
170
+
171
+ <variant condition="SOME expected files exist (partial implementation)">
172
+ ```
173
+ ! Partial implementation detected — some expected files exist.
174
+ ```
175
+
176
+ Display the file check results (EXISTS/MISSING for each expected file).
177
+
178
+ Use AskUserQuestion:
179
+ - header: "Resume?"
180
+ - question: "Some files from the Technical Solution already exist. What would you like to do?"
181
+ - options:
182
+ - "Continue from plan" — Create a plan that accounts for existing files
183
+ - "Start fresh" — Plan and execute from scratch (I'll handle the working tree)
184
+
185
+ <option value="Continue from plan">
186
+ Proceed to step 2. The plan must account for already-existing files
187
+ and only implement what's missing.
188
+ </option>
189
+ <option value="Start fresh">
190
+ Proceed normally from step 2 (user is responsible for cleaning working tree).
191
+ </option>
192
+ </variant>
193
+
194
+ <variant condition="NO expected files from Technical Solution exist">
195
+ Uncommitted changes exist but none match expected story files.
196
+ Proceed normally to step 2.
197
+ </variant>
198
+ </variant>
199
+ </substep>
200
+
201
+ <substep order="1.6" name="resolve-agent-teams">
202
+ <rule condition="--agent-teams-off flag present">Set `USE_AGENT_TEAMS = false` regardless of setting.</rule>
203
+ <rule condition="flag not present">Set `USE_AGENT_TEAMS = INIT.agent_teams`.</rule>
204
+ </substep>
205
+
206
+ <substep order="1.7" name="display-context">
207
+ ```
208
+ i Story: {INIT.story.id} — {INIT.story.title}
209
+ Feature: {INIT.feature.id} — {INIT.feature.title}
210
+ Status: {INIT.story.status} | Size: {INIT.story.size}
211
+ AC scenarios: {INIT.acceptance_criteria_count}
212
+ Technical solution: present
213
+ Agent teams: {USE_AGENT_TEAMS ? "enabled" : "disabled"}
214
+ ```
215
+ </substep>
216
+
217
+ </step>
218
+
219
+ <!-- ═══ CHECKPOINT: Step 1 MUST be complete. Init MUST have run. Banner MUST be displayed. Context MUST be shown. ═══ -->
220
+
221
+ <!-- ══════════════════════════════════════════════════════════════════ -->
222
+ <!-- STEP 2: LOAD CONTEXT & CHOOSE EXECUTION MODE -->
223
+ <!-- ══════════════════════════════════════════════════════════════════ -->
224
+
225
+ <step name="load-and-decide" order="2">
226
+
227
+ <substep order="2.1" name="display-banner">
228
+ ```
229
+ ┌──────────────────────────────────────────────────┐
230
+ │ ACE > Execute Story > Planning │
231
+ └──────────────────────────────────────────────────┘
232
+ ```
233
+ </substep>
234
+
235
+ <substep order="2.2" name="read-story-sections">
236
+ Read `INIT.paths.story_file` and extract:
237
+ - **Acceptance Criteria** — Gherkin scenarios (WHAT to build)
238
+ - **Technical Solution** — component breakdown, sequence diagrams (HOW)
239
+ - **Relevant Wiki** — file references for codebase context (WHERE)
240
+ - **Out of Scope** — explicit exclusions (what NOT to build)
241
+ - **Dependencies** — what must exist before this story
242
+ - **Definition of Done** — quality checklist
243
+ </substep>
244
+
245
+ <substep order="2.3" name="read-coding-standards">
246
+ <variant condition="INIT.has_coding_standards is true">
247
+ Read `INIT.paths.coding_standards` in full — coding standards are mandatory context.
248
+ </variant>
249
+ </substep>
250
+
251
+ <substep order="2.4" name="assess-and-choose-execution-mode">
252
+ **BEFORE any planning — analyze the story and ask the user to choose execution mode.**
253
+
254
+ Analyze the Technical Solution to assess complexity. Count ALL of the following signals:
255
+
256
+ <complexity-signals>
257
+ <signal weight="high" name="story-size">Story size >= 5 SP</signal>
258
+ <signal weight="high" name="file-count">Technical solution touches 6+ files</signal>
259
+ <signal weight="high" name="new-code-volume">Technical solution estimates 100+ new lines of code</signal>
260
+ <signal weight="high" name="implementation-phases">Technical solution defines 3+ implementation phases</signal>
261
+ <signal weight="medium" name="cross-cutting">Changes span multiple layers (state + UI + services + tests)</signal>
262
+ <signal weight="medium" name="complex-patterns">Story involves concurrency, cancellation, retry logic, race conditions, or state machines</signal>
263
+ <signal weight="medium" name="independent-components">Technical solution shows 3+ independent components that could be built in parallel</signal>
264
+ <signal weight="medium" name="ac-count">Story has 5+ acceptance criteria scenarios</signal>
265
+ <signal weight="low" name="multi-subsystem">Changes touch multiple backend/frontend subsystems via API calls</signal>
266
+ <signal weight="low" name="context-window-risk">Estimated implementation would exceed ~140k tokens (70% of 200k context)</signal>
267
+ </complexity-signals>
268
+
269
+ <assessment-rules>
270
+ **Recommend Agent Teams** when ANY of:
271
+ - 3+ HIGH signals present
272
+ - 2+ HIGH signals AND 2+ MEDIUM signals
273
+ - Story has independent components that can genuinely be built in parallel
274
+
275
+ **Recommend Solo** when:
276
+ - Mostly sequential work with tight dependencies between components
277
+ - Small story (1-3 SP) with few files
278
+ - Simple CRUD or single-file changes
279
+
280
+ **When in doubt → recommend Agent Teams.** It's better to have teammates
281
+ that finish early than a solo session that runs out of context window.
282
+ </assessment-rules>
283
+
284
+ **MANDATORY: Always present this choice to the user using AskUserQuestion — NEVER skip it, NEVER auto-decide.**
285
+
286
+ Present your complexity assessment summary, then ask:
287
+
288
+ <variant condition="USE_AGENT_TEAMS is true">
289
+ Use AskUserQuestion:
290
+ - header: "Execution"
291
+ - question: "How should this story be executed?\n\nComplexity: {count high/medium/low signals hit}\n{list the signals that matched}\n\nMy recommendation: {Solo|Agent Teams} because {reasoning}"
292
+ - options:
293
+ - "{Recommended option} (Recommended)" — with reasoning
294
+ - "{Other option}" — with reasoning
295
+ - The recommended option goes first with "(Recommended)" suffix
296
+ </variant>
297
+
298
+ <variant condition="USE_AGENT_TEAMS is false">
299
+ Agent teams are disabled by configuration. Use AskUserQuestion:
300
+ - header: "Execution"
301
+ - question: "Agent teams are disabled.\n\nComplexity: {count signals hit}\n{list the signals that matched}\n\nExecute in solo mode?"
302
+ - options:
303
+ - "Solo (Confirmed)" — proceed with solo execution
304
+ - "Enable Agent Teams" — I want agent teams for this story (override the setting)
305
+
306
+ <variant condition="user chose Enable Agent Teams">
307
+ Override: set `USE_AGENT_TEAMS = true` and re-present the full
308
+ Solo vs Agent Teams choice as in the variant above.
309
+ </variant>
310
+ </variant>
311
+
312
+ Store the user's choice as `EXECUTION_MODE` (solo | agent-teams).
313
+ </substep>
314
+
315
+ <!-- ─────────────────────────────────────────────────── -->
316
+ <!-- SOLO PATH: Main creates plan, executor agent runs -->
317
+ <!-- ─────────────────────────────────────────────────── -->
318
+
319
+ <substep order="2.5" name="solo-plan-mode" condition="EXECUTION_MODE is solo">
320
+ **BEFORE entering Plan Mode, display this highlighted warning to the user:**
321
+
322
+ ```
323
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
324
+ ┃ ⚠️ IMPORTANT — READ BEFORE EXITING PLAN MODE ┃
325
+ ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
326
+ ┃ ┃
327
+ ┃ When Claude Code wants to exit plan mode, do NOT choose ┃
328
+ ┃ the option with "clear context" no matter how filled ┃
329
+ ┃ the context is! This will interrupt our command! ┃
330
+ ┃ ┃
331
+ ┃ The implementation in solo mode is done by a different ┃
332
+ ┃ subagent with a fresh context window — no need to clear it. ┃
333
+ ┃ ┃
334
+ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
335
+ ```
336
+
337
+ Enter Plan Mode using the EnterPlanMode tool.
338
+
339
+ Feed into Plan Mode context:
340
+
341
+ ```
342
+ Create an execution plan for this story based on the technical solution.
343
+
344
+ STORY: {INIT.story.id} — {INIT.story.title}
345
+
346
+ ACCEPTANCE CRITERIA:
347
+ {extracted AC scenarios}
348
+
349
+ TECHNICAL SOLUTION:
350
+ {extracted technical solution}
351
+
352
+ RELEVANT WIKI:
353
+ {extracted wiki references}
354
+
355
+ CODING STANDARDS:
356
+ {full coding standards document}
357
+
358
+ OUT OF SCOPE:
359
+ {extracted out-of-scope items}
360
+ ```
361
+
362
+ <plan-rules>
363
+ <rule>Follow the technical solution's component breakdown and sequence diagrams</rule>
364
+ <rule>Each task must map to one or more AC scenarios</rule>
365
+ <rule>Include verification steps (tests, build checks) after implementation tasks</rule>
366
+ <rule>Follow coding standards from wiki</rule>
367
+ <rule>DO NOT implement anything outside the AC scenarios (respect Out of Scope)</rule>
368
+ <rule>NO intermediary commits — all changes accumulate as working tree changes</rule>
369
+ <rule>ONE commit happens AFTER user approval at the end</rule>
370
+ </plan-rules>
371
+
372
+ <deviation-rules>
373
+ <rule id="1" name="Auto-fix Bugs" approval="auto">Broken behavior, errors, type errors, security → fix inline, track as [Rule 1 - Bug]</rule>
374
+ <rule id="2" name="Auto-add Missing Critical" approval="auto">Missing validation, error handling, auth → add, track as [Rule 2 - Missing Critical]</rule>
375
+ <rule id="3" name="Auto-fix Blocking" approval="auto">Missing deps, broken imports, build errors → fix, track as [Rule 3 - Blocking]</rule>
376
+ <rule id="4" name="Architectural Changes" approval="user">New DB tables, switching libraries, breaking API → STOP and ask user</rule>
377
+ </deviation-rules>
378
+
379
+ <self-verification>
380
+ After each significant step:
381
+ - Build check: run build command — must pass
382
+ - Test check: run relevant tests — must pass
383
+ - File existence: verify created files exist
384
+ - Import check: verify new modules are imported/used where expected
385
+ </self-verification>
386
+ </substep>
387
+
388
+ <substep order="2.6" name="solo-approve-plan" condition="EXECUTION_MODE is solo">
389
+ User approves the plan (standard Plan Mode approval flow via ExitPlanMode).
390
+
391
+ After plan approval, **read the plan file** that Plan Mode created.
392
+ Store its contents as `APPROVED_PLAN` — this will be passed to the executor agent.
393
+
394
+ Proceed to step 3b (solo execution via executor agent).
395
+ </substep>
396
+
397
+ <!-- ─────────────────────────────────────────────────── -->
398
+ <!-- AGENT TEAMS PATH: Main stays out of Plan Mode -->
399
+ <!-- Teammates plan their own work — lead approves -->
400
+ <!-- ─────────────────────────────────────────────────── -->
401
+
402
+ <substep order="2.7" name="teams-task-decomposition" condition="EXECUTION_MODE is agent-teams">
403
+ **Main does NOT enter Plan Mode.** The Technical Solution IS the high-level plan.
404
+
405
+ Decompose the Technical Solution into teammate assignments:
406
+ - Identify 2-4 independent work streams from the implementation phases/components
407
+ - Assign each stream to a teammate role (e.g., "state-layer", "ui-layer", "integration", "tests")
408
+ - Map AC scenarios to teammates (each AC must be covered by at least one teammate)
409
+ - Identify shared interfaces/contracts between teammates
410
+ - Identify task dependencies (which teammate's work blocks another)
411
+
412
+ Present the team composition to the user using AskUserQuestion:
413
+ - header: "Team"
414
+ - question: "Proposed agent team:\n\n{for each teammate: role, files owned, tasks, AC coverage}\n\nDoes this look right?"
415
+ - options:
416
+ - "Approve team" — create the team as proposed
417
+ - "Adjust" — I want to change the team composition
418
+
419
+ <variant condition="user chose Adjust">
420
+ Ask what they want to change → adjust → re-present.
421
+ </variant>
422
+
423
+ Proceed to step 3a (agent teams execution).
424
+ </substep>
425
+
426
+ </step>
427
+
428
+ <!-- ═══ CHECKPOINT: Step 2 MUST be complete. Execution mode MUST be chosen via AskUserQuestion. Plan MUST be approved (solo) or team MUST be approved (teams). ═══ -->
429
+
430
+ <!-- ══════════════════════════════════════════════════════════════════ -->
431
+ <!-- STEP 3a: AGENT TEAMS EXECUTION -->
432
+ <!-- ══════════════════════════════════════════════════════════════════ -->
433
+
434
+ <step name="agent-teams-execution" order="3a">
435
+ **This step only runs when agent teams mode is selected.**
436
+ **Main (lead) does NOT enter Plan Mode — teammates plan their own work.**
437
+
438
+ <substep order="3a.1" name="display-banner">
439
+ ```
440
+ ┌──────────────────────────────────────────────────┐
441
+ │ ACE > Execute Story > Agent Teams │
442
+ └──────────────────────────────────────────────────┘
443
+
444
+ i Creating agent team for story implementation...
445
+ ```
446
+ </substep>
447
+
448
+ <substep order="3a.2" name="create-team">
449
+ **Safety net: if a leftover team exists from a crashed/interrupted previous run,
450
+ delete it first with TeamDelete before creating the new team.**
451
+
452
+ Create an agent team using the decomposition from step 2.7.
453
+
454
+ Tell Claude Code to create the team in natural language:
455
+
456
+ ```
457
+ Create an agent team for implementing story {INIT.story.id} — {INIT.story.title}.
458
+
459
+ Teammates:
460
+ {For each teammate from the approved decomposition:}
461
+ N. "{role}" {description of work}
462
+ Files owned: {list of files this teammate owns — NO overlap with other teammates}
463
+ Tasks: {task list from decomposition}
464
+ Require plan approval before they make any changes.
465
+
466
+ {If coding standards exist:}
467
+ N+1. "reviewer" — Review code written by other teammates
468
+ Watches for: TODOs, stubs, placeholders, hardcoded values, missing tests,
469
+ deviation from coding standards, missing error handling, dead code,
470
+ backwards-compatible shims.
471
+ Messages teammates directly when issues found.
472
+ Creates tasks in shared task list for issues requiring fixes.
473
+ Does a final sweep when all teammates are done.
474
+
475
+ All teammates must follow:
476
+ - Coding standards from {INIT.paths.coding_standards}
477
+ - Technical solution from story file
478
+ - NO intermediary commits — changes accumulate as working tree changes
479
+ - Deviation rules: auto-fix bugs/critical/blocking (Rules 1-3), STOP for architectural (Rule 4)
480
+
481
+ Only approve plans that:
482
+ - Follow the technical solution's component design exactly
483
+ - Include verification steps (build check, type check) after implementation
484
+ - Do NOT touch files owned by another teammate
485
+ - Map to AC scenarios from the story
486
+ ```
487
+
488
+ Each teammate enters plan mode automatically (via "Require plan approval").
489
+ The lead reviews and approves/rejects each teammate's plan autonomously.
490
+ </substep>
491
+
492
+ <substep order="3a.3" name="monitor-execution">
493
+ After plans are approved, teammates execute in parallel:
494
+
495
+ <task>Each teammate implements their approved plan</task>
496
+ <task>Teammates message each other for coordination on shared interfaces</task>
497
+ <task>Reviewer teammate monitors checks code as it's written, messages others about issues</task>
498
+ <task>User can interact with any teammate via `Shift+Down`</task>
499
+ <task>If lead starts implementing tasks itself, tell it: "Wait for your teammates to complete their tasks before proceeding"</task>
500
+ <task>When all teammates idle → lead collects results</task>
501
+ </substep>
502
+
503
+ <substep order="3a.4" name="final-verification">
504
+ After all teammates complete:
505
+ <task>Run `git status` to see all changes</task>
506
+ <task>Run build + test suite to verify everything works together</task>
507
+ <task>If build/tests fail → coordinate fixes with relevant teammate</task>
508
+
509
+ Proceed to step 4 (reviewer teammate's final sweep serves as the review).
510
+ </substep>
511
+
512
+ </step>
513
+
514
+ <!-- ═══ CHECKPOINT: Step 3a runs ONLY if agent-teams mode was chosen. Otherwise skip to 3b. ═══ -->
515
+
516
+ <!-- ══════════════════════════════════════════════════════════════════ -->
517
+ <!-- STEP 3b: SOLO EXECUTION -->
518
+ <!-- ══════════════════════════════════════════════════════════════════ -->
519
+
520
+ <step name="solo-execution" order="3b">
521
+ **This step runs when solo mode is selected.**
522
+ **Main spawns an executor subagent with a FRESH context window.**
523
+
524
+ <substep order="3b.1" name="display-banner">
525
+ ```
526
+ ┌──────────────────────────────────────────────────┐
527
+ ACE > Execute Story > Implementing │
528
+ └──────────────────────────────────────────────────┘
529
+
530
+ i Spawning executor agent with fresh context...
531
+ ```
532
+ </substep>
533
+
534
+ <substep order="3b.2" name="spawn-executor-agent">
535
+ Spawn a subagent to execute the approved plan in a **fresh 200k context window**.
536
+ The main session's context is preserved for post-implementation steps (review, state, wiki).
537
+
538
+ ```
539
+ Agent(
540
+ prompt="You are the ACE Story Executor. Implement this story by following
541
+ the approved execution plan EXACTLY.
542
+
543
+ STORY: {INIT.story.id} {INIT.story.title}
544
+ STORY FILE: {INIT.paths.story_file}
545
+
546
+ Read the story file to get the full Acceptance Criteria and Technical Solution.
547
+
548
+ {If INIT.has_coding_standards:}
549
+ CODING STANDARDS: {INIT.paths.coding_standards}
550
+ Read coding standards in full before starting implementation.
551
+
552
+ APPROVED EXECUTION PLAN:
553
+ {APPROVED_PLAN}
554
+
555
+ RULES:
556
+ - Follow the plan step by step do NOT skip steps or reorder
557
+ - After each significant step: run build check + test check
558
+ - NO commitsall changes stay as working tree changes
559
+ - Auto-fix bugs, missing critical code, and blocking issues (Rules 1-3)
560
+ - For architectural changes beyond story scope (Rule 4): STOP and include
561
+ in your return report main will ask the user
562
+ - Respect Out of Scope do NOT implement anything not in the AC
563
+
564
+ SELF-VERIFICATION (after ALL implementation is complete):
565
+ - Verify all key files from the plan exist
566
+ - Run full build — must pass
567
+ - Run full test suite must pass
568
+ - If verification fails, fix before returning
569
+
570
+ **Return format ONLY this, nothing else:**
571
+ IMPLEMENTATION COMPLETE
572
+ - Files created: {list}
573
+ - Files modified: {list}
574
+ - Build: {pass/fail}
575
+ - Tests: {pass/fail include test command and result}
576
+ - Deviations: {list of [Rule N] deviations, or 'None'}
577
+ - Rule 4 blockers: {list of architectural issues needing user decision, or 'None'}
578
+ - Notes: {anything the main session needs to know}",
579
+ subagent_type="general-purpose",
580
+ model="{INIT.executor_model}",
581
+ description="Execute {INIT.story.id}"
582
+ )
583
+ ```
584
+
585
+ Parse the executor's return report.
586
+ </substep>
587
+
588
+ <substep order="3b.3" name="handle-executor-result">
589
+ <variant condition="Rule 4 blockers reported">
590
+ The executor hit architectural issues it couldn't auto-resolve.
591
+ Present each blocker to the user:
592
+
593
+ ```
594
+ ! Executor reported architectural issue(s) requiring your decision:
595
+
596
+ {For each Rule 4 blocker:}
597
+ ? {description}
598
+ Proposed change: {what the executor wants to do}
599
+ Impact: {what it affects}
600
+ ```
601
+
602
+ Use AskUserQuestion for each blocker:
603
+ - header: "Rule 4"
604
+ - question: "{blocker description} approve this change?"
605
+ - options:
606
+ - "Approve" — allow the change
607
+ - "Reject" find an alternative approach
608
+ - "Reject and stop" stop implementation entirely
609
+
610
+ If approved: spawn a follow-up executor agent to apply the approved changes.
611
+ If rejected: spawn a follow-up executor agent with alternative instructions.
612
+ If stopped: proceed to step 5 with partial implementation for user review.
613
+ </variant>
614
+
615
+ <variant condition="Build or tests failed">
616
+ ```
617
+ x Executor reported build/test failures.
618
+ Spawning follow-up agent to fix...
619
+ ```
620
+ Spawn a follow-up executor agent focused on fixing the failures.
621
+ Include the failure output in the prompt.
622
+ </variant>
623
+
624
+ <variant condition="All clear — implementation complete">
625
+ Proceed to step 4 (code review).
626
+ </variant>
627
+ </substep>
628
+
629
+ <substep order="3b.4" name="no-intermediary-commits">
630
+ **CRITICAL: Do NOT commit during implementation.**
631
+ All changes accumulate as working tree changes (unstaged/staged).
632
+ Only ONE commit happens after user approval in step 5.
633
+
634
+ Store the executor's deviation list for the Summary &amp; State section.
635
+ </substep>
636
+
637
+ </step>
638
+
639
+ <!-- ═══ CHECKPOINT: Implementation MUST be complete (step 3a or 3b). Executor report MUST be parsed. ═══ -->
640
+
641
+ <!-- ══════════════════════════════════════════════════════════════════ -->
642
+ <!-- STEP 4: CODE REVIEW -->
643
+ <!-- ══════════════════════════════════════════════════════════════════ -->
644
+
645
+ <step name="code-review" order="4">
646
+
647
+ <substep order="4.1" name="display-banner">
648
+ ```
649
+ ┌──────────────────────────────────────────────────┐
650
+ ACE > Execute Story > Code Review │
651
+ └──────────────────────────────────────────────────┘
652
+
653
+ i Running code review...
654
+ ```
655
+ </substep>
656
+
657
+ <substep order="4.2" name="determine-review-mode">
658
+ <variant condition="Agent Teams mode">
659
+ The reviewer teammate's final sweep serves as the review.
660
+ Skip the subagent spawn — use the reviewer teammate's report.
661
+ If the reviewer has already flagged and resolved all issues, proceed to step 5.
662
+ </variant>
663
+
664
+ <variant condition="Solo mode">
665
+ Dispatch /ace:review-story as a subagent (see substep 4.3).
666
+ </variant>
667
+ </substep>
668
+
669
+ <substep order="4.3" name="dispatch-review-story">
670
+ **Solo mode only.** Dispatch the review-story command:
671
+
672
+ ```
673
+ Agent(
674
+ prompt="/ace:review-story story={INIT.paths.story_file}
675
+
676
+ Execute the review-story workflow end-to-end.
677
+
678
+ **Return format — ONLY this, nothing else:**
679
+ REVIEW COMPLETE
680
+ Status: {passed | issues_found}
681
+ - Blockers: {count}
682
+ - Warnings: {count}
683
+ - Files reviewed: {count}
684
+ - Artifacts verified: {passed}/{total} (3-level)
685
+ - AC coverage: {covered}/{total} scenarios
686
+ - Tech debt items discovered: {count}
687
+
688
+ [Blocker list with file:line, description, severity, suggested fix]
689
+ [Warning list with file:line, description, severity, suggested fix]
690
+ [Tech debt list in YAML format]",
691
+ subagent_type="ace-code-reviewer",
692
+ model="{INIT.reviewer_model}",
693
+ description="Code review for {INIT.story.id}"
694
+ )
695
+ ```
696
+ </substep>
697
+
698
+ <substep order="4.4" name="fix-verify-loop">
699
+ **If blockers found → auto-fix cycle:**
700
+
701
+ <loop max-iterations="3">
702
+ <task>Review reports blockers</task>
703
+ <task>Fix them (deviation rules 1-3 apply — most blocker fixes are auto-approved)</task>
704
+ <task>Re-run review (focused on previously-failed items only)</task>
705
+ <task>Repeat until zero blockers</task>
706
+ </loop>
707
+
708
+ <escalation condition="blockers persist after 3 rounds">
709
+ Escalate to user (Rule 4 behavior).
710
+ </escalation>
711
+
712
+ Warnings don't block — they're presented to user alongside verification.
713
+ Each fix round is tracked as a deviation in the summary.
714
+ Store the code review results (including tech debt YAML) for later steps.
715
+ </substep>
716
+
717
+ </step>
718
+
719
+ <!-- ═══ CHECKPOINT: Code review MUST be complete with zero blockers before proceeding. ═══ -->
720
+
721
+ <!-- ══════════════════════════════════════════════════════════════════ -->
722
+ <!-- STEP 5: USER VERIFICATION & COMMIT -->
723
+ <!-- ══════════════════════════════════════════════════════════════════ -->
724
+
725
+ <step name="user-verification" order="5">
726
+
727
+ <substep order="5.1" name="display-verification">
728
+ <variant condition="RESUME_FROM_DEVREADY is true">
729
+ ```
730
+ ╔══════════════════════════════════════════════════╗
731
+ ║ ACE > Execute Story > Verification ║
732
+ ╚══════════════════════════════════════════════════╝
733
+
734
+ Story: {INIT.story.id} {INIT.story.title}
735
+
736
+ Previously implemented and marked DevReady.
737
+ Ready to promote to Done after manual verification.
738
+ ```
739
+ </variant>
740
+
741
+ <variant condition="RESUME_FROM_DEVREADY is false (normal execution)">
742
+ ```
743
+ ╔══════════════════════════════════════════════════╗
744
+ ║ ACE > Execute Story > Verification ║
745
+ ╚══════════════════════════════════════════════════╝
746
+
747
+ Story: {INIT.story.id} — {INIT.story.title}
748
+
749
+ Implementation complete. Please verify:
750
+
751
+ Acceptance Criteria Walkthrough:
752
+ ────────────────────────────────
753
+ 1. ✓ {scenario name} — [auto-verified: tests pass]
754
+ 2. ? {scenario name} — [needs manual check: {instructions}]
755
+ ...
756
+
757
+ Code Review Results:
758
+ ────────────────────
759
+ ✓ No blockers found
760
+ {⚠ N warning(s): {brief descriptions}}
761
+
762
+ Deviations:
763
+ ────────────
764
+ {deviation list or "None — plan executed as written"}
765
+ ```
766
+ </variant>
767
+ </substep>
768
+
769
+ <substep order="5.2" name="ask-user">
770
+ <variant condition="RESUME_FROM_DEVREADY is true">
771
+ Use AskUserQuestion:
772
+ - header: "Verify"
773
+ - question: "Story was previously implemented as DevReady. Has manual testing passed?"
774
+ - options:
775
+ - "Approve (Done)" — Manual testing passed, promote to Done
776
+ - "Fix issues" Something still needs to be changed
777
+
778
+ <option value="Fix issues">
779
+ Ask what needs fixing → apply fixes (deviation rules apply) →
780
+ return to this verification prompt.
781
+ </option>
782
+
783
+ <option value="Approve (Done)">
784
+ Set `FINAL_STATUS = Done`.
785
+ Proceed to step 6 (state updates) → step 7 (wiki + commit).
786
+ </option>
787
+ </variant>
788
+
789
+ <variant condition="RESUME_FROM_DEVREADY is false (normal execution)">
790
+ Use AskUserQuestion:
791
+ - header: "Verify"
792
+ - question: "Implementation and code review complete. Does everything look correct?"
793
+ - options:
794
+ - "Approve (Done)" — All AC verified, mark story as Done
795
+ - "Approve (DevReady)" — Implementation done but I need to test manually first
796
+ - "Fix issues" Something needs to be changed
797
+
798
+ <option value="Fix issues">
799
+ Ask what needs fixing → apply fixes (deviation rules apply) →
800
+ re-run code review (focused) → return to verification prompt.
801
+ </option>
802
+
803
+ <option value="Approve (Done)">
804
+ Set `FINAL_STATUS = Done`.
805
+ Proceed to step 6 (state updates) → step 7 (wiki + commit).
806
+ </option>
807
+
808
+ <option value="Approve (DevReady)">
809
+ Set `FINAL_STATUS = DevReady`.
810
+
811
+ Present manual testing instructions:
812
+ ```
813
+ ! Manual testing required before wiki mapping.
814
+ The following scenarios need manual verification:
815
+
816
+ {For each AC scenario that was NOT auto-verified by tests:}
817
+ ? {scenario name}
818
+ How to test: {step-by-step manual test instructions}
819
+
820
+ After testing, run /ace:execute-story again with this story.
821
+ It will detect DevReady status and skip directly to verification.
822
+ ```
823
+
824
+ **DevReady path: skip wiki, commit code + state only.**
825
+ Proceed to step 6 (state updates) → step 7.6 (commit) directly.
826
+ Do NOT run step 7.1-7.5 (wiki mapping) — the code may still change
827
+ after manual testing. Wiki mapping happens when the story reaches Done.
828
+ </option>
829
+ </variant>
830
+ </substep>
831
+
832
+ </step>
833
+
834
+ <!-- ═══ CHECKPOINT: User MUST have approved via AskUserQuestion (Done or DevReady). ═══ -->
835
+
836
+ <!-- ══════════════════════════════════════════════════════════════════ -->
837
+ <!-- STEP 6: STATE UPDATES -->
838
+ <!-- ══════════════════════════════════════════════════════════════════ -->
839
+
840
+ <step name="state-updates" order="6">
841
+
842
+ <substep order="6.1" name="display-banner">
843
+ ```
844
+ ┌──────────────────────────────────────────────────┐
845
+ │ ACE > Execute Story > State Updates │
846
+ └──────────────────────────────────────────────────┘
847
+ ```
848
+ </substep>
849
+
850
+ <substep order="6.2" name="write-summary-section">
851
+ Write `## Summary &amp; State` section into the story file at the
852
+ `&lt;section name="summary-and-state"&gt;` location:
853
+
854
+ ```markdown
855
+ ## Summary &amp; State
856
+
857
+ **Status**: {FINAL_STATUS}
858
+ **Executed**: {current date YYYY-MM-DD}
859
+ **Duration**: {execution duration}
860
+
861
+ ### Implementation Summary
862
+ {Substantive one-liner e.g., "OAuth buttons with Google/GitHub using next-auth providers"}
863
+
864
+ ### Commits
865
+ | # | Hash | Type | Description |
866
+ |---|---------|----------|--------------------------------------|
867
+ | 1 | {hash} | feat | {description} |
868
+
869
+ ### Deviations
870
+ {None — plan executed as written}
871
+ OR
872
+ {1. [Rule N] description of deviation}
873
+
874
+ ### Code Review
875
+ - Blockers found: {count} (all resolved)
876
+ - Warnings: {count}
877
+ - AC coverage: {covered}/{total} scenarios
878
+ - Tech debt discovered: {count} items
879
+ ```
880
+ </substep>
881
+
882
+ <substep order="6.3" name="update-state-via-tools">
883
+ ```bash
884
+ node ~/.claude/agile-context-engineering/src/ace-tools.js story update-state \
885
+ story={INIT.paths.story_file} \
886
+ status={FINAL_STATUS}
887
+ ```
888
+
889
+ Parse result for: `story_updated`, `feature_updated`, `backlog_updated`, `feature_status_changed`.
890
+
891
+ ```
892
+ + Story status updated to {FINAL_STATUS}
893
+ {+ Feature file updated (if feature_updated)}
894
+ {+ Product backlog updated (if backlog_updated)}
895
+ {+ Feature status changed to Done! (if feature_status_changed)}
896
+ ```
897
+ </substep>
898
+
899
+ <substep order="6.4" name="update-github">
900
+ <variant condition="INIT.github_project.enabled is false OR INIT.has_gh_cli is false">
901
+ ```
902
+ — GitHub sync skipped (not configured or gh CLI unavailable).
903
+ ```
904
+ </variant>
905
+
906
+ <variant condition="INIT.github_project.enabled is true AND INIT.has_gh_cli is true">
907
+ Sync story and feature GitHub issues in a single call.
908
+ This command prints status lines directly to the console (stderr)
909
+ so the user ALWAYS sees whether each issue was updated or not.
910
+
911
+ ```bash
912
+ node ~/.claude/agile-context-engineering/src/ace-tools.js github sync-story \
913
+ repo={INIT.github_project.repo} \
914
+ story_file={INIT.paths.story_file} \
915
+ feature_file={INIT.paths.feature_file} \
916
+ owner={INIT.github_project.owner} \
917
+ project={INIT.github_project.project_number}
918
+ ```
919
+
920
+ The command handles all cases:
921
+ - Story/feature has no GitHub issue linked → prints skip message
922
+ - Update succeeds → prints success message with issue number
923
+ - Update fails → prints error message with details
924
+ </variant>
925
+ </substep>
926
+
927
+ </step>
928
+
929
+ <!-- ═══ CHECKPOINT: State updates MUST be complete (story, feature, backlog, GitHub). ═══ -->
930
+
931
+ <!-- ══════════════════════════════════════════════════════════════════ -->
932
+ <!-- STEP 7: WIKI UPDATE -->
933
+ <!-- ══════════════════════════════════════════════════════════════════ -->
934
+
935
+ <step name="wiki-and-commit" order="7">
936
+
937
+ <!-- ─────────────────────────────────────────────────── -->
938
+ <!-- WIKI MAPPING: Only when FINAL_STATUS = Done -->
939
+ <!-- DevReady skips straight to commit (7.6) -->
940
+ <!-- ─────────────────────────────────────────────────── -->
941
+
942
+ <substep order="7.1" name="display-banner" condition="FINAL_STATUS is Done">
943
+ ```
944
+ ┌──────────────────────────────────────────────────┐
945
+ ACE > Execute Story > Wiki Update │
946
+ └──────────────────────────────────────────────────┘
947
+
948
+ i Wiki mapper running (background agent)...
949
+ ```
950
+ </substep>
951
+
952
+ <substep order="7.2" name="dispatch-map-story" condition="FINAL_STATUS is Done">
953
+ Dispatch /ace:map-story as a background agent.
954
+ Pass tech debt from the code review output as a parameter — map-story
955
+ handles all tech debt integration (wiki docs + index).
956
+
957
+ **CRITICAL — Context Window Protection:**
958
+ The agent writes directly to wiki files and returns ONLY a confirmation.
959
+ Do NOT call TaskOutput on the background agent — it pollutes the main context.
960
+
961
+ ```
962
+ Agent(
963
+ prompt="/ace:map-story story-context={INIT.paths.story_file} tech-debt=\"{tech_debt_yaml from code review output}\"
964
+
965
+ Execute the map-story workflow end-to-end.
966
+
967
+ **Return format ONLY this, nothing else:**
968
+ WIKI UPDATE COMPLETE
969
+ - Updated: {list of updated wiki docs}
970
+ - Created: {list of new wiki docs}
971
+ - Tech debt integrated: {count} items across {count} wiki docs
972
+ - No change needed: {list}
973
+ WALKTHROUGH SUGGESTIONS
974
+ - FLOW: {flow description} | SUBSYSTEM: {name} | EMPHASIS: {frameworks or none} | REASON: {why}
975
+ [or: WALKTHROUGH SUGGESTIONS: none]",
976
+ subagent_type="ace-wiki-mapper",
977
+ run_in_background=true,
978
+ description="Wiki update for {INIT.story.id}"
979
+ )
980
+ ```
981
+
982
+ Store the agent task ID as `WIKI_TASK`.
983
+ </substep>
984
+
985
+ <substep order="7.3" name="wait-for-wiki-completion" condition="FINAL_STATUS is Done">
986
+ **BLOCKING WAIT Do NOT proceed to substep 7.4 until the wiki mapper has finished.**
987
+
988
+ Poll using TaskGet until the background agent completes:
989
+ ```
990
+ Loop (max 60 iterations, 10 second intervals):
991
+ TaskGet(id=WIKI_TASK)
992
+ If status is "completed" → break, proceed to 7.4
993
+ If status is "failed" → log warning, proceed to 7.4 (commit without wiki)
994
+ Otherwise → continue polling
995
+ ```
996
+
997
+ Once complete, verify wiki files exist:
998
+ ```bash
999
+ git status --short .docs/wiki/
1000
+ ```
1001
+
1002
+ Read the agent result to extract walkthrough suggestions. The return format
1003
+ is compact — it will NOT pollute the context window.
1004
+
1005
+ Parse the result for the `WALKTHROUGH SUGGESTIONS` section.
1006
+ Store as WALKTHROUGH_SUGGESTIONS (list of { flow, subsystem, emphasis, reason }).
1007
+ If "none" or not found, set WALKTHROUGH_SUGGESTIONS = empty.
1008
+ </substep>
1009
+
1010
+ <substep order="7.4" name="write-wiki-updates-section" condition="FINAL_STATUS is Done">
1011
+ Write `## Wiki Updates` section into the story file:
1012
+
1013
+ ```markdown
1014
+ ## Wiki Updates
1015
+
1016
+ **Updated**: {current date}
1017
+
1018
+ | Document | Action | Path |
1019
+ |----------|--------|------|
1020
+ | {doc name} | Updated | {path} |
1021
+ | {doc name} | Created | {path} |
1022
+ | {doc name} | No change | {path} |
1023
+ ```
1024
+ </substep>
1025
+
1026
+ <substep order="7.5" name="update-github-with-wiki" condition="FINAL_STATUS is Done">
1027
+ <variant condition="INIT.github_project.enabled is true AND INIT.has_gh_cli is true">
1028
+ Update GitHub issues again (story file now includes the Wiki Updates section):
1029
+
1030
+ ```bash
1031
+ node ~/.claude/agile-context-engineering/src/ace-tools.js github sync-story \
1032
+ repo={INIT.github_project.repo} \
1033
+ story_file={INIT.paths.story_file} \
1034
+ feature_file={INIT.paths.feature_file} \
1035
+ owner={INIT.github_project.owner} \
1036
+ project={INIT.github_project.project_number}
1037
+ ```
1038
+ </variant>
1039
+ </substep>
1040
+
1041
+ <!-- ─────────────────────────────────────────────────── -->
1042
+ <!-- WALKTHROUGHS: Offer suggestions from map-story -->
1043
+ <!-- ─────────────────────────────────────────────────── -->
1044
+
1045
+ <substep order="7.5.1" name="offer-walkthroughs" condition="FINAL_STATUS is Done AND WALKTHROUGH_SUGGESTIONS is not empty">
1046
+ Present walkthrough suggestions to the user.
1047
+
1048
+ Display:
1049
+ ```
1050
+ i Potential walkthroughs detected from this story's code:
1051
+
1052
+ [For each suggestion, numbered:]
1053
+ [N]. [flow description]
1054
+ Subsystem: [subsystem] | Emphasis: [frameworks or "none"]
1055
+ [reason]
1056
+ ```
1057
+
1058
+ Use AskUserQuestion:
1059
+ - header: "Walkthroughs"
1060
+ - question: "Would you like to create any of these walkthroughs?\nYou can also describe your own."
1061
+ - options:
1062
+ - "Create [numbers]" — e.g., "Create 1,3" or "Create all"
1063
+ - "Custom" — user describes their own walkthrough
1064
+ - "Skip" — no walkthroughs
1065
+
1066
+ **If "Skip":** Continue to commit.
1067
+
1068
+ **If "Create [numbers]" or "Create all":**
1069
+ For each selected suggestion, spawn a background agent:
1070
+
1071
+ ```
1072
+ Agent(
1073
+ prompt="/ace:map-walkthrough flow=\"{suggestion.flow}\" subsystem=\"{suggestion.subsystem}\" emphasis-frameworks=\"{suggestion.emphasis}\"
1074
+
1075
+ Execute the map-walkthrough workflow end-to-end.",
1076
+ subagent_type="ace-wiki-mapper",
1077
+ run_in_background=true,
1078
+ description="Walkthrough: {short flow name}"
1079
+ )
1080
+ ```
1081
+
1082
+ **If "Custom":**
1083
+ Ask the user for their flow description, subsystem, and optional emphasis-frameworks.
1084
+ Spawn a background agent for that walkthrough too.
1085
+
1086
+ Wait for all walkthrough agents to complete.
1087
+
1088
+ Display:
1089
+ ```
1090
+ + [N] walkthrough(s) created.
1091
+ [For each: path and line count]
1092
+ ```
1093
+
1094
+ Stage walkthrough files:
1095
+ ```bash
1096
+ git add .docs/wiki/subsystems/*/walkthroughs/
1097
+ ```
1098
+ </substep>
1099
+
1100
+ <!-- ─────────────────────────────────────────────────── -->
1101
+ <!-- COMMIT: Always runs (both Done and DevReady) -->
1102
+ <!-- ─────────────────────────────────────────────────── -->
1103
+
1104
+ <substep order="7.6" name="create-story-commit">
1105
+ **ONE single commit for the entire story — code + state {+ wiki if Done}.**
1106
+
1107
+ Stage all files individually (NEVER `git add .` or `git add -A`):
1108
+ ```bash
1109
+ git status --short
1110
+ git add {each implementation file}
1111
+ git add {INIT.paths.story_file} {INIT.paths.feature_file} .ace/artifacts/product/product-backlog.md
1112
+ ```
1113
+
1114
+ <variant condition="FINAL_STATUS is Done">
1115
+ Also stage wiki files:
1116
+ ```bash
1117
+ git add .docs/wiki/
1118
+ ```
1119
+ </variant>
1120
+
1121
+ Commit with conventional format:
1122
+ ```
1123
+ feat({INIT.story.id}): {INIT.story.title}
1124
+
1125
+ - {key change 1}
1126
+ - {key change 2}
1127
+ - {key change 3}
1128
+ ```
1129
+
1130
+ Record commit hash:
1131
+ ```bash
1132
+ COMMIT_HASH=$(git rev-parse --short HEAD)
1133
+ ```
1134
+
1135
+ ```
1136
+ + Story committed: {COMMIT_HASH}
1137
+ ```
1138
+ </substep>
1139
+
1140
+ <substep order="7.7" name="cleanup-agent-team" condition="EXECUTION_MODE is agent-teams">
1141
+ **Clean up the agent team so future stories can create a new one.**
1142
+ Delete the active team using TeamDelete. This prevents the
1143
+ "already leading team" error on the next /ace:execute-story run.
1144
+ </substep>
1145
+
1146
+ <substep order="7.8" name="display-completion">
1147
+ <variant condition="FINAL_STATUS is Done">
1148
+ ```
1149
+ ╔══════════════════════════════════════════════════╗
1150
+ ║ ACE > Story Executed ║
1151
+ ║ {INIT.story.id} "{INIT.story.title}" ║
1152
+ ╚══════════════════════════════════════════════════╝
1153
+
1154
+ + Story execution complete.
1155
+
1156
+ Status: Done
1157
+ Commit: {COMMIT_HASH}
1158
+ AC coverage: {covered}/{total} scenarios
1159
+ Deviations: {count}
1160
+ Wiki docs updated: {count}
1161
+
1162
+ Next > /ace:execute-story story={next story path}
1163
+ Execute the next story in the feature.
1164
+ > /ace:plan-story story={next story path}
1165
+ Plan the next story.
1166
+ ```
1167
+ </variant>
1168
+
1169
+ <variant condition="FINAL_STATUS is DevReady">
1170
+ ```
1171
+ ╔══════════════════════════════════════════════════╗
1172
+ ║ ACE > Story Implemented (DevReady) ║
1173
+ ║ {INIT.story.id} "{INIT.story.title}" ║
1174
+ ╚══════════════════════════════════════════════════╝
1175
+
1176
+ ! Implementation committed. Manual testing required.
1177
+
1178
+ Status: DevReady
1179
+ Commit: {COMMIT_HASH}
1180
+ AC coverage: {covered}/{total} scenarios
1181
+ Deviations: {count}
1182
+ Wiki: skipped (waiting for Done)
1183
+
1184
+ After manual testing:
1185
+ > /ace:execute-story story={INIT.paths.story_file}
1186
+ Re-run to promote to Done (will detect DevReady status
1187
+ and skip directly to verification → approve as Done → wiki mapping).
1188
+ ```
1189
+ </variant>
1190
+ </substep>
1191
+
1192
+ </step>
1193
+
1194
+ </process>
1195
+
1196
+ <success_criteria>
1197
+ <criterion>Init function executed (environment detected, story validated, paths computed)</criterion>
1198
+ <criterion>Acceptance criteria present — STOPPED if missing</criterion>
1199
+ <criterion>Technical solution present — STOPPED if missing</criterion>
1200
+ <criterion>Plan Mode entered and execution plan created</criterion>
1201
+ <criterion>User approved execution plan</criterion>
1202
+ <criterion>Agent teams vs solo decision correctly made</criterion>
1203
+ <criterion>Implementation executed following technical solution</criterion>
1204
+ <criterion>Deviation rules applied correctly (Rules 1-3 auto, Rule 4 asks)</criterion>
1205
+ <criterion>Self-verification passed (build, tests, file existence, imports)</criterion>
1206
+ <criterion>Code review completed with zero blockers</criterion>
1207
+ <criterion>All coding standards violations resolved (mandatory check)</criterion>
1208
+ <criterion>Dead code and backwards-compatible shims DELETED (zero tolerance)</criterion>
1209
+ <criterion>User verified and approved implementation</criterion>
1210
+ <criterion>Story file updated with Summary &amp; State section</criterion>
1211
+ <criterion>Story status updated in story file, feature file, product backlog</criterion>
1212
+ <criterion>GitHub issue updated (if applicable)</criterion>
1213
+ <criterion>Feature status updated to Done if all stories are Done</criterion>
1214
+ <criterion>Wiki mapper dispatched (background) with tech debt integration</criterion>
1215
+ <criterion>Wiki Updates section written to story file</criterion>
1216
+ <criterion>ONE single commit created after everything is done (code + state + wiki)</criterion>
1217
+ </success_criteria>
1218
+
1219
+ </workflow>