owflow 0.1.4 → 0.1.6

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 (42) hide show
  1. package/README.md +34 -21
  2. package/dist/__tests__/verify_template.test.js +102 -0
  3. package/dist/agents/task-classifier.md +7 -19
  4. package/dist/commands/diagrams-mermaid.md +37 -0
  5. package/dist/commands/html-renderer.md +37 -0
  6. package/dist/commands/quick-dev.md +48 -6
  7. package/dist/commands/quick-plan.md +39 -4
  8. package/dist/commands/work.md +13 -17
  9. package/dist/index.js +4 -0
  10. package/dist/skills/development/SKILL.md +98 -115
  11. package/dist/skills/diagrams-mermaid/SKILL.md +156 -0
  12. package/dist/skills/diagrams-mermaid/references/reference.md +148 -0
  13. package/dist/skills/flow-init/SKILL.md +15 -0
  14. package/dist/skills/html-renderer/SKILL.md +159 -0
  15. package/dist/skills/html-renderer/references/index.html +318 -0
  16. package/dist/skills/html-renderer/references/styles.css +388 -0
  17. package/dist/skills/html-renderer/references/tokens.json +104 -0
  18. package/dist/skills/migration/SKILL.md +14 -33
  19. package/dist/skills/orchestrator-framework/references/orchestrator-creation-checklist.md +1 -0
  20. package/dist/skills/orchestrator-framework/references/orchestrator-patterns.md +4 -59
  21. package/dist/skills/performance/SKILL.md +14 -30
  22. package/dist/skills/quick-bugfix/SKILL.md +96 -26
  23. package/dist/skills/research/SKILL.md +11 -42
  24. package/dist/templates/orchestrator-state-base.yml +17 -0
  25. package/dist/templates/orchestrator-state-development.yml +94 -0
  26. package/dist/templates/orchestrator-state-migration.yml +55 -0
  27. package/dist/templates/orchestrator-state-performance.yml +53 -0
  28. package/dist/templates/orchestrator-state-research.yml +61 -0
  29. package/dist/templates/quick-bugfix-task.yml +10 -0
  30. package/dist/templates/quick-dev-task.yml +10 -0
  31. package/dist/templates/quick-plan-task.yml +11 -0
  32. package/dist/tools/verify_template.js +61 -0
  33. package/package.json +4 -3
  34. package/dist/agents/ui-mockup-generator.md +0 -369
  35. package/dist/commands/product-design.md +0 -37
  36. package/dist/skills/product-design/SKILL.md +0 -843
  37. package/dist/skills/product-design/references/characteristic-detection.md +0 -92
  38. package/dist/skills/product-design/references/interaction-patterns.md +0 -206
  39. package/dist/skills/product-design/references/visual-companion.md +0 -190
  40. package/dist/skills/product-design/server/index.js +0 -302
  41. package/dist/skills/product-design/server/index.ts +0 -359
  42. package/dist/skills/product-design/server/template.html +0 -256
@@ -18,7 +18,7 @@ Unified workflow for all development tasks — bug fixes, enhancements, and new
18
18
 
19
19
  1. `../orchestrator-framework/references/orchestrator-patterns.md` - Delegation rules, interactive mode, state schema, initialization, context passing, issue resolution
20
20
 
21
- ### Step 2: Detect Research Context
21
+ ### Step 2: Detect Prior Work Context
22
22
 
23
23
  **If argument is a research folder path** (matches `.owflow/tasks/research/*`):
24
24
 
@@ -32,11 +32,39 @@ Unified workflow for all development tasks — bug fixes, enhancements, and new
32
32
  - Copy to `analysis/research-context/`
33
33
  - Set `research_reference` in state
34
34
 
