agile-context-engineering 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +272 -78
  3. package/agents/ace-code-discovery-analyst.md +245 -0
  4. package/agents/ace-code-integration-analyst.md +248 -0
  5. package/agents/ace-code-reviewer.md +375 -0
  6. package/agents/ace-product-owner.md +361 -0
  7. package/agents/ace-project-researcher.md +606 -0
  8. package/agents/ace-research-synthesizer.md +228 -0
  9. package/agents/ace-technical-application-architect.md +287 -0
  10. package/agents/ace-wiki-mapper.md +334 -0
  11. package/agile-context-engineering/src/ace-tools.js +2881 -0
  12. package/agile-context-engineering/src/ace-tools.test.js +1089 -0
  13. package/agile-context-engineering/templates/_command.md +54 -0
  14. package/agile-context-engineering/templates/_workflow.xml +17 -0
  15. package/agile-context-engineering/templates/config.json +0 -0
  16. package/agile-context-engineering/templates/product/external-solution.xml +832 -0
  17. package/agile-context-engineering/templates/product/feature.xml +361 -0
  18. package/agile-context-engineering/templates/product/integration-solution.xml +0 -0
  19. package/agile-context-engineering/templates/product/product-backlog.xml +231 -0
  20. package/agile-context-engineering/templates/product/product-vision.xml +227 -0
  21. package/agile-context-engineering/templates/product/story-integration-solution.xml +1014 -0
  22. package/agile-context-engineering/templates/product/story-technical-solution.xml +1025 -0
  23. package/agile-context-engineering/templates/product/story-wiki.xml +190 -0
  24. package/agile-context-engineering/templates/product/story.xml +451 -0
  25. package/agile-context-engineering/templates/wiki/coding-standards.xml +493 -0
  26. package/agile-context-engineering/templates/wiki/decizions.xml +115 -0
  27. package/agile-context-engineering/templates/wiki/guide.xml +137 -0
  28. package/agile-context-engineering/templates/wiki/module-discovery.xml +174 -0
  29. package/agile-context-engineering/templates/wiki/pattern.xml +159 -0
  30. package/agile-context-engineering/templates/wiki/subsystem-architecture.xml +343 -0
  31. package/agile-context-engineering/templates/wiki/subsystem-structure.xml +235 -0
  32. package/agile-context-engineering/templates/wiki/system-architecture.xml +254 -0
  33. package/agile-context-engineering/templates/wiki/system-cross-cutting.xml +197 -0
  34. package/agile-context-engineering/templates/wiki/system-structure.xml +178 -0
  35. package/agile-context-engineering/templates/wiki/system.xml +381 -0
  36. package/agile-context-engineering/templates/wiki/tech-debt-index.xml +125 -0
  37. package/agile-context-engineering/templates/wiki/testing-framework.xml +283 -0
  38. package/agile-context-engineering/utils/questioning.xml +111 -0
  39. package/agile-context-engineering/utils/ui-formatting.md +300 -0
  40. package/agile-context-engineering/workflows/execute-story.xml +1145 -0
  41. package/agile-context-engineering/workflows/help.xml +540 -0
  42. package/agile-context-engineering/workflows/init-coding-standards.xml +386 -0
  43. package/agile-context-engineering/workflows/map-story.xml +797 -0
  44. package/agile-context-engineering/workflows/map-subsystem.xml +1177 -0
  45. package/agile-context-engineering/workflows/map-system.xml +647 -0
  46. package/agile-context-engineering/workflows/plan-backlog.xml +1356 -0
  47. package/agile-context-engineering/workflows/plan-feature.xml +1495 -0
  48. package/agile-context-engineering/workflows/plan-product-vision.xml +342 -0
  49. package/agile-context-engineering/workflows/plan-story.xml +909 -0
  50. package/agile-context-engineering/workflows/research-external-solution.xml +659 -0
  51. package/agile-context-engineering/workflows/research-integration-solution.xml +712 -0
  52. package/agile-context-engineering/workflows/research-story-wiki.xml +474 -0
  53. package/agile-context-engineering/workflows/research-technical-solution.xml +762 -0
  54. package/agile-context-engineering/workflows/review-story.xml +281 -0
  55. package/bin/install.js +102 -166
  56. package/commands/ace/execute-story.md +137 -0
  57. package/commands/ace/help.md +93 -0
  58. package/commands/ace/init-coding-standards.md +83 -0
  59. package/commands/ace/map-story.md +156 -0
  60. package/commands/ace/map-subsystem.md +138 -0
  61. package/commands/ace/map-system.md +90 -0
  62. package/commands/ace/plan-backlog.md +83 -0
  63. package/commands/ace/plan-feature.md +89 -0
  64. package/commands/ace/plan-product-vision.md +81 -0
  65. package/commands/ace/plan-story.md +145 -0
  66. package/commands/ace/research-external-solution.md +138 -0
  67. package/commands/ace/research-integration-solution.md +135 -0
  68. package/commands/ace/research-story-wiki.md +116 -0
  69. package/commands/ace/research-technical-solution.md +147 -0
  70. package/commands/ace/review-story.md +109 -0
  71. package/package.json +5 -8
  72. package/agents/executor.md +0 -88
  73. package/agents/planner.md +0 -78
  74. package/agents/researcher.md +0 -77
  75. package/agents/verifier.md +0 -116
  76. package/commands/ace-execute-story.md +0 -114
  77. package/commands/ace-init.md +0 -254
  78. package/commands/ace-plan-epic.md +0 -79
  79. package/commands/ace-plan-feature.md +0 -78
  80. package/commands/ace-plan-project.md +0 -205
  81. package/commands/ace-plan-story.md +0 -97
  82. package/commands/ace-refine-story.md +0 -90
  83. package/commands/ace-verify-story.md +0 -127
