agile-context-engineering 0.5.0 → 0.5.1

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