35
+ **If argument is a quick-\* task folder path** (matches `.owflow/tasks/quick-*/`):
36
+
37
+ 1. Read `task.yml` — extract `command`, `description`, `standards_applied`, `escalation_reason`
38
+ 2. Read `analysis/findings.md` — extract root cause, affected files, complexity assessment, test strategy
39
+ 3. Use `description` as the task description (same as research extracts `research_question`)
40
+ 4. Set `quick_reference` in orchestrator state:
41
+ ```yaml
42
+ task_context:
43
+ quick_reference:
44
+ path: .owflow/tasks/quick-bugfix/2026-05-28-fix-login-timeout
45
+ command: quick-bugfix
46
+ escalation_reason: "5+ files, unclear root cause"
47
+ phase_summaries:
48
+ quick_analysis:
49
+ { summary: "...", affected_files: [...], root_cause: "..." }
50
+ ```
51
+ 5. Update the quick-\* `task.yml`: set `escalated_to` to the new development task path
52
+
53
+ **How quick-\* context informs development phases**:
54
+
55
+ | Phase | How Quick-\* Context is Used |
56
+ | ------- | --------------------------------------------------------------------------- |
57
+ | Phase 1 | Codebase analyzer receives affected files and root cause as search guidance |
58
+ | Phase 2 | Gap analyzer uses complexity assessment for risk level |
59
+ | Phase 3 | TDD gate uses test strategy from findings.md as starting point |
60
+ | Phase 4 | Specification creator receives prior analysis as input context |
61
+
35
62
  ### Step 3: Initialize Workflow
36
63
 
37
64
  1. **Create Task Items**: Use `TaskCreate` for all phases (see Phase Configuration), then set dependencies with `TaskUpdate addBlockedBy`
38
65
  2. **Create Task Directory**: `.owflow/tasks/development/YYYY-MM-DD-task-name/`
39
66
  3. **Initialize State**: Create `orchestrator-state.yml` with task info and research reference
67
+ - **CRITICAL**: Use the `verify_template` tool immediately after creation to check YAML validity against `orchestrator-state-development.yml`.
40
68
  4. **Discover project documentation**: Read `.owflow/docs/INDEX.md` (if exists), extract ALL file paths from the "Project Documentation" section. This includes predefined docs (vision, roadmap, tech-stack, architecture) AND any user-added project docs (e.g., deployment.md, api-strategy.md). Store complete list as `project_context.project_doc_paths` in state.
41
69
 
42
70
  **Output**:
@@ -67,17 +95,16 @@ Use for **all development tasks**: bug fixes, enhancements, new features, and an
67
95
  | 1 | "Analyze codebase & clarify requirements" | "Analyzing codebase & clarifying" | Always |
68
96
  | 2 | "Analyze gaps & clarify scope" | "Analyzing gaps & clarifying scope" | Always |
69
97
  | 3 | "Write failing test (TDD Red)" | "Writing failing test" | When `has_reproducible_defect` |
70
- | 4 | "Generate UI mockups" | "Generating UI mockups" | When `ui_heavy` |
71
- | 5 | "Gather requirements & create specification" | "Gathering requirements & creating specification" | Always |
72
- | 6 | "Audit specification" | "Auditing specification" | Always (conditional) |
73
- | 7 | "Plan implementation" | "Planning implementation" | Always |
74
- | 8 | "Execute implementation" | "Executing implementation" | Always |
75
- | 9 | "Verify test passes (TDD Green)" | "Verifying test passes" | When Phase 3 was executed |
76
- | 10 | "Prompt verification options" | "Prompting verification options" | Always |
77
- | 11 | "Verify implementation & resolve issues" | "Verifying implementation" | Always |
78
- | 12 | "Run E2E tests" | "Running E2E tests" | When `e2e_enabled` |
79
- | 13 | "Generate user documentation" | "Generating user documentation" | When `user_docs_enabled` |
80
- | 14 | "Finalize workflow" | "Finalizing workflow" | Always |
98
+ | 4 | "Gather requirements & create specification" | "Gathering requirements & creating specification" | Always |
99
+ | 5 | "Audit specification" | "Auditing specification" | Always (conditional) |
100
+ | 6 | "Plan implementation" | "Planning implementation" | Always |
101
+ | 7 | "Execute implementation" | "Executing implementation" | Always |
102
+ | 8 | "Verify test passes (TDD Green)" | "Verifying test passes" | When Phase 3 was executed |
103
+ | 9 | "Prompt verification options" | "Prompting verification options" | Always |
104
+ | 10 | "Verify implementation & resolve issues" | "Verifying implementation" | Always |
105
+ | 11 | "Run E2E tests" | "Running E2E tests" | When `e2e_enabled` |
106
+ | 12 | "Generate user documentation" | "Generating user documentation" | When `user_docs_enabled` |
107
+ | 13 | "Finalize workflow" | "Finalizing workflow" | Always |
81
108
 