@@ -0,0 +1,647 @@
1
+ <workflow>
2
+
3
+ <purpose>
4
+ Orchestrate system-wide wiki mapping: detect environment, determine which documents need
5
+ creation or updates, spawn ace-wiki-mapper agents to produce them, and optionally add
6
+ CLAUDE.md instructions to keep the wiki current.
7
+
8
+ Produces documents in `.docs/wiki/system-wide/`:
9
+ - system-structure.md — physical layout, subsystem index, shared directories
10
+ - testing-framework.md — test runner, patterns, conventions
11
+ - system-architecture.md — L1/L2 views, core flows, tech stack
12
+
13
+ Brownfield projects get documents filled from codebase analysis.
14
+ Greenfield projects get system-architecture.md via deep questioning (structure and testing
15
+ are scaffolded with headings only — filled as code is added).
16
+ </purpose>
17
+
18
+ <mandatory-context>
19
+ Read all files referenced by the invoking command's execution-context before starting.
20
+ Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
21
+ </mandatory-context>
22
+
23
+ <process>
24
+
25
+ <!-- ══════════════════════════════════════════════════════════════════ -->
26
+ <!-- STEP 1: SETUP -->
27
+ <!-- ══════════════════════════════════════════════════════════════════ -->
28
+
29
+ <step name="setup" order="1">
30
+ **MANDATORY FIRST STEP — Execute environment detection before any user interaction:**
31
+
32
+ ```bash
33
+ INIT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js init map-system)
34
+ ```
35
+
36
+ Parse JSON for: `mapper_model`, `commit_docs`, `is_brownfield`, `is_greenfield`,
37
+ `has_existing_code`, `has_package_file`, `wiki_dir_exists`, `existing_wiki_files`,
38
+ `has_system_structure`, `has_system_architecture`, `has_testing_framework`,
39
+ `has_coding_standards`, `has_git`.
40
+
41
+ Also resolve the mapper model for spawning agents:
42
+ ```bash
43
+ MAPPER_MODEL=$(node ~/.claude/agile-context-engineering/src/ace-tools.js resolve-model ace-wiki-mapper --raw)
44
+ ```
45
+
46
+ Display stage banner:
47
+
48
+ ```
49
+ ╔══════════════════════════════════════════════════╗
50
+ ║ ACE > Map System ║
51
+ ╚══════════════════════════════════════════════════╝
52
+ ```
53
+
54
+ **If `has_git` is false:** Initialize git:
55
+ ```bash
56
+ git init
57
+ ```
58
+
59
+ Continue to step 2 (document triage).
60
+ </step>
61
+
62
+ <!-- ══════════════════════════════════════════════════════════════════ -->
63
+ <!-- STEP 2: DOCUMENT TRIAGE -->
64
+ <!-- Determine per-document action: create, update, recreate, or skip -->
65
+ <!-- ══════════════════════════════════════════════════════════════════ -->
66
+
67
+ <step name="document-triage" order="2">
68
+
69
+ Build a **document action plan** — a list of `{ document, action }` entries where
70
+ action is one of: `create`, `update`, `recreate`, `scaffold`, `skip`.
71
+
72
+ Evaluate each document independently:
73
+
74
+ <!-- ── system-structure.md ────────────────────────────────────── -->
75
+
76
+ **system-structure.md:**
77
+
78
+ If `is_greenfield`:
79
+ - Action: `scaffold` — create with headings and placeholder sections.
80
+ The document will be filled as subsystems are added.
81
+
82
+ If `is_brownfield` AND `has_system_structure` is false:
83
+ - Action: `create` — analyze codebase and produce full document.
84
+
85
+ If `is_brownfield` AND `has_system_structure` is true:
86
+ - Use AskUserQuestion:
87
+ - header: "Structure"
88
+ - question: "System structure document already exists at `.docs/wiki/system-wide/system-structure.md`. What would you like to do?"
89
+ - options:
90
+ - "Update" — Refresh the existing document with current codebase state
91
+ - "Recreate" — Discard and rebuild from scratch
92
+ - "Skip" — Keep the current document as-is
93
+ - Map user choice to action: `update`, `recreate`, or `skip`.
94
+
95
+ <!-- ── testing-framework.md ───────────────────────────────────── -->
96
+
97
+ **testing-framework.md:**
98
+
99
+ If `is_greenfield`:
100
+ - Action: `scaffold` — create with headings and placeholder sections.
101
+ Filled once a test framework is chosen and tests are written.
102
+
103
+ If `is_brownfield` AND `has_testing_framework` is false:
104
+ - Action: `create` — analyze codebase and produce full document.
105
+
106
+ If `is_brownfield` AND `has_testing_framework` is true:
107
+ - Use AskUserQuestion:
108
+ - header: "Testing"
109
+ - question: "Testing framework document already exists at `.docs/wiki/system-wide/testing-framework.md`. What would you like to do?"
110
+ - options:
111
+ - "Update" — Refresh the existing document with current codebase state
112
+ - "Recreate" — Discard and rebuild from scratch
113
+ - "Skip" — Keep the current document as-is
114
+ - Map user choice to action: `update`, `recreate`, or `skip`.
115
+
116
+ <!-- ── system-architecture.md ─────────────────────────────────── -->
117
+
118
+ **system-architecture.md:**
119
+
120
+ If `is_greenfield`:
121
+ - Action: `create_with_interview` — requires deep questioning before writing.
122
+ Cannot be scaffolded because architecture decisions must be made upfront.
123
+
124
+ If `is_brownfield` AND `has_system_architecture` is false:
125
+ - Action: `create` — analyze codebase and produce full document.
126
+
127
+ If `is_brownfield` AND `has_system_architecture` is true:
128
+ - Use AskUserQuestion:
129
+ - header: "Architecture"
130
+ - question: "System architecture document already exists at `.docs/wiki/system-wide/system-architecture.md`. What would you like to do?"
131
+ - options:
132
+ - "Update" — Refresh the existing document with current codebase state
133
+ - "Recreate" — Discard and rebuild from scratch
134
+ - "Skip" — Keep the current document as-is
135
+ - Map user choice to action: `update`, `recreate`, or `skip`.
136
+
137
+ **IMPORTANT:** Ask all questions that need asking in a SINGLE AskUserQuestion call
138
+ where possible (up to 4 questions). If multiple documents exist, batch the questions.
139
+
140
+ Display the action plan to the user:
141
+
142
+ ```
143
+ ┌──────────────────────────────────────────────────┐
144
+ │ ACE > Map System > Action Plan │
145
+ └──────────────────────────────────────────────────┘
146
+
147
+ Document Action
148
+ ──────────────────────── ──────────
149
+ system-structure.md [create/update/recreate/scaffold/skip]
150
+ testing-framework.md [create/update/recreate/scaffold/skip]
151
+ system-architecture.md [create/update/recreate/scaffold/skip/create_with_interview]
152
+ ```
153
+
154
+ If ALL actions are `skip`, exit workflow with message:
155
+ ```
156
+ i All documents already exist and were skipped. Nothing to do.
157
+
158
+ Next > `/clear` first for a fresh context window, then:
159
+
160
+ /ace:map-subsystems
161
+ Map individual subsystem internals.
162
+ ```
163
+
164
+ Continue to step 3 (create directory structure).
165
+ </step>
166
+
167
+ <!-- ══════════════════════════════════════════════════════════════════ -->
168
+ <!-- STEP 3: CREATE DIRECTORY STRUCTURE -->
169
+ <!-- ══════════════════════════════════════════════════════════════════ -->
170
+
171
+ <step name="create-directories" order="3">
172
+ Create the wiki directory if it doesn't exist:
173
+
174
+ ```bash
175
+ mkdir -p .docs/wiki/system-wide
176
+ ```
177
+
178
+ Continue to step 4.
179
+ </step>
180
+
181
+ <!-- ══════════════════════════════════════════════════════════════════ -->
182
+ <!-- STEP 4: SYSTEM STRUCTURE -->
183
+ <!-- ══════════════════════════════════════════════════════════════════ -->
184
+
185
+ <step name="system-structure" order="4">
186
+ Skip this step if system-structure action is `skip`.
187
+
188
+ **If action is `scaffold` (greenfield):**
189
+
190
+ Create an empty file:
191
+
192
+ ```bash
193
+ touch .docs/wiki/system-wide/system-structure.md
194
+ ```
195
+
196
+ It will be filled by `/ace:map-system` once source code exists.
197
+
198
+ **If action is `create` or `recreate`:**
199
+
200
+ Spawn ace-wiki-mapper agent:
201
+
202
+ ```
203
+ Task(
204
+ prompt="Focus: system-structure
205
+
206
+ Analyze this codebase and produce the system-wide structure document.
207
+
208
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/system-structure.xml
209
+ **Output:** Write to .docs/wiki/system-wide/system-structure.md
210
+
211
+ Follow the template structure. Fill every section with real data from the codebase.
212
+ Identify all subsystems (microservices, monolith modules, or library packages).
213
+
214
+ Return confirmation only — do NOT return document contents.",
215
+ subagent_type="ace-wiki-mapper",
216
+ model="{MAPPER_MODEL}",
217
+ description="Map system structure"
218
+ )
219
+ ```
220
+
221
+ **If action is `update`:**
222
+
223
+ Spawn ace-wiki-mapper agent with existing content as context:
224
+
225
+ ```
226
+ Task(
227
+ prompt="Focus: system-structure
228
+
229
+ UPDATE the existing system structure document.
230
+
231
+ **Current document:** Read .docs/wiki/system-wide/system-structure.md
232
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/system-structure.xml
233
+
234
+ Compare the current document against the actual codebase state.
235
+ Update sections that are stale. Add new subsystems or shared directories
236
+ that were added since the document was written. Remove entries for
237
+ deleted subsystems or directories.
238
+
239
+ Preserve accurate content. Only change what's actually stale.
240
+
241
+ Write the updated file to .docs/wiki/system-wide/system-structure.md
242
+ Return confirmation only — do NOT return document contents.",
243
+ subagent_type="ace-wiki-mapper",
244
+ model="{MAPPER_MODEL}",
245
+ description="Update system structure"
246
+ )
247
+ ```
248
+
249
+ Continue to step 5.
250
+ </step>
251
+
252
+ <!-- ══════════════════════════════════════════════════════════════════ -->
253
+ <!-- STEP 5: TESTING FRAMEWORK -->
254
+ <!-- ══════════════════════════════════════════════════════════════════ -->
255
+
256
+ <step name="testing-framework" order="5">
257
+ Skip this step if testing-framework action is `skip`.
258
+
259
+ **NOTE:** This step can run IN PARALLEL with step 4 (system-structure) if both
260
+ need agent work. Use `run_in_background=true` for the agents in steps 4 and 5,
261
+ then collect results before step 6.
262
+
263
+ **If action is `scaffold` (greenfield):**
264
+
265
+ Create an empty file:
266
+
267
+ ```bash
268
+ touch .docs/wiki/system-wide/testing-framework.md
269
+ ```
270
+
271
+ It will be filled by `/ace:map-system` once tests exist.
272
+
273
+ **If action is `create` or `recreate`:**
274
+
275
+ Spawn ace-wiki-mapper agent:
276
+
277
+ ```
278
+ Task(
279
+ prompt="Focus: testing-framework
280
+
281
+ Analyze this codebase and produce the testing framework document.
282
+
283
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/testing-framework.xml
284
+ **Output:** Write to .docs/wiki/system-wide/testing-framework.md
285
+
286
+ Check package.json/config files for test runner and scripts.
287
+ Read 3-5 existing test files for patterns.
288
+ Look for test utilities, fixtures, factories.
289
+ If NO tests exist, write a minimal document noting 'No tests found'
290
+ instead of a document full of placeholders.
291
+
292
+ Return confirmation only — do NOT return document contents.",
293
+ subagent_type="ace-wiki-mapper",
294
+ model="{MAPPER_MODEL}",
295
+ description="Map testing framework"
296
+ )
297
+ ```
298
+
299
+ **If action is `update`:**
300
+
301
+ Spawn ace-wiki-mapper agent with update instructions:
302
+
303
+ ```
304
+ Task(
305
+ prompt="Focus: testing-framework
306
+
307
+ UPDATE the existing testing framework document.
308
+
309
+ **Current document:** Read .docs/wiki/system-wide/testing-framework.md
310
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/testing-framework.xml
311
+
312
+ Compare against current codebase state. Update stale sections only.
313
+ Check for new test runner config, new test patterns, changed coverage settings.
314
+
315
+ Write the updated file to .docs/wiki/system-wide/testing-framework.md
316
+ Return confirmation only — do NOT return document contents.",
317
+ subagent_type="ace-wiki-mapper",
318
+ model="{MAPPER_MODEL}",
319
+ description="Update testing framework"
320
+ )
321
+ ```
322
+
323
+ Continue to step 6 (wait for parallel agents from steps 4-5 if applicable).
324
+ </step>
325
+
326
+ <!-- ══════════════════════════════════════════════════════════════════ -->
327
+ <!-- STEP 5.5: COLLECT PARALLEL RESULTS -->
328
+ <!-- ══════════════════════════════════════════════════════════════════ -->
329
+
330
+ <step name="collect-parallel" order="5.5">
331
+ If steps 4 and 5 spawned background agents, wait for both to complete.
332
+ Read each agent's output to collect confirmations.
333
+
334
+ If any agent failed, note the failure and inform the user.
335
+ Do NOT re-attempt — let the user decide.
336
+
337
+ Continue to step 6.
338
+ </step>
339
+
340
+ <!-- ══════════════════════════════════════════════════════════════════ -->
341
+ <!-- STEP 6: SYSTEM ARCHITECTURE -->
342
+ <!-- ══════════════════════════════════════════════════════════════════ -->
343
+
344
+ <step name="system-architecture" order="6">
345
+ Skip this step if system-architecture action is `skip`.
346
+
347
+ <!-- ── 6a: BROWNFIELD CREATE / RECREATE ──────────────────────── -->
348
+
349
+ **If action is `create` or `recreate` AND `is_brownfield`:**
350
+
351
+ Spawn ace-wiki-mapper agent directly (codebase provides all the answers):
352
+
353
+ ```
354
+ Task(
355
+ prompt="Focus: system-architecture
356
+
357
+ Analyze this codebase and produce the system-wide architecture document.
358
+
359
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/system-architecture.xml
360
+ **Output:** Write to .docs/wiki/system-wide/system-architecture.md
361
+
362
+ **Also read (if it exists):** .docs/wiki/system-wide/system-structure.md
363
+ — use the subsystem index from the structure doc to inform the L2 container diagram
364
+ and subsystem responsibility matrix. Do NOT duplicate content.
365
+
366
+ Follow the template structure. Fill every section with real data.
367
+ Generate C4 L1 and L2 Mermaid diagrams.
368
+ Trace 1-2 core flows as sequence diagrams.
369
+ Catalog the tech stack from actual dependency files (versions from lock files).
370
+
371
+ Return confirmation only — do NOT return document contents.",
372
+ subagent_type="ace-wiki-mapper",
373
+ model="{MAPPER_MODEL}",
374
+ description="Map system architecture"
375
+ )
376
+ ```
377
+
378
+ <!-- ── 6b: BROWNFIELD UPDATE ─────────────────────────────────── -->
379
+
380
+ **If action is `update`:**
381
+
382
+ Spawn ace-wiki-mapper agent with update instructions:
383
+
384
+ ```
385
+ Task(
386
+ prompt="Focus: system-architecture
387
+
388
+ UPDATE the existing system architecture document.
389
+
390
+ **Current document:** Read .docs/wiki/system-wide/system-architecture.md
391
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/system-architecture.xml
392
+ **Also read (if it exists):** .docs/wiki/system-wide/system-structure.md
393
+
394
+ Compare against current codebase state. Check:
395
+ - New subsystems or removed subsystems?
396
+ - New external integrations?
397
+ - Tech stack changes (new frameworks, version bumps)?
398
+ - Core flow shape changes?
399
+
400
+ Update only stale sections. Preserve accurate content.
401
+
402
+ Write the updated file to .docs/wiki/system-wide/system-architecture.md
403
+ Return confirmation only — do NOT return document contents.",
404
+ subagent_type="ace-wiki-mapper",
405
+ model="{MAPPER_MODEL}",
406
+ description="Update system architecture"
407
+ )
408
+ ```
409
+
410
+ <!-- ── 6c: GREENFIELD — DEEP QUESTIONING ─────────────────────── -->
411
+
412
+ **If action is `create_with_interview` (greenfield):**
413
+
414
+ Architecture cannot be inferred from code that doesn't exist yet.
415
+ Conduct a deep questioning session to gather architecture decisions.
416
+
417
+ Follow the questioning guide from `questioning.xml`. You are a thinking partner
418
+ helping the user articulate their system architecture.
419
+
420
+ **Opening:**
421
+ ```
422
+ ┌──────────────────────────────────────────────────┐
423
+ │ ACE > Map System > Architecture Interview │
424
+ └──────────────────────────────────────────────────┘
425
+
426
+ This is a greenfield project — no codebase to analyze.
427
+ I need to understand your architecture plans to create
428
+ the system-architecture document.
429
+ ```
430
+
431
+ **Key areas to explore (adapt based on conversation, don't checklist):**
432
+
433
+ 1. **System purpose**
434
+ "In 2-3 sentences, what does this system do and who uses it?"
435
+
436
+ 2. **Subsystem breakdown**
437
+ "What are the major components/services/modules?"
438
+ Use AskUserQuestion:
439
+ - header: "Topology"
440
+ - question: "What's your deployment topology?"
441
+ - options:
442
+ - "Monolith" — Single deployable with internal modules
443
+ - "Microservices" — Multiple independently deployed services
444
+ - "Monorepo packages" — Multiple packages in one repo
445
+ - "Hybrid" — Mix of approaches
446
+
447
+ 3. **External integrations**
448
+ "What external systems will this integrate with?"
449
+ (databases, auth providers, third-party APIs, message brokers)
450
+
451
+ 4. **Communication patterns**
452
+ If multiple subsystems: "How will they communicate?"
453
+ - Sync (HTTP/gRPC) vs Async (events/queues) vs Hybrid
454
+
455
+ 5. **Tech stack**
456
+ "What technologies are you using?"
457
+ Use AskUserQuestion:
458
+ - header: "Backend"
459
+ - question: "What's your primary backend technology?"
460
+ - options: (adapt to context, e.g., "Node.js/TypeScript", "C#/.NET", "Python", "Go")
461
+
462
+ Follow up for: frontend, database, cache, messaging if applicable.
463
+
464
+ 6. **Key architectural decisions**
465
+ "Any architectural patterns you're committed to?"
466
+ (Clean Architecture, CQRS, Event Sourcing, etc.)
467
+
468
+ **Decision gate:**
469
+ When you understand the architecture:
470
+ - header: "Ready?"
471
+ - question: "I have enough to create your architecture document. Ready to generate?"
472
+ - options:
473
+ - "Generate" — Create the document
474
+ - "Keep exploring" — I have more to share
475
+
476
+ Loop until "Generate" selected.
477
+
478
+ **Then prepare a context brief (300-500 words) that distills:**
479
+ - System purpose and users
480
+ - Subsystem breakdown (names, responsibilities)
481
+ - External integrations (what, direction, protocol)
482
+ - Communication patterns between subsystems
483
+ - Tech stack with expected versions
484
+ - Key architectural decisions
485
+
486
+ **Spawn the ace-wiki-mapper agent with the interview context:**
487
+
488
+ ```
489
+ Task(
490
+ prompt="Focus: system-architecture
491
+
492
+ Create the system-wide architecture document for a GREENFIELD project.
493
+
494
+ **Architecture brief from user interview:**
495
+ {paste the context brief here}
496
+
497
+ **Template:** Read ~/.claude/agile-context-engineering/templates/wiki/system-architecture.xml
498
+ **Output:** Write to .docs/wiki/system-wide/system-architecture.md
499
+
500
+ **Also read (if it exists):** .docs/wiki/system-wide/system-structure.md
501
+
502
+ Follow the template structure. Generate Mermaid C4 diagrams based on the
503
+ interview data. For greenfield, subsystem boxes in L2 may be planned but
504
+ not yet implemented — that's fine, document the intended architecture.
505
+
506
+ Return confirmation only — do NOT return document contents.",
507
+ subagent_type="ace-wiki-mapper",
508
+ model="{MAPPER_MODEL}",
509
+ description="Write system architecture (greenfield)"
510
+ )
511
+ ```
512
+
513
+ Continue to step 7.
514
+ </step>
515
+
516
+ <!-- ══════════════════════════════════════════════════════════════════ -->
517
+ <!-- STEP 7: CLAUDE.MD INSTRUCTIONS -->
518
+ <!-- ══════════════════════════════════════════════════════════════════ -->
519
+
520
+ <step name="claude-md-instructions" order="7">
521
+ **Add wiki maintenance instructions to CLAUDE.md** so that future code changes
522
+ trigger wiki updates.
523
+
524
+ Check if `CLAUDE.md` exists at project root. If not, create it.
525
+ If it exists, append the wiki section only if it's not already present.
526
+
527
+ Search for "Wiki Maintenance" in CLAUDE.md. If found, skip this step.
528
+
529
+ **Content to add:**
530
+
531
+ ```markdown
532
+
533
+ ## Wiki Maintenance
534
+
535
+ When adding, removing, or renaming files or directories:
536
+ - Update `.docs/wiki/system-wide/system-structure.md` if the change affects subsystem boundaries, shared directories, or root config files.
537
+ - Update `.docs/wiki/subsystems/[subsystem-name]/structure.md` for any subsystem where files changed.
538
+
539
+ When adding a new subsystem, external integration, or changing communication patterns:
540
+ - Update `.docs/wiki/system-wide/system-architecture.md`.
541
+
542
+ When changing test framework, runner, mocking approach, or coverage config:
543
+ - Update `.docs/wiki/system-wide/testing-framework.md`.
544
+ ```
545
+
546
+ Continue to step 8.
547
+ </step>
548
+
549
+ <!-- ══════════════════════════════════════════════════════════════════ -->
550
+ <!-- STEP 8: VERIFY AND COMMIT -->
551
+ <!-- ══════════════════════════════════════════════════════════════════ -->
552
+
553
+ <step name="verify-and-commit" order="8">
554
+ **Verify all expected documents exist and are non-empty:**
555
+
556
+ For each document where the action was NOT `skip`:
557
+ - Check file exists
558
+ - Check file has content (>5 lines for scaffold, >20 lines for create/update/recreate)
559
+
560
+ If any document is missing or empty, warn the user.
561
+
562
+ **Security scan** before commit — use the Grep tool (NOT bash grep):
563
+
564
+ ```
565
+ Grep(
566
+ pattern="(sk-[a-zA-Z0-9]{20,}|sk_live_|sk_test_|ghp_[a-zA-Z0-9]{36}|AKIA[A-Z0-9]{16}|-----BEGIN.*PRIVATE KEY)",
567
+ path=".docs/wiki/system-wide/",
568
+ glob="*.md",
569
+ output_mode="content"
570
+ )
571
+ ```
572
+
573
+ If matches found: SECRETS_FOUND — pause and alert user.
574
+ If no matches: CLEAN.
575
+
576
+ If SECRETS_FOUND: pause and alert user before committing.
577
+
578
+ **Commit** (if `commit_docs` is true):
579
+
580
+ ```bash
581
+ git add .docs/wiki/system-wide/
582
+ ```
583
+
584
+ If CLAUDE.md was created or updated:
585
+ ```bash
586
+ git add CLAUDE.md
587
+ ```
588
+
589
+ ```bash
590
+ git commit -m "docs: map system-wide wiki documents"
591
+ ```
592
+
593
+ Continue to step 9.
594
+ </step>
595
+
596
+ <!-- ══════════════════════════════════════════════════════════════════ -->
597
+ <!-- STEP 9: COMPLETION -->
598
+ <!-- ══════════════════════════════════════════════════════════════════ -->
599
+
600
+ <step name="completion" order="9">
601
+ Display completion banner and next steps.
602
+
603
+ ```
604
+ ╔══════════════════════════════════════════════════╗
605
+ ║ ACE > System Mapped ║
606
+ ╚══════════════════════════════════════════════════╝
607
+
608
+ Documents:
609
+ ──────────
610
+ [For each document, show action taken and line count]
611
+ + system-structure.md ([N] lines) — [created/updated/recreated/scaffolded]
612
+ + testing-framework.md ([N] lines) — [created/updated/recreated/scaffolded]
613
+ + system-architecture.md ([N] lines) — [created/updated/recreated/scaffolded]
614
+ - [document] skipped
615
+
616
+ i Wiki maintenance rules added to CLAUDE.md.
617
+
618
+ Next > `/clear` first for a fresh context window, then:
619
+
620
+ /ace:map-subsystems
621
+ Map individual subsystem internals.
622
+
623
+ Also available (`/clear` first):
624
+ - /ace:init-coding-standards — Define coding standards
625
+ - /ace:map-system — Re-run this command to refresh
626
+ - Review files in .docs/wiki/system-wide/
627
+ ```
628
+
629
+ End workflow.
630
+ </step>
631
+
632
+ </process>
633
+
634
+ <success_criteria>
635
+ - Init function executed (brownfield/greenfield detected, document existence checked)
636
+ - Each document triaged independently (create/update/recreate/scaffold/skip)
637
+ - Greenfield: structure and testing scaffolded, architecture created via interview
638
+ - Brownfield: all documents created/updated by ace-wiki-mapper agents
639
+ - Agents spawned in parallel where possible (structure + testing)
640
+ - CLAUDE.md updated with wiki maintenance instructions
641
+ - All created documents verified for content (non-empty, non-placeholder for brownfield)
642
+ - Security scan passed (no secrets in generated docs)
643
+ - Documents committed to .docs/wiki/system-wide/
644
+ - User sees clear completion summary and next steps
645
+ </success_criteria>
646
+
647
+ </workflow>