82
109
  ---
83
110
 
@@ -136,14 +163,12 @@ Use for **all development tasks**: bug fixes, enhancements, new features, and an
136
163
 
137
164
  **ANTI-PATTERN — DO NOT DO THIS:**
138
165
 
139
- - ❌ "The UI change is small/simple, skipping Phase 4..." — STOP. If `ui_heavy` is true, Phase 4 runs. The gap-analyzer made this assessment, not you.
140
166
  - ❌ "No new screens needed, just a component..." — STOP. `ui_heavy` is a signal from the gap-analyzer. Do NOT override it with your own complexity judgment.
141
167
 
142
- question - Display executive summary before asking. Read `analysis/gap-analysis.md` and extract: task type detected, risk level, key characteristics enabled (TDD gates, UI mockups, E2E, user docs), scope decisions made (if any). Then read `task_context.task_characteristics` from `orchestrator-state.yml` and determine the next phase:
168
+ question - Display executive summary before asking. Read `analysis/gap-analysis.md` and extract: task type detected, risk level, key characteristics enabled (TDD gates, E2E, user docs), scope decisions made (if any). Then read `task_context.task_characteristics` from `orchestrator-state.yml` and determine the next phase:
143
169
 
144
170
  - If `has_reproducible_defect` is true → ask "Continue to Phase 3: TDD Red Gate?"
145
- - If `ui_heavy` is true → ask "Continue to Phase 4: UI Mockup Generation?"
146
- - Otherwise → ask "Continue to Phase 5: Technical Approach, Requirements & Specification?"
171
+ - Otherwise → ask "Continue to Phase 4: Technical Approach, Requirements & Specification?"
147
172
 
148
173
  ---
149
174
 
@@ -166,30 +191,11 @@ question - "TDD red gate complete. Continue to Phase 4?"
166
191
 
167
192
  ---
168
193
 
169
- ### Phase 4: UI Mockup Generation (Conditional)
194
+ ### Phase 4: Technical Approach, Requirements & Specification
170
195
 
171
196
  > **Phase gate**: Requires `question` confirmation from the preceding phase before executing.
172
197
 
173
- **Purpose**: Generate ASCII mockups showing UI integration
174
- **Execute**: Task tool - `ui-mockup-generator` subagent
175
- **Output**: `analysis/ui-mockups.md`
176
- **State**: Update `phase_summaries.ui_mockups`
177
-
178
- **Skip if**: `task_characteristics.ui_heavy` is false
179
-
180
- **Context to pass**: Gap analysis, scope decisions, component choices
181
-
182
- → Pause
183
-
184
- question - "UI mockups complete. Continue to Phase 5?"
185
-
186
- ---
187
-
188
- ### Phase 5: Technical Approach, Requirements & Specification
189
-
190
- > **Phase gate**: Requires `question` confirmation from the preceding phase before executing.
191
-
192
- **⛔ ROUTING GUARD**: Read `task_context.task_characteristics` from `orchestrator-state.yml`. If `has_reproducible_defect` is true and Phase 3 is NOT in `completed_phases` → STOP, execute Phase 3 first. If `ui_heavy` is true and Phase 4 is NOT in `completed_phases` → STOP, execute Phase 4 first.
198
+ **⛔ ROUTING GUARD**: Read `task_context.task_characteristics` from `orchestrator-state.yml`. If `has_reproducible_defect` is true and Phase 3 is NOT in `completed_phases` → STOP, execute Phase 3 first.
193
199
 
194
200
  **Purpose**: Resolve technical decisions, gather specification requirements, then create comprehensive specification
195
201
  **Execute**:
@@ -235,6 +241,15 @@ question - "UI mockups complete. Continue to Phase 5?"
235
241
 
236
242
  **SELF-CHECK**: Did you just invoke the Task tool with `specification-creator`? Or did you start writing spec.md yourself? If the latter, STOP immediately and invoke the Task tool instead.
237
243
 
244
+ **Part D — Diagram Refinement (Skill, content-preserving)**:
245
+
246
+ 7. Invoke Skill tool: `diagrams-mermaid` to refine `implementation/spec.md`
247
+ 8. Add diagrams that clarify scope and communication (without replacing prose):
248
+ - `flowchart` for primary functional path,
249
+ - `sequenceDiagram` for key component interaction,
250
+ - optionally `C4Component` if internal module structure is required by scope.
251
+ 9. If required context is missing, add explicit open questions/assumptions section instead of inventing entities.
252
+
238
253
  **Output**: `analysis/technical-clarifications.md` (conditional), `analysis/requirements.md`, `implementation/spec.md`
239
254
  **State**: Update `task_context.tech_clarified`, `task_context.architecture_decision`, `phase_summaries.specification`
240
255
 
@@ -244,9 +259,9 @@ question - Display executive summary before asking. Read `implementation/spec.md
244
259
 
245
260
  ---
246
261
 
247
- ### Phase 6: Specification Audit (Recommended)
262
+ ### Phase 5: Specification Audit (Recommended)
248
263
 
249
- > **Phase gate**: Requires `question` confirmation from Phase 5 before executing.
264
+ > **Phase gate**: Requires `question` confirmation from Phase 4 before executing.
250
265
 
251
266
  **Purpose**: Independent review of specification before implementation
252
267
  **Execute**: Task tool - `spec-auditor` subagent
@@ -263,9 +278,9 @@ question - Display executive summary before asking. Read `verification/spec-audi
263
278
 
264
279
  ---
265
280
 
266
- ### Phase 7: Implementation Planning
281
+ ### Phase 6: Implementation Planning
267
282
 
268
- > **Phase gate**: Requires `question` confirmation from Phase 6 before executing.
283
+ > **Phase gate**: Requires `question` confirmation from Phase 5 before executing.
269
284
 
270
285
  **Purpose**: Break specification into implementation steps
271
286
 
@@ -285,15 +300,21 @@ question - Display executive summary before asking. Read `verification/spec-audi
285
300
 
286
301
  **SELF-CHECK**: Did you just invoke the Task tool with `implementation-planner`? Or did you start writing implementation-plan.md yourself? If the latter, STOP immediately and invoke the Task tool instead.
287
302
 
303
+ **Post-plan diagram refinement (Skill, content-preserving)**:
304
+
305
+ - Invoke Skill tool: `diagrams-mermaid` for `implementation/implementation-plan.md`
306
+ - Add a compact execution diagram (task-group dependency flow or phase/state view).
307
+ - Keep implementation steps authoritative; diagrams are explanatory, not a replacement for task descriptions.
308
+
288
309
  → Pause
289
310
 
290
311
  question - Display executive summary before asking. Read `implementation/implementation-plan.md` and extract: number of task groups, total implementation steps, key dependencies between groups, estimated complexity. Format as brief overview then "Continue to implementation?"
291
312
 
292
313
  ---
293
314
 
294
- ### Phase 8: Implementation
315
+ ### Phase 7: Implementation
295
316
 
296
- > **Phase gate**: Requires `question` confirmation from Phase 7 before executing.
317
+ > **Phase gate**: Requires `question` confirmation from Phase 6 before executing.
297
318
 
298
319
  **Purpose**: Execute the implementation plan
299
320
 
@@ -313,8 +334,8 @@ question - Display executive summary before asking. Read `implementation/impleme
313
334
  **⚠️ POST-IMPLEMENTATION CONTINUATION** — After the skill completes and returns control:
314
335
 
315
336
  1. Read `orchestrator-state.yml` to confirm you are the orchestrator
316
- 2. Update state: add Phase 8 to `completed_phases`
317
- 3. Evaluate conditional: if `task_characteristics.has_reproducible_defect` AND Phase 3 in `completed_phases` → Phase 9, else → Phase 10
337
+ 2. Update state: add Phase 7 to `completed_phases`
338
+ 3. Evaluate conditional: if `task_characteristics.has_reproducible_defect` AND Phase 3 in `completed_phases` → Phase 8, else → Phase 9
318
339
 
319
340
  → Pause
320
341
 
@@ -322,9 +343,9 @@ question - Display executive summary before asking. Extract from `phase_summarie
322
343
 
323
344
  ---
324
345
 
325
- ### Phase 9: TDD Green Gate (Conditional)
346
+ ### Phase 8: TDD Green Gate (Conditional)
326
347
 
327
- > **Phase gate**: Requires `question` confirmation from Phase 8 before executing.
348
+ > **Phase gate**: Requires `question` confirmation from Phase 7 before executing.
328
349
 
329
350
  **Purpose**: Verify the failing test now passes
330
351
  **Execute**: Direct - run the test written in Phase 3
@@ -337,11 +358,11 @@ question - Display executive summary before asking. Extract from `phase_summarie
337
358
 
338
359
  → Pause
339
360
 
340
- question - "TDD gate passed. Continue to Phase 10?"
361
+ question - "TDD gate passed. Continue to Phase 9?"
341
362
 
342
363
  ---
343
364
 
344
- ### Phase 10: Verification Options Prompt
365
+ ### Phase 9: Verification Options Prompt
345
366
 
346
367
  > **Phase gate**: Requires `question` confirmation from the preceding phase before executing.
347
368
 
@@ -383,9 +404,9 @@ Options: "Code review (Recommended)", "Pragmatic review (Recommended)", "Reality
383
404
 
384
405
  ---
385
406
 
386
- ### Phase 11: Verification & Issue Resolution
407
+ ### Phase 10: Verification & Issue Resolution
387
408
 
388
- > **Phase gate**: Requires `question` confirmation from Phase 10 before executing.
409
+ > **Phase gate**: Requires `question` confirmation from Phase 9 before executing.
389
410
 
390
411
  **Purpose**: Comprehensive implementation verification with fix-then-reverify cycles
391
412
  **Output**: `verification/implementation-verification.md`, optional code-review/pragmatic/reality reports, updated `implementation/work-log.md`
@@ -438,18 +459,18 @@ Verification Results:
438
459
  **⚠️ POST-VERIFICATION CONTINUATION** — After issue resolution completes:
439
460
 
440
461
  1. Read `orchestrator-state.yml` to confirm you are the orchestrator
441
- 2. Update state: add Phase 11 to `completed_phases`
442
- 3. Proceed to Phase 12
462
+ 2. Update state: add Phase 10 to `completed_phases`
463
+ 3. Proceed to Phase 11
443
464
 
444
465
  → Pause
445
466
 
446
- question - Display executive summary: total issues found, issues fixed, issues remaining by severity. Then "Continue to Phase 12?"
467
+ question - Display executive summary: total issues found, issues fixed, issues remaining by severity. Then "Continue to Phase 11?"
447
468
 
448
469
  ---
449
470
 
450
- ### Phase 12: E2E Testing (Optional)
471
+ ### Phase 11: E2E Testing (Optional)
451
472
 
452
- > **Phase gate**: Requires `question` confirmation from Phase 11 before executing.
473
+ > **Phase gate**: Requires `question` confirmation from Phase 10 before executing.
453
474
 
454
475
  **Purpose**: Runtime browser verification with screenshots (via Playwright MCP tools, not test file generation)
455
476
  **Execute**: Task tool - `e2e-test-verifier` subagent
@@ -461,11 +482,11 @@ question - Display executive summary: total issues found, issues fixed, issues r
461
482
 
462
483
  → Pause
463
484
 
464
- question - "E2E complete. Continue to Phase 13?"
485
+ question - "E2E complete. Continue to Phase 12?"
465
486
 
466
487
  ---
467
488
 
468
- ### Phase 13: User Documentation (Optional)
489
+ ### Phase 12: User Documentation (Optional)
469
490
 
470
491
  > **Phase gate**: Requires `question` confirmation from the preceding phase before executing.
471
492
 
@@ -479,11 +500,11 @@ question - "E2E complete. Continue to Phase 13?"
479
500
 
480
501
  → Pause
481
502
 
482
- question - "Documentation complete. Continue to Phase 14?"
503
+ question - "Documentation complete. Continue to Phase 13?"
483
504
 
484
505
  ---
485
506
 
486
- ### Phase 14: Finalization
507
+ ### Phase 13: Finalization
487
508
 
488
509
  > **Phase gate**: Requires `question` confirmation from the preceding phase before executing.
489
510
 
@@ -507,44 +528,7 @@ question - "Documentation complete. Continue to Phase 14?"
507
528
 
508
529
  Development-specific fields in `orchestrator-state.yml`:
509
530
 
510
- ```yaml
511
- orchestrator:
512
- options:
513
- spec_audit_enabled: true
514
- skip_test_suite: true
515
- e2e_enabled: null
516
- user_docs_enabled: null
517
- code_review_enabled: true
518
- pragmatic_review_enabled: true
519
- reality_check_enabled: true
520
- production_check_enabled: true
521
- task_context:
522
- risk_level: null
523
- clarifications_resolved: null
524
- scope_expanded: null
525
- architecture_decision: null
526
- task_characteristics:
527
- has_reproducible_defect: false
528
- modifies_existing_code: false
529
- creates_new_entities: false
530
- involves_data_operations: false
531
- ui_heavy: false
532
- research_reference:
533
- path: null
534
- research_question: null
535
- research_type: null
536
- confidence_level: null
537
- phase_summaries:
538
- research: { summary: null, key_findings: [], recommended_approach: null }
539
- codebase_analysis:
540
- { key_files: [], primary_language: null, summary: null }
541
- clarifications: []
542
- gap_analysis: { integration_points: [], summary: null }
543
- scope_clarifications: { scope_expanded: null, summary: null }
544
- ui_mockups: { components_designed: [], summary: null }
545
- specification: { summary: null }
546
- architecture_decision: { decision: null, summary: null }
547
- ```
531
+ Refer to the template [src/templates/orchestrator-state-development.yml](../../templates/orchestrator-state-development.yml).
548
532
 
549
533
  ---
550
534
 
@@ -559,21 +543,20 @@ orchestrator:
559
543
  │ ├── clarifications.md # Phase 1
560
544
  │ ├── gap-analysis.md # Phase 2
561
545
  │ ├── scope-clarifications.md # Phase 2 (conditional)
562
- │ ├── technical-clarifications.md # Phase 5 (conditional)
563
- │ └── ui-mockups.md # Phase 4 (conditional)
546
+ │ └── technical-clarifications.md # Phase 4 (conditional)
564
547
  ├── implementation/
565
- │ ├── spec.md # Phase 5
566
- │ ├── requirements.md # Phase 5
567
- │ ├── implementation-plan.md # Phase 7
568
- │ ├── work-log.md # Phase 8
548
+ │ ├── spec.md # Phase 4
549
+ │ ├── requirements.md # Phase 4
550
+ │ ├── implementation-plan.md # Phase 6
551
+ │ ├── work-log.md # Phase 7
569
552
  │ ├── tdd-red-gate.md # Phase 3 (conditional)
570
- │ └── tdd-green-gate.md # Phase 9 (conditional)
553
+ │ └── tdd-green-gate.md # Phase 8 (conditional)
571
554
  ├── verification/
572
- │ ├── spec-audit.md # Phase 6 (recommended)
573
- │ ├── implementation-verification.md # Phase 11
574
- │ └── e2e-verification-report.md # Phase 12 (optional)
555
+ │ ├── spec-audit.md # Phase 5 (recommended)
556
+ │ ├── implementation-verification.md # Phase 10
557
+ │ └── e2e-verification-report.md # Phase 11 (optional)
575
558
  └── documentation/
576
- └── user-guide.md # Phase 13 (optional)
559
+ └── user-guide.md # Phase 12 (optional)
577
560
  ```
578
561
 
579
562
  ---
@@ -637,9 +620,9 @@ When research context is detected, read these files from the research folder:
637
620
  | -------------------- | --------------------------------- | ---------------------------------------------- |
638
621
  | State | `orchestrator-state.yml` | research_type, confidence_level |
639
622
  | Report | `outputs/research-report.md` | Main findings and conclusions |
640
- | Solution Exploration | `outputs/solution-exploration.md` | Alternatives and trade-offs (input to Phase 5) |
641
- | High-Level Design | `outputs/high-level-design.md` | C4 architecture (input to Phase 5) |
642
- | Decision Log | `outputs/decision-log.md` | ADR decisions (input to Phase 5) |
623
+ | Solution Exploration | `outputs/solution-exploration.md` | Alternatives and trade-offs (input to Phase 4) |
624
+ | High-Level Design | `outputs/high-level-design.md` | C4 architecture (input to Phase 4) |
625
+ | Decision Log | `outputs/decision-log.md` | ADR decisions (input to Phase 4) |
643
626
 
644
627
  ### How Research Informs Each Phase
645
628
 
@@ -649,8 +632,8 @@ When research context is detected, read these files from the research folder:
649
632
  | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
650
633
  | Phase 1 | Codebase analyzer receives research findings as search guidance |
651
634
  | Phase 2 | Gap analyzer uses research recommendations for comparison |
652
- | Phase 5 | Specification creator uses high-level-design.md as INPUT (still creates full spec). Architecture decisions use research report AND decision-log.md (lighter when ADRs comprehensive) |
653
- | Phase 7 | Implementation planner references research approach for task grouping |
635
+ | Phase 4 | Specification creator uses high-level-design.md as INPUT (still creates full spec). Architecture decisions use research report AND decision-log.md (lighter when ADRs comprehensive) |
636
+ | Phase 6 | Implementation planner references research approach for task grouping |
654
637
 
655
638
  ---
656
639
 
@@ -666,4 +649,4 @@ Invoked via:
666
649
  ## TDD Gate Rules
667
650
 
668
651
  **Phase 3 (Red Gate)**: Test MUST FAIL before implementation (activated when gap-analyzer detects reproducible defect)
669
- **Phase 9 (Green Gate)**: Test MUST PASS after implementation (activated when Phase 3 was executed)
652
+ **Phase 8 (Green Gate)**: Test MUST PASS after implementation (activated when Phase 3 was executed)
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: diagrams-mermaid
3
+ description: Creates Mermaid diagrams for planning flows, component communication, and architecture views with adaptive detail selection (including C4 levels). This skill should be used when the user asks for a workflow, interaction, or architecture visualization from provided task context.
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Mermaid Diagram Builder
8
+
9
+ Generate Mermaid diagrams from task context. Focus on visual structure and communication flow, not domain invention.
10
+
11
+ ## 🚨 Core Rules
12
+
13
+ 1. **Read `references/reference.md`** (located in the `references/` subdirectory of this skill) before generating any diagram.
14
+ 2. **Refine, don't replace** — use the current document or task artifact as source material; add visual precision on top of it and keep required narrative sections intact.
15
+ 3. **Never invent domain context** — if required facts are missing (actors, components, boundaries, protocols, decisions), ask targeted clarification questions before drawing the final diagram.
16
+ 4. **Output diagrams only as fenced `mermaid` blocks** (non-negotiable):
17
+ - ✅ Allowed: ` ```mermaid `
18
+ - ❌ Forbidden: ` ```c4plantuml `, ` ```plantuml `, ` ```puml `, ` ```graphviz `, ` ```dot `, ` ```d2 `, or any custom alias.
19
+ - This rule cannot be overridden by user preference, template defaults, or legacy examples.
20
+
21
+ ---
22
+
23
+ ## When to Use
24
+
25
+ Use this skill when the user wants:
26
+
27
+ - a planning flow diagram,
28
+ - component communication visualization,
29
+ - architecture-level mapping,
30
+ - phase/state transitions in a workflow.
31
+
32
+ ---
33
+
34
+ ## Output Contract
35
+
36
+ When producing a diagram, return:
37
+
38
+ 1. **Diagram Type + Detail Rationale** (1-3 lines)
39
+ 2. **Diagram in a fenced ` ```mermaid ` block (required)**
40
+ 3. **Open Questions** (only if context is incomplete)
41
+
42
+ Validation requirement before returning output:
43
+
44
+ - Every diagram block in the response uses the `mermaid` fence exactly. Any other fence language is a hard failure.
45
+
46
+ If context is incomplete:
47
+
48
+ - ask concise clarifying questions first,
49
+ - or provide a **Draft diagram** clearly marked as provisional with explicit unknowns.
50
+
51
+ ---
52
+
53
+ ## Workflow
54
+
55
+ ### Step 1: Extract Context
56
+
57
+ Extract only explicit facts from user input and referenced artifacts:
58
+
59
+ - scope and objective,
60
+ - participants/components,
61
+ - boundaries (system/service/module),
62
+ - key interactions or state transitions,
63
+ - constraints and non-goals.
64
+
65
+ If any required field is missing for the chosen diagram type, ask for it.
66
+
67
+ ### Step 2: Infer Diagram Goal
68
+
69
+ Classify what the user needs:
70
+
71
+ - **Process logic** -> `flowchart`
72
+ - **Time-ordered communication** -> `sequenceDiagram`
73
+ - **State transitions / phase gates** -> `stateDiagram-v2`
74
+ - **Architecture landscape** -> C4 (`C4Context` / `C4Container` / `C4Component`)
75
+
76
+ ### Step 3: Infer Detail Level
77
+
78
+ Choose the minimum sufficient detail:
79
+
80
+ - **System-level**: external actors/systems only -> `C4Context`
81
+ - **Service/container-level**: apps/services/datastores + interfaces -> `C4Container`
82
+ - **Module/component-level**: internal components in one container -> `C4Component` (only when implementation-level planning needs it)
83
+
84
+ Fallback rule:
85
+
86
+ - If C4 is too ambiguous or unstable for the requested artifact, use `flowchart` or `sequenceDiagram`.
87
+
88
+ ### Step 4: Build Diagram
89
+
90
+ Apply naming and structure rules:
91
+
92
+ - Stable IDs, human-readable labels.
93
+ - One concern per diagram (split large scope into multiple diagrams).
94
+ - For branching logic, use explicit decisions.
95
+ - For interactions, use `alt`, `opt`, `par` where needed.
96
+
97
+ ### Step 5: Validate Quality
98
+
99
+ Run this checklist before final output:
100
+
101
+ - Diagram type matches user intent.
102
+ - Detail level matches planning need (not over/under detailed).
103
+ - No speculative domain entities or links.
104
+ - Labels are clear and consistent.
105
+ - Syntax is parser-safe.
106
+ - All diagram blocks are fenced with ` ```mermaid ` (no alternatives).
107
+
108
+ ---
109
+
110
+ ## Mermaid/C4 Best Practices
111
+
112
+ 1. **Goal-first, syntax-second**: pick the view before drawing nodes.
113
+ 2. **Small readable views**: split diagrams instead of creating one overloaded graph.
114
+ 3. **Consistent naming**: keep IDs stable and semantic.
115
+ 4. **Explicit branching/parallelism**: model alternatives and parallel flows clearly.
116
+ 5. **C4 discipline**: do not mix levels (context/container/component) in one diagram.
117
+ 6. **Parser safety**:
118
+ - quote labels with special characters,
119
+ - avoid reserved or fragile node IDs,
120
+ - avoid custom style/color directives unless explicitly required.
121
+
122
+ ---
123
+
124
+ ## Anti-Examples (What Not To Do)
125
+
126
+ 1. **Invented domain context (critical anti-pattern)**
127
+ Adding components, protocols, or dependencies not present in provided context.
128
+
129
+ 2. **Mixed abstraction levels**
130
+ Combining system landscape and low-level function internals in a single diagram.
131
+
132
+ 3. **Unreadable mega-diagram**
133
+ Packing too many nodes/edges into one chart without decomposition.
134
+
135
+ 4. **Sequence without temporal semantics**
136
+ Using `sequenceDiagram` while omitting real call order, branches, or optional paths.
137
+
138
+ 5. **Placeholder naming**
139
+ IDs and labels like `A`, `B`, `step1` with no domain meaning.
140
+
141
+ 6. **Non-Mermaid diagram fence (hard failure)**
142
+ Returning diagrams in ` ```c4plantuml `, ` ```plantuml `, or any other non-`mermaid` fenced format.
143
+
144
+ When any anti-pattern appears, stop and refactor the output before returning it.
145
+
146
+ ---
147
+
148
+ ## C4 Detail Decision Matrix
149
+
150
+ | Need | Recommended Type | Minimum Inputs |
151
+ | ----------------------------------------------- | ---------------- | ----------------------------------------------- |
152
+ | Who interacts with the system? | `C4Context` | actors, external systems, system boundary |
153
+ | How services/data stores communicate? | `C4Container` | containers, interfaces, protocols/data flow |
154
+ | How one service/module is internally organized? | `C4Component` | container scope, components, internal contracts |
155
+
156
+ If minimum inputs are missing, ask questions instead of guessing.