@rashidee/co2 1.2.5

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 (190) hide show
  1. package/dist/index.js +25449 -0
  2. package/drizzle/0000_remarkable_charles_xavier.sql +210 -0
  3. package/drizzle/0001_wise_wolf_cub.sql +13 -0
  4. package/drizzle/0002_secret_spyke.sql +16 -0
  5. package/drizzle/0003_workspace_config_singleton.sql +16 -0
  6. package/drizzle/0004_terminal_claim_v120.sql +11 -0
  7. package/drizzle/0005_brainstorm_v124.sql +10 -0
  8. package/drizzle/0006_project_v140.sql +6 -0
  9. package/drizzle/0007_prd_wizard_v124.sql +14 -0
  10. package/drizzle/0008_workflow_artifact_v126.sql +24 -0
  11. package/drizzle/0009_project_import_v150.sql +7 -0
  12. package/drizzle/0010_quality_v151.sql +3 -0
  13. package/drizzle/meta/0000_snapshot.json +1335 -0
  14. package/drizzle/meta/0001_snapshot.json +1416 -0
  15. package/drizzle/meta/0002_snapshot.json +1510 -0
  16. package/drizzle/meta/_journal.json +83 -0
  17. package/package.json +41 -0
  18. package/plugin/.claude-plugin/marketplace.json +36 -0
  19. package/plugin/.claude-plugin/plugin.json +22 -0
  20. package/plugin/README.md +625 -0
  21. package/plugin/SKILLS.md +350 -0
  22. package/plugin/co2.svg +5 -0
  23. package/plugin/commands/brainstorm-loop.md +129 -0
  24. package/plugin/skills/conductor-defect/SKILL.md +898 -0
  25. package/plugin/skills/conductor-feature-develop/SKILL.md +1383 -0
  26. package/plugin/skills/conductor-feature-develop/references/implementation-domain-template.md +131 -0
  27. package/plugin/skills/conductor-feature-develop/references/implementation-master-template.md +89 -0
  28. package/plugin/skills/conductor-feature-develop/references/playwright-setup.md +224 -0
  29. package/plugin/skills/conductor-feature-prepare/SKILL.md +604 -0
  30. package/plugin/skills/depgen-k8s/SKILL.md +468 -0
  31. package/plugin/skills/depgen-k8s/references/dockerfile-laravel.md +197 -0
  32. package/plugin/skills/depgen-k8s/references/dockerfile-nodejs.md +163 -0
  33. package/plugin/skills/depgen-k8s/references/dockerfile-spring-boot.md +174 -0
  34. package/plugin/skills/depgen-k8s/references/k8s-patterns.md +869 -0
  35. package/plugin/skills/mockgen-shadcn/SKILL.md +1067 -0
  36. package/plugin/skills/mockgen-shadcn/references/admin-layout-template.md +1467 -0
  37. package/plugin/skills/mockgen-shadcn/references/mockup-hub-template.md +498 -0
  38. package/plugin/skills/mockgen-shadcn/references/mockup-index-template.md +216 -0
  39. package/plugin/skills/mockgen-tailwind/SKILL.md +904 -0
  40. package/plugin/skills/mockgen-tailwind/references/admin-layout-template.md +720 -0
  41. package/plugin/skills/mockgen-tailwind/references/mockup-hub-template.md +498 -0
  42. package/plugin/skills/mockgen-tailwind/references/mockup-index-template.md +190 -0
  43. package/plugin/skills/modelgen-nosql/SKILL.md +617 -0
  44. package/plugin/skills/modelgen-nosql/references/model-extraction-methodology.md +497 -0
  45. package/plugin/skills/modelgen-nosql/references/nosql-design-guide.md +258 -0
  46. package/plugin/skills/modelgen-relational/SKILL.md +707 -0
  47. package/plugin/skills/modelgen-relational/references/model-extraction-methodology.md +499 -0
  48. package/plugin/skills/specgen-flutter-riverpod/SKILL.md +898 -0
  49. package/plugin/skills/specgen-flutter-riverpod/references/component-patterns.md +971 -0
  50. package/plugin/skills/specgen-flutter-riverpod/references/notification-patterns.md +457 -0
  51. package/plugin/skills/specgen-flutter-riverpod/references/routing-patterns.md +362 -0
  52. package/plugin/skills/specgen-flutter-riverpod/references/security-patterns.md +709 -0
  53. package/plugin/skills/specgen-flutter-riverpod/references/spec-template.md +1566 -0
  54. package/plugin/skills/specgen-flutter-riverpod/references/state-patterns.md +518 -0
  55. package/plugin/skills/specgen-flutter-riverpod/references/storage-patterns.md +370 -0
  56. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/SKILL.md +984 -0
  57. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/batch-patterns.md +359 -0
  58. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/messaging-patterns.md +468 -0
  59. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/modulith-patterns.md +461 -0
  60. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/reporting-patterns.md +803 -0
  61. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/security-patterns.md +501 -0
  62. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/spec-template.md +1268 -0
  63. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/web-patterns.md +301 -0
  64. package/plugin/skills/specgen-node-cli-web/SKILL.md +561 -0
  65. package/plugin/skills/specgen-node-cli-web/references/auth-patterns.md +293 -0
  66. package/plugin/skills/specgen-node-cli-web/references/cli-packaging-patterns.md +250 -0
  67. package/plugin/skills/specgen-node-cli-web/references/server-patterns.md +247 -0
  68. package/plugin/skills/specgen-node-cli-web/references/spec-template.md +401 -0
  69. package/plugin/skills/specgen-node-cli-web/references/testing-patterns.md +174 -0
  70. package/plugin/skills/specgen-react-mui/SKILL.md +789 -0
  71. package/plugin/skills/specgen-react-mui/references/component-patterns.md +1077 -0
  72. package/plugin/skills/specgen-react-mui/references/reporting-patterns.md +1998 -0
  73. package/plugin/skills/specgen-react-mui/references/routing-patterns.md +461 -0
  74. package/plugin/skills/specgen-react-mui/references/security-patterns.md +599 -0
  75. package/plugin/skills/specgen-react-mui/references/spec-template.md +1030 -0
  76. package/plugin/skills/specgen-react-mui/references/state-patterns.md +327 -0
  77. package/plugin/skills/specgen-react-tailwind/SKILL.md +859 -0
  78. package/plugin/skills/specgen-react-tailwind/references/component-patterns.md +1212 -0
  79. package/plugin/skills/specgen-react-tailwind/references/reporting-patterns.md +1529 -0
  80. package/plugin/skills/specgen-react-tailwind/references/routing-patterns.md +669 -0
  81. package/plugin/skills/specgen-react-tailwind/references/security-patterns.md +656 -0
  82. package/plugin/skills/specgen-react-tailwind/references/spec-template.md +1237 -0
  83. package/plugin/skills/specgen-react-tailwind/references/state-patterns.md +327 -0
  84. package/plugin/skills/specgen-sdk-java/SKILL.md +933 -0
  85. package/plugin/skills/specgen-sdk-java/references/api-extraction-patterns.md +247 -0
  86. package/plugin/skills/specgen-sdk-java/references/http-client-patterns.md +495 -0
  87. package/plugin/skills/specgen-sdk-java/references/packaging-patterns.md +366 -0
  88. package/plugin/skills/specgen-sdk-java/references/spec-template.md +956 -0
  89. package/plugin/skills/specgen-spring-jpa-jtehtmx/SKILL.md +1284 -0
  90. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/batch-patterns.md +1224 -0
  91. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/jasper-patterns.md +1638 -0
  92. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/messaging-patterns.md +512 -0
  93. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/modulith-patterns.md +354 -0
  94. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/security-patterns.md +551 -0
  95. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/spec-template.md +2502 -0
  96. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/web-patterns.md +503 -0
  97. package/plugin/skills/specgen-spring-jpa-restapi/SKILL.md +990 -0
  98. package/plugin/skills/specgen-spring-jpa-restapi/references/batch-patterns.md +1224 -0
  99. package/plugin/skills/specgen-spring-jpa-restapi/references/messaging-patterns.md +512 -0
  100. package/plugin/skills/specgen-spring-jpa-restapi/references/modulith-patterns.md +279 -0
  101. package/plugin/skills/specgen-spring-jpa-restapi/references/reporting-patterns.md +1536 -0
  102. package/plugin/skills/specgen-spring-jpa-restapi/references/restapi-patterns.md +722 -0
  103. package/plugin/skills/specgen-spring-jpa-restapi/references/security-patterns.md +351 -0
  104. package/plugin/skills/specgen-spring-jpa-restapi/references/spec-template.md +553 -0
  105. package/plugin/skills/specgen-ts-cli/SKILL.md +861 -0
  106. package/plugin/skills/specgen-ts-cli/references/async-patterns.md +1101 -0
  107. package/plugin/skills/specgen-ts-cli/references/command-patterns.md +383 -0
  108. package/plugin/skills/specgen-ts-cli/references/config-patterns.md +430 -0
  109. package/plugin/skills/specgen-ts-cli/references/database-patterns.md +750 -0
  110. package/plugin/skills/specgen-ts-cli/references/packaging-patterns.md +426 -0
  111. package/plugin/skills/specgen-ts-cli/references/spec-template.md +1391 -0
  112. package/plugin/skills/specgen-ts-cli/references/testing-patterns.md +909 -0
  113. package/plugin/skills/testgen-functional/SKILL.md +1381 -0
  114. package/plugin/skills/tracegen-matrix/SKILL.md +243 -0
  115. package/plugin/skills/util-preparek8senv/SKILL.md +422 -0
  116. package/plugin/skills/util-projectinit/SKILL.md +307 -0
  117. package/plugin/skills/util-projectinit/reference/brainstorm-loop.md +129 -0
  118. package/plugin/skills/util-projectinit/reference/brainstorm-protocol.md +144 -0
  119. package/plugin/skills/util-projectinit/reference/brainstorm-setup-guide.md +153 -0
  120. package/plugin/skills/util-projectinit/reference/brainstorm-template-appdev.md +87 -0
  121. package/plugin/skills/util-projectinit/reference/co2-context-generation-guide.md +761 -0
  122. package/plugin/skills/util-projectsync/SKILL.md +501 -0
  123. package/plugin/skills/util-updprd/SKILL.md +324 -0
  124. package/plugin/skills/util-usanalyzer/SKILL.md +307 -0
  125. package/plugin/skills/util-ustagger/SKILL.md +154 -0
  126. package/static/assets/abnfDiagram-VRR7QNED-DvPuwyCV.js +1 -0
  127. package/static/assets/arc-DRKw7sjs.js +1 -0
  128. package/static/assets/architectureDiagram-ZJ3FMSHR-CaNcxUbC.js +36 -0
  129. package/static/assets/blockDiagram-677ZJIJ3-Demd4AOK.js +132 -0
  130. package/static/assets/c4Diagram-LMCZKHZV-PVKUfc2x.js +10 -0
  131. package/static/assets/channel-C2nVbuwv.js +1 -0
  132. package/static/assets/chunk-2Q5K7J3B-CExf8ww_.js +1 -0
  133. package/static/assets/chunk-32BRIVSS-CFPaoONF.js +1 -0
  134. package/static/assets/chunk-5VM5RSS4-DE2esM67.js +15 -0
  135. package/static/assets/chunk-EX3LRPZG-SON_YdDG.js +231 -0
  136. package/static/assets/chunk-JWPE2WC7-Qxah8LNr.js +1 -0
  137. package/static/assets/chunk-MOJQB5TN-BcWGQV3j.js +88 -0
  138. package/static/assets/chunk-RYQCIY6F-DkDj-OR5.js +1 -0
  139. package/static/assets/chunk-V7JOEXUC-BlI1Mrah.js +206 -0
  140. package/static/assets/chunk-VR4S4FIN-Agf__duj.js +1 -0
  141. package/static/assets/chunk-XXDRQBXY-B5CfAh85.js +1 -0
  142. package/static/assets/classDiagram-OUVF2IWQ-DXJIljsR.js +1 -0
  143. package/static/assets/classDiagram-v2-EOCWNBFH-DXJIljsR.js +1 -0
  144. package/static/assets/cose-bilkent-JH36ORCC-DO0cQkcy.js +1 -0
  145. package/static/assets/cynefin-VYW2F7L2-CfOnsnXc.js +178 -0
  146. package/static/assets/cynefinDiagram-TSTJHNR4-BJ8tULAv.js +62 -0
  147. package/static/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
  148. package/static/assets/dagre-VKFMJZFB-DfjwzHqP.js +4 -0
  149. package/static/assets/defaultLocale-DX6XiGOO.js +1 -0
  150. package/static/assets/diagram-FQU43EPY-CndSOIIM.js +3 -0
  151. package/static/assets/diagram-G47NLZAW-Czf5hN0Z.js +24 -0
  152. package/static/assets/diagram-NH7WQ7WH-COAyojGh.js +24 -0
  153. package/static/assets/diagram-OA4YK3LP-H8PoiN2m.js +30 -0
  154. package/static/assets/diagram-WEI45ONY-DzcaVzjp.js +41 -0
  155. package/static/assets/ebnfDiagram-CCIWWBDH-DPazGYLJ.js +1 -0
  156. package/static/assets/erDiagram-Q63AITRT-Bo-fubgF.js +85 -0
  157. package/static/assets/flowDiagram-23GEKE2U-CSvxUDwh.js +156 -0
  158. package/static/assets/ganttDiagram-NO4QXBWP-DnBveWX6.js +292 -0
  159. package/static/assets/gitGraphDiagram-IHSO6WYX-B3rVL8c-.js +106 -0
  160. package/static/assets/graph-C9eacEi8.js +1 -0
  161. package/static/assets/index-LZSQkLE2.css +41 -0
  162. package/static/assets/index-y7XDSgMG.js +495 -0
  163. package/static/assets/infoDiagram-FWYZ7A6U-CvWV9yy2.js +2 -0
  164. package/static/assets/init-Gi6I4Gst.js +1 -0
  165. package/static/assets/ishikawaDiagram-FXEZZL3T-DF28a1N6.js +70 -0
  166. package/static/assets/journeyDiagram-5HDEW3XC-CB6CugYk.js +139 -0
  167. package/static/assets/kanban-definition-HUTT4EX6-ResSLF6d.js +89 -0
  168. package/static/assets/katex-C5jXJg4s.js +257 -0
  169. package/static/assets/layout-DEXfKzaS.js +1 -0
  170. package/static/assets/linear-CLO--ryk.js +1 -0
  171. package/static/assets/map-Czzmt4hB.js +1 -0
  172. package/static/assets/mindmap-definition-LN4V7U3C-BvW3EbxX.js +96 -0
  173. package/static/assets/ordinal-Cboi1Yqb.js +1 -0
  174. package/static/assets/pegDiagram-2B236MQR-BHCgqrrM.js +1 -0
  175. package/static/assets/pieDiagram-ENE6RG2P-DVmCQ5FA.js +39 -0
  176. package/static/assets/quadrantDiagram-ABIIQ3AL-B3e5KR52.js +7 -0
  177. package/static/assets/railroadDiagram-RFXS5EU6-Csv5ysLc.js +1 -0
  178. package/static/assets/requirementDiagram-TGXJPOKE-DOMVzvnB.js +84 -0
  179. package/static/assets/sankeyDiagram-HTMAVEWB-B1dcTOvy.js +40 -0
  180. package/static/assets/sequenceDiagram-DBY2YBRQ-BY414yeO.js +162 -0
  181. package/static/assets/sizeCapture-X5ZJPWSS-CuJfrfBN.js +1 -0
  182. package/static/assets/stateDiagram-2N3HPSRC-FX4rJkzV.js +1 -0
  183. package/static/assets/stateDiagram-v2-6OUMAXLB-BVufbO_H.js +1 -0
  184. package/static/assets/swimlanes-5IMT3BWC-Sfy58mmv.js +2 -0
  185. package/static/assets/swimlanesDiagram-G3AALYLV-wDCDw08H.js +8 -0
  186. package/static/assets/timeline-definition-FHXFAJF6-CmV7by8p.js +120 -0
  187. package/static/assets/vennDiagram-L72KCM5P-FqIyFZFt.js +34 -0
  188. package/static/assets/wardleyDiagram-EHGQE667-BZ06O45i.js +78 -0
  189. package/static/assets/xychartDiagram-FW5EYKEG-BOkffR06.js +7 -0
  190. package/static/index.html +24 -0
@@ -0,0 +1,707 @@
1
+ ---
2
+ name: modelgen-relational
3
+ model: claude-opus-4-8
4
+ effort: xhigh
5
+ description: >
6
+ Extract module models from Agile user stories using Domain-Driven Design (DDD) principles.
7
+ Produces ERD diagrams (Mermaid) and detailed model documentation per module. Use this skill
8
+ whenever the user asks to extract a module model, data model, entity model, table design,
9
+ schema design, or ERD from user stories. Also trigger when the user provides a set of user
10
+ stories grouped by module and asks for entity/relationship analysis, database schema extraction,
11
+ or DDD model generation. Even if the user says "analyze these stories" or "what entities do
12
+ I need", this skill applies if the input contains structured Agile user stories with module groupings.
13
+ Also trigger when the user says "update the model" or "upgrade the model" to
14
+ incrementally evolve an existing module model based on changes in PRD.md.
15
+ Accepts an application name (mandatory), version (mandatory), and optional module argument
16
+ (e.g., `/modelgen-relational hub_middleware v1.0.3` or `/modelgen-relational hub_middleware v1.0.3 module:Location Information`).
17
+ ---
18
+
19
+ # Relational Model Generator
20
+
21
+ Extract structured module models from Agile user stories following a systematic DDD methodology.
22
+
23
+ ## When to Use
24
+
25
+ Trigger this skill when the user asks to:
26
+ - Extract a module model, data model, or entity model
27
+ - Generate an ERD or entity-relationship diagram from user stories
28
+ - Design database tables or schema from requirements
29
+ - Perform DDD analysis on user stories
30
+ - Update an existing module model based on story changes
31
+ - Upgrade the model to a new version
32
+ - Detect and fix outdated/invalid model elements
33
+
34
+ ## Version Gate
35
+
36
+ Before starting any work, resolve the application folder first (see Input Resolution below), then check `CHANGELOG.md` in the application folder (`<app_folder>/CHANGELOG.md`):
37
+
38
+ 1. If `<app_folder>/CHANGELOG.md` does not exist, skip this check (first-ever execution for this application).
39
+ 2. If `<app_folder>/CHANGELOG.md` exists, scan all `## vX.Y.Z` headings and determine the **highest version** using semantic versioning comparison.
40
+ 3. Compare the requested version against the highest version:
41
+ - If requested version **>=** highest version: proceed normally.
42
+ - If requested version **<** highest version: **STOP immediately**. Print: `"Version {requested} is lower than the current application version {highest} recorded in <app_folder>/CHANGELOG.md. Execution rejected."` Do NOT proceed with any work.
43
+
44
+ ## Input Resolution
45
+
46
+ The skill requires mandatory `<application>` and `<version>` arguments, with an optional `module:` argument.
47
+
48
+ ### Argument Syntax
49
+
50
+ | Argument | Required | Description |
51
+ |----------|----------|-------------|
52
+ | `<application>` | Yes | Application name — matched against root-level application folders |
53
+ | `<version>` | Yes | Version label (e.g., `v1.0.3`). Used for version-filtered generation. |
54
+ | `module:<name>` | No | Limit generation to a single module |
55
+
56
+ | Format | Example | Meaning |
57
+ |--------|---------|---------|
58
+ | App + version | `/modelgen-relational hub_middleware v1.0.3` | All modules, version-filtered |
59
+ | App + version + module | `/modelgen-relational hub_middleware v1.0.3 module:Location Information` | Single module, version-filtered |
60
+ | Module quoted | `module:"Location Information"` | Quoted form (equivalent) |
61
+ | Module snake_case | `module:location_information` | Converted to title-case for matching |
62
+
63
+ ### Application Folder Resolution
64
+
65
+ 1. List root-level application folders that have a numeric prefix (e.g., `1_hub_middleware`, `2_hc_adapter`)
66
+ 2. Strip the leading `<number>_` prefix from each folder name (e.g., `1_hub_middleware` -> `hub_middleware`)
67
+ 3. Match the provided application name **case-insensitively** against the stripped folder names
68
+ 4. Accept `snake_case`, `kebab-case`, or title-case input (e.g., `hub_middleware`, `hub-middleware`, `Hub Middleware` all match `1_hub_middleware`)
69
+ 5. If no match is found, list all available application names and **stop**
70
+
71
+ ### Auto-Resolved Paths
72
+
73
+ | File | Resolved Path |
74
+ |------|---------------|
75
+ | PRD.md | `<app_folder>/context/PRD.md` |
76
+ | Output directory | `<app_folder>/context/model/` |
77
+
78
+ ### Module Matching Rules
79
+
80
+ 1. Match the specified module name **case-insensitively** against modules in PRD.md
81
+ 2. Convert `snake_case` input to title-case for matching (e.g., `location_information` -> `Location Information`)
82
+ 3. If no module matches, **stop and report available module names** before doing any file writes
83
+ 4. Exactly one module must match — partial or ambiguous matches are rejected with suggestions
84
+
85
+ ### Version Filtering
86
+
87
+ When a version argument is provided:
88
+
89
+ 1. Only process user stories from versions **up to and including** the specified version
90
+ 2. Stories from later versions are excluded from extraction
91
+ 3. Version comparison uses the ordering present in PRD.md (versions appear in document order, earlier = lower)
92
+ 4. The generated model reflects the state of the system at the specified version
93
+
94
+ When combined with `module:`, both filters apply: only stories in the target module at or below the target version are processed.
95
+
96
+ ---
97
+
98
+ ## Update Mode
99
+
100
+ This section defines the **incremental update** workflow for evolving an existing module model
101
+ when user stories change across versions. Use this mode instead of full regeneration when working
102
+ with a previously generated model.
103
+
104
+ ### Update Mode Triggers
105
+
106
+ Activate update mode when the user says:
107
+ - "update the model"
108
+ - "upgrade the model"
109
+
110
+ The user must provide a **new version identifier** for the update (e.g., "1.1.0", "v2", "Sprint-4").
111
+
112
+ ### Update Mode Input Contract
113
+
114
+ | Element | Description |
115
+ |---------|-------------|
116
+ | **Existing Model Directory** | Path to previously generated output (must contain MODEL.md + module subdirectories with model.md and erd.mermaid) |
117
+ | **Updated PRD.md** | The updated user story file with changes (additions, modifications, removals) |
118
+ | **New Version** | Version label for this update (e.g., "1.1.0", "v2") |
119
+
120
+ ### Update Mode Processing Workflow
121
+
122
+ #### Phase U1: Baseline Loading
123
+
124
+ - Read all existing model files (MODEL.md, per-module model.md, erd.mermaid)
125
+ - Build an inventory of current entities, attributes, relationships, enums with their source story traceability tags
126
+
127
+ #### Phase U2: Change Detection (Diff Analysis)
128
+
129
+ - Parse the updated PRD.md
130
+ - Compare against source story references in existing model files
131
+ - Classify changes into:
132
+ - **ADDED** — New stories not referenced by any existing model element
133
+ - **MODIFIED** — Stories whose text has changed (same tag, different content)
134
+ - **REMOVED** — Stories referenced in the model but no longer present in PRD.md
135
+ - **UNCHANGED** — Stories with no changes
136
+
137
+ #### Phase U3: Staleness & Validity Check
138
+
139
+ For each existing model element (entity, attribute, relationship, enum value), check:
140
+ - **Orphaned elements**: Source stories entirely removed → flag for removal
141
+ - **Partially orphaned**: Some source stories removed but others remain → flag for review
142
+ - **Stale attributes**: Source story text changed such that the attribute inference no longer holds → flag for update
143
+ - **Stale relationships**: Verb/preposition patterns changed → flag for re-evaluation
144
+ - **Stale enums**: Qualifier terms changed or removed → flag for update
145
+ - **Contradictions**: New stories contradict existing model assumptions → flag
146
+
147
+ Produce a **Staleness Report** table:
148
+
149
+ | Element Type | Element Name | Module | Status | Reason | Affected Stories | Action |
150
+ |---|---|---|---|---|---|---|
151
+ | Entity | Order | Order Mgmt | ORPHANED | All source stories removed | [US-010] | REMOVE |
152
+ | Attribute | priority | Order | STALE | Source story US-005 modified | [US-005] | UPDATE |
153
+
154
+ Status values: `ORPHANED`, `STALE`, `CONTRADICTED`, `VALID`
155
+ Action values: `REMOVE`, `UPDATE`, `REVIEW`, `KEEP`
156
+
157
+ #### Phase U4: Incremental Extraction
158
+
159
+ - For ADDED stories: run the full 8-phase extraction pipeline (existing Phases 1–8)
160
+ - For MODIFIED stories: re-extract affected model elements, compare with existing, merge
161
+ - Apply new version tag to all new/modified elements
162
+
163
+ #### Phase U5: Model Merge
164
+
165
+ - Integrate new/updated elements into existing model
166
+ - Remove ORPHANED elements (after confirmation or auto-removal if clearly orphaned)
167
+ - Update version annotations on modified elements
168
+ - Preserve unchanged elements with their original versions
169
+
170
+ #### Phase U6: Output Regeneration
171
+
172
+ - Regenerate all output files (erd.mermaid, model.md, MODEL.md) with merged model
173
+ - Add a **Changelog** section to each module's model.md and to the root MODEL.md
174
+
175
+ ---
176
+
177
+ ## Methodology Reference
178
+
179
+ Before processing any input, read the full extraction methodology:
180
+
181
+ ```
182
+ Read references/model-extraction-methodology.md
183
+ ```
184
+
185
+ This reference defines the 8-phase extraction pipeline in detail, including linguistic
186
+ analysis heuristics, entity classification decision trees, attribute inference rules,
187
+ relationship detection patterns, and NFR impact mappings. The instructions below
188
+ orchestrate that methodology — always defer to the reference for phase-specific rules.
189
+
190
+ ---
191
+
192
+ ## Input Contract
193
+
194
+ The user MUST provide the following structured input. If any required element is missing,
195
+ ask the user to supply it before proceeding. Do NOT infer modules from story content.
196
+
197
+ ### Required Input
198
+
199
+ | Element | Description |
200
+ |---------|-------------|
201
+ | **Module List** | Explicit list of module names (bounded context candidates) |
202
+ | **User Stories** | Agile-format stories, each tagged with a **module** and a **version**. Format: "As [role], I want to [action] [object] so that [purpose]". The module associates the story to a bounded context. The version enables progressive model evolution tracking — every entity, attribute, relationship, and enum value in the output will reference the version that introduced it. |
203
+ | **NFRs per Module** | Non-functional requirements (security, performance, compliance, etc.) |
204
+
205
+ ### Optional Input
206
+
207
+ | Element | Description |
208
+ |---------|-------------|
209
+ | **Module Prefix Overrides** | A 3-character prefix per module to override the auto-generated one. Format: `Module Name: XXX`. If not provided, the skill generates a prefix automatically (see Prefix Generation Rules). |
210
+ | **Assumptions** | Assumptions the user has made about the domain or requirements |
211
+ | **Constraints** | Technical or business constraints affecting the model |
212
+ | **Glossary** | Domain-specific term definitions (ubiquitous language) |
213
+ | **Existing Data Model** | Current-state model for migration or extension scenarios |
214
+
215
+ ### Input Format Example
216
+
217
+ ```markdown
218
+ ## Module: User Management
219
+
220
+ ### Version: 1.0
221
+
222
+ - US-001: As an Admin, I want to create user accounts so that new employees can access the system.
223
+ - US-002: As an Admin, I want to assign roles to users so that access is controlled.
224
+
225
+ ### Version: 1.1
226
+
227
+ - US-010: As an Admin, I want to deactivate user accounts so that former employees lose access.
228
+ - US-011: As a User, I want to update my profile so that my contact information stays current.
229
+
230
+ #### NFRs
231
+ - NFR-001: All entities must support soft delete.
232
+ - NFR-002: Audit trail required for all write operations.
233
+
234
+ #### Assumptions
235
+ - User accounts are internal only (no external/public registration).
236
+ ```
237
+
238
+ The version tag is freeform (e.g., `1.0`, `v2`, `Sprint-3`, `Phase-1`). The skill does not
239
+ enforce a versioning scheme but preserves the user's version labels exactly as provided.
240
+
241
+ ### Module Prefix Generation Rules
242
+
243
+ Each module is assigned a 3-character uppercase prefix used in ERD entity names to support
244
+ shared-database deployment. The prefix is auto-generated but can be overridden by the user.
245
+
246
+ **Auto-generation algorithm (in order of preference):**
247
+
248
+ 1. **Multi-word module** — take the first letter of each word, up to 3 characters.
249
+ - "User Management" → `USM`
250
+ - "Order Processing" → `ORP`
251
+ - "Inventory" → `INV` (single word: first 3 characters)
252
+ 2. **Single-word module** — take the first 3 characters.
253
+ - "Billing" → `BIL`
254
+ - "Inventory" → `INV`
255
+ 3. **Collision resolution** — if two modules produce the same prefix, append a numeric
256
+ suffix to the second one and truncate to 3 characters.
257
+ - "Order Processing" → `ORP`, "Order Placement" → `OPL` (use first + second-word first two)
258
+ - If still colliding, use first letter + incremental digit: `OR1`, `OR2`
259
+
260
+ **Rules:**
261
+ - Prefix is always exactly 3 characters, uppercase A-Z or A-Z + digit for collision cases.
262
+ - The prefix is applied **only in ERD entity names** (e.g., `USM_USER`, `ORP_ORDER`).
263
+ It does NOT appear in the `model.md` tables, where entities use their clean PascalCase
264
+ names for readability.
265
+ - Present the prefix-to-module mapping at the top of each `erd.mermaid` file as a comment
266
+ and in a **Module Prefix Map** section in `model.md`.
267
+
268
+ **Override:** The user can supply prefix overrides in the input. Overrides must be exactly
269
+ 3 uppercase characters and take priority over auto-generation.
270
+
271
+ ### Input Validation Rules
272
+
273
+ 1. **Requirement tagging is mandatory.** Before processing, scan the input PRD.md file and verify that ALL top-level bullet items under User Story, Functional Requirements, Non Functional Requirement, Constraint, and Reference sections have a tag code (e.g., `[USHM00003]`, `[NFRHM0003]`, `[CONSHM003]`, `[REFHM0003]`). If ANY item is missing a tag, **stop immediately** and invoke the `co2-skills:util-ustagger` skill on the file to tag all untagged items. Only resume model extraction after all items are tagged. These tag codes will be used as the `Source Story` reference throughout the model output.
274
+ 2. **Module-story binding is mandatory.** Every user story must be explicitly tagged with a module. If stories are provided without module assignment, stop and ask the user to assign them.
275
+ 3. **Version tag is mandatory.** Every user story must be associated with a version. If stories are provided without version tags, stop and ask the user to assign them.
276
+ 4. **Story format check.** Each story should follow "As [role], I want to [action] [object] so that [purpose]". Flag stories that deviate and ask for clarification, but attempt to parse them.
277
+ 5. **At least one NFR per module.** If no NFRs are provided for a module, prompt the user to confirm whether standard conventions (audit trail, soft delete, optimistic locking) should apply as defaults.
278
+ 6. **Output directory is auto-resolved.** The output directory is automatically resolved to `<app_folder>/context/model/`. Auto-create if the path doesn't exist (including any intermediate parent directories).
279
+
280
+ ---
281
+
282
+ ## Processing Workflow
283
+
284
+ Process ALL modules in a single pass. Each module is treated as an independent bounded
285
+ context — do not model cross-module relationships. If you detect a potential cross-module
286
+ dependency (e.g., Module A references an entity that looks like it belongs to Module B),
287
+ note it in the assumptions table but do not create a relationship.
288
+
289
+ ### Version Tracking
290
+
291
+ Within each module, process user stories **in version order** (earliest version first).
292
+ Every model element — entity, attribute, relationship, enum value, domain event — must
293
+ be annotated with the **version that introduced it**. This means:
294
+
295
+ - If Entity `Order` first appears from stories in version `1.0`, its version is `1.0`.
296
+ - If a new attribute `priority` is added to `Order` by a story in version `1.1`, that
297
+ attribute's version is `1.1`, while the entity's version remains `1.0`.
298
+ - If an existing enum gains new values in a later version, the new values carry the
299
+ later version while existing values retain their original version.
300
+
301
+ This enables the user to trace exactly what changed at each version and supports
302
+ progressive model growth across sprints or phases.
303
+
304
+ For each module, execute the following phases sequentially. The output is the final
305
+ consolidated result — do NOT include intermediate phase analysis in the deliverables.
306
+
307
+ ### Phase 1: Linguistic Analysis
308
+
309
+ Parse each user story using the grammar-to-domain mapping from the methodology reference
310
+ (Section 3). For compound stories with multiple verbs, decompose into individual operations.
311
+
312
+ Key extractions:
313
+ - **Subjects** → Actor/Role candidates (enum values)
314
+ - **Verbs** → Operations, commands, state transitions
315
+ - **Direct Objects** → Primary entity candidates
316
+ - **Indirect Objects** → Related entity candidates
317
+ - **Purpose Clauses** → Business rules, domain events
318
+ - **Adjectives/Qualifiers** → Enum values, states, types
319
+
320
+ ### Phase 2: Entity Identification
321
+
322
+ Classify every extracted noun using the decision flowchart from the methodology reference
323
+ (Section 4.2):
324
+
325
+ ```
326
+ Finite known set? → ENUM
327
+ Has identity + lifecycle? → Is it aggregate root? → AGGREGATE ROOT / ENTITY
328
+ Immutable, describes another? → VALUE OBJECT
329
+ Verb/action that happened? → DOMAIN EVENT
330
+ Otherwise → DOMAIN SERVICE or needs analysis
331
+ ```
332
+
333
+ Apply naming conventions: PascalCase for entities, enums, events, value objects, join entities.
334
+
335
+ ### Phase 3: Attribute Extraction
336
+
337
+ Derive attributes from four sources in priority order:
338
+ 1. **Explicit mention** in user story text
339
+ 2. **Operation inference** (CRUD verbs → audit fields, version, soft delete)
340
+ 3. **NFR requirements** (see Appendix B of the methodology reference)
341
+ 4. **Domain convention** (id, audit fields, base entity pattern)
342
+
343
+ For each attribute, determine: name (camelCase), type, nullable, constraints, and source type
344
+ (`EXPLICIT`, `OPERATION_INFERENCE`, `NFR`, `CONVENTION`, or `ASSUMPTION`).
345
+
346
+ #### Primary Key Convention
347
+
348
+ All entity primary keys MUST use **UUID** type with **database-level generation**. The UUID value MUST be generated by the database engine itself (e.g., `gen_random_uuid()` in PostgreSQL, `UUID()` in MySQL, `NEWSEQUENTIALID()` in SQL Server), NOT by the application layer. This is a mandatory convention for all entities including join entities.
349
+
350
+ **Rationale:** Application-generated UUIDs introduce performance overhead (extra network round-trips, inconsistent generation strategies across application instances, potential index fragmentation from random UUIDs). Database-generated UUIDs ensure consistent generation, reduce application complexity, and allow the database to use optimized UUID variants (e.g., UUIDv7 or sequential UUIDs) for better index performance.
351
+
352
+ In model documentation, annotate the `id` attribute with `DB-generated UUID` in the Constraints column to make this explicit.
353
+
354
+ When a story is ambiguous, propose defaults and record the ambiguity.
355
+
356
+ ### Phase 4: Relationship Mapping
357
+
358
+ Detect relationships using the verb/preposition patterns from the methodology reference
359
+ (Section 6.1). For each relationship, determine:
360
+ - Source and target entities
361
+ - Cardinality (1:1, 1:N, N:1, M:N)
362
+ - Join entity name (for M:N)
363
+ - Cascade behavior
364
+ - Source story traceability
365
+
366
+ Promote M:N relationships to join entities with audit fields.
367
+
368
+ ### Phase 5: Cross-Cutting Concerns
369
+
370
+ Scan NFRs and map each to model impact using the NFR-to-Model Impact Map (Appendix B
371
+ of the methodology reference). Define a base entity specification if audit fields, soft
372
+ delete, or optimistic locking are implied.
373
+
374
+ #### Phase 5a: Architecture Principle Integration
375
+
376
+ If PRD.md contains an `# Architecture Principle` section, read it and apply to model decisions:
377
+
378
+ - **Monolithic vs. Microservice**: If "monolithic" (e.g., "monolithic web application", "modular architecture"), model cross-module references as soft references (ID columns without FK constraints) and note this convention in the Cross-Module Dependencies section. If "microservice", enforce strict bounded context isolation — no cross-module references at all.
379
+ - **Event-driven**: If architecture mentions "event-driven" or "domain events", elevate domain event identification in Phase 2. Generate more domain event entities and event payload types in Section 7 (Domain Events). Each inter-module data flow should have a corresponding domain event.
380
+ - **Stateless**: If architecture mentions "stateless", confirm that no session-related entities are modeled — user context comes from JWT tokens or external identity providers.
381
+ - **Database type confirmation**: Use the architecture section to confirm the relational database choice. If the architecture mentions a specific database engine (e.g., PostgreSQL, MySQL), record it in assumptions for DDL dialect considerations.
382
+
383
+ If the `# Architecture Principle` section is absent, skip this sub-phase and proceed with existing behavior.
384
+
385
+ #### Phase 5b: Process Flow State Extraction
386
+
387
+ If PRD.md contains a `# High Level Process Flow` section, read it and extract state-related information:
388
+
389
+ - **Entity lifecycle states**: If a process flow describes status transitions for an entity (e.g., "Received → Validated → Enriched → Active"), cross-reference with enum extraction from Phase 2. Ensure all states mentioned in process flows appear in the corresponding entity's status enum definition. Add any missing states.
390
+ - **Intermediate entities**: If a flow describes intermediate or staging data (e.g., "incoming message stored before validation"), verify that corresponding staging/intermediate entities exist in the model. If not, create them.
391
+ - **Domain events from flows**: Each step in a process flow that describes "publishes", "sends", or "triggers" should be checked against the Domain Events table (Section 7). Add any flow-derived events not already captured from user stories.
392
+
393
+ If the `# High Level Process Flow` section is absent, skip this sub-phase.
394
+
395
+ ### Phase 6: Bounded Context Finalization
396
+
397
+ Since modules are provided explicitly by the user, confirm each module as a bounded context.
398
+ Within each context, identify aggregates by grouping entities with transactional cohesion.
399
+ No aggregate should contain more than 4–5 entities.
400
+
401
+ ### Phase 7: Output Generation
402
+
403
+ Produce the two deliverables per module (see Output Specification below).
404
+
405
+ ### Phase 8: Validation
406
+
407
+ Run the completeness and quality checklists from the methodology reference (Section 10)
408
+ as a self-review. Fix any issues found before presenting the output.
409
+
410
+ ---
411
+
412
+ ## Changelog Append
413
+
414
+ After all model files are successfully generated, append an entry to `CHANGELOG.md` in the application folder (`<app_folder>/CHANGELOG.md`):
415
+
416
+ 1. Read `<app_folder>/CHANGELOG.md`. If it does not exist, create it with:
417
+ ```markdown
418
+ # Changelog
419
+
420
+ - This file tracks all skill executions by version for this application.
421
+ - The highest version recorded here is the current application version.
422
+ - Skills MUST NOT execute for a version lower than the highest version in this file.
423
+
424
+ ---
425
+ ```
426
+ 2. Search for a `## {version}` heading matching the current version.
427
+ 3. If the section **exists**: append a new row to its table.
428
+ 4. If the section **does not exist**: insert a new section after the `---` below the context header and before any existing `## vX.Y.Z` section (newest-first ordering), with a new table header and the first row.
429
+ 5. Row format: `| {YYYY-MM-DD} | {application_name} | modelgen-relational | {module or "All"} | Generated relational module models |`
430
+ 6. **Never modify or delete existing rows.**
431
+
432
+ ## Output Specification
433
+
434
+ For each module, produce exactly **two files** plus one **root-level summary file**:
435
+
436
+ ### 1. ERD Mermaid File: `{module-dir}/erd.mermaid`
437
+
438
+ A valid Mermaid ER diagram file. Requirements:
439
+
440
+ - Use the `erDiagram` diagram type
441
+ - Include ALL entities from the entity catalog for this module
442
+ - Show all attributes with data types for each entity
443
+ - Mark PK and FK fields
444
+ - Show all relationships with cardinality using Mermaid notation:
445
+
446
+ | Marker | Meaning |
447
+ |--------|---------|
448
+ | `\|\|` | Exactly one |
449
+ | `o\|` | Zero or one |
450
+ | `\|{` | One or more |
451
+ | `o{` | Zero or more |
452
+
453
+ - Use descriptive relationship labels (verbs from the stories)
454
+ - Entity names in UPPER_SNAKE_CASE **with 3-character module prefix** (e.g., `USM_USER`, `USM_ROLE`)
455
+ - Attribute names in snake_case in the diagram
456
+ - Mermaid ERD does not natively support version annotations. The ERD represents the
457
+ **cumulative model across all versions**. Per-element version tracking is captured
458
+ in the companion `model.md` file. Add a Mermaid comment at the top of the file
459
+ listing the versions included and the module prefix mapping.
460
+
461
+ Example structure:
462
+ ```mermaid
463
+ %% Module: User Management | Prefix: USM
464
+ %% Versions included: 1.0, 1.1
465
+ erDiagram
466
+ USM_USER {
467
+ uuid id PK
468
+ string username
469
+ string email
470
+ string status
471
+ timestamp created_at
472
+ string created_by
473
+ timestamp updated_at
474
+ string updated_by
475
+ }
476
+ USM_ROLE {
477
+ uuid id PK
478
+ string name
479
+ string description
480
+ }
481
+ USM_USER_ROLE {
482
+ uuid id PK
483
+ uuid user_id FK
484
+ uuid role_id FK
485
+ timestamp assigned_at
486
+ string assigned_by
487
+ }
488
+ USM_USER ||--o{ USM_USER_ROLE : "has"
489
+ USM_ROLE ||--o{ USM_USER_ROLE : "assigned to"
490
+ ```
491
+
492
+ ### 2. Model Documentation: `{domain-dir}/model.md`
493
+
494
+ A markdown file containing the following sections. Use tables for all structured data.
495
+
496
+ #### Document Structure
497
+
498
+ ```markdown
499
+ # Module Model: {Module Name}
500
+
501
+ ## 1. Module Prefix Map
502
+
503
+ | Module | Prefix | Auto-Generated | Override |
504
+ |--------|--------|----------------|----------|
505
+
506
+ (e.g., User Management | USM | Yes | — )
507
+
508
+ ## 2. Entity Catalog
509
+
510
+ | Entity | DDD Type | Bounded Context | Key Attributes | Relationships | Source Stories | Version |
511
+ |--------|----------|-----------------|----------------|---------------|---------------|---------|
512
+
513
+ ## 3. Base Entity Specification
514
+ (If applicable — audit fields, soft delete, versioning inherited by all entities)
515
+
516
+ ## 4. Attribute Detail
517
+ (One subsection per entity with full attribute table)
518
+
519
+ ### 4.x {Entity Name}
520
+
521
+ | Attribute | Type | Nullable | Constraints | Source | Source Story | Version |
522
+ |-----------|------|----------|-------------|--------|--------------|---------|
523
+
524
+ ## 5. Relationship Catalog
525
+
526
+ | Source Entity | Target Entity | Cardinality | Join Entity | Cascade | Business Rule | Source Story | Version |
527
+ |---------------|---------------|-------------|-------------|---------|---------------|-------------|---------|
528
+
529
+ ## 6. Enum Definitions
530
+ (One subsection per enum)
531
+
532
+ ### 6.x {Enum Name}
533
+
534
+ | Value | Description | Source Story | Version |
535
+ |-------|-------------|--------------|---------|
536
+
537
+ ## 7. Domain Events
538
+
539
+ | Event Name | Trigger Story | Aggregate | Payload Fields | Version |
540
+ |------------|---------------|-----------|----------------|---------|
541
+
542
+ ## 8. Bounded Context Summary
543
+
544
+ | Context | Aggregates | Description |
545
+ |---------|------------|-------------|
546
+
547
+ ## 9. Assumptions and Ambiguities
548
+
549
+ | Story ID | Entity / Attribute | Assumption Made | Clarification Needed | Version |
550
+ |----------|--------------------|-----------------|----------------------|---------|
551
+
552
+ ## 10. Changelog
553
+
554
+ ### Version {new-version} (from {previous-version})
555
+
556
+ #### Added
557
+ | Element Type | Name | Description | Source Stories |
558
+ |---|---|---|---|
559
+
560
+ #### Modified
561
+ | Element Type | Name | Change Description | Previous | New | Source Stories |
562
+ |---|---|---|---|---|---|
563
+
564
+ #### Removed
565
+ | Element Type | Name | Reason | Former Source Stories |
566
+ |---|---|---|---|
567
+
568
+ #### Flagged for Review
569
+ | Element Type | Name | Issue | Recommendation |
570
+ |---|---|---|---|
571
+ ```
572
+
573
+ ### 3. Root Summary: `MODEL.md`
574
+
575
+ After generating all per-module files, produce a single `MODEL.md` in the **root output directory**.
576
+ This file serves as the entry point and table of contents for the entire model extraction output.
577
+
578
+ #### Document Structure
579
+
580
+ ```markdown
581
+ # Module Model Summary
582
+
583
+ > Generated from {total story count} user stories across {module count} modules.
584
+
585
+ ## Modules
586
+
587
+ | # | Module | Prefix | Entities | Relationships | Versions | Stories |
588
+ |---|--------|--------|----------|---------------|----------|---------|
589
+
590
+ (One row per module. Entities = count of entities in that module. Relationships = count of
591
+ relationships. Versions = comma-separated list of versions included. Stories = count of
592
+ source stories for that module.)
593
+
594
+ ## Table of Contents
595
+
596
+ ### {Module Name} (`{prefix}`)
597
+
598
+ > {One-line summary: e.g., "Manages user accounts, roles, and permissions."}
599
+
600
+ - **Model Documentation:** [{module-kebab}/model.md](./{module-kebab}/model.md)
601
+ - **ERD Diagram:** [{module-kebab}/erd.mermaid](./{module-kebab}/erd.mermaid)
602
+ - **Entities:** {comma-separated PascalCase entity names}
603
+ - **Key Relationships:** {2–3 most significant relationships in natural language}
604
+
605
+ (Repeat for each module, in the same order as the Modules table.)
606
+
607
+ ## Cross-Module Dependencies
608
+
609
+ | Source Module | Target Module | Dependency | Noted In |
610
+ |---------------|---------------|------------|----------|
611
+
612
+ (List any cross-module dependencies flagged in assumptions tables. If none, state "No
613
+ cross-module dependencies were identified.")
614
+
615
+ ## Assumptions Summary
616
+
617
+ | Module | Count | Critical |
618
+ |--------|-------|----------|
619
+
620
+ (Count = total assumptions for that module. Critical = count of assumptions marked as
621
+ needing clarification. Links to the respective module's Assumptions and Ambiguities section.)
622
+
623
+ ## Update History
624
+
625
+ | Version | Date | Modules Affected | Added | Modified | Removed | Flagged |
626
+ |---|---|---|---|---|---|---|
627
+ ```
628
+
629
+ ---
630
+
631
+ ## Constraints
632
+
633
+ 1. **No module inference.** The skill does not guess which module a story belongs to.
634
+ Module-to-story mapping must be provided by the user.
635
+ 2. **Modules are independent.** Do not create relationships between entities in different
636
+ modules. Flag potential cross-module dependencies in the assumptions table.
637
+ 3. **Concise output.** Produce only the final consolidated tables. Do not include
638
+ intermediate linguistic analysis, noun classification lists, or phase-by-phase
639
+ working notes in the deliverables.
640
+ 4. **Traceability.** Every entity, attribute, and relationship in the output must
641
+ reference its originating user story ID or NFR.
642
+ 5. **Ambiguity transparency.** When making assumptions, always record them in the
643
+ Assumptions and Ambiguities table with a clarification question.
644
+
645
+ ---
646
+
647
+ ## File Naming Convention
648
+
649
+ All output files are written under the user-specified output directory, organized as
650
+ one subdirectory per module. Module names are converted to kebab-case for directory names.
651
+
652
+ Given an output directory `/path/to/output` and three modules — "User Management",
653
+ "Order Management", and "Inventory":
654
+
655
+ ```
656
+ /path/to/output/
657
+ ├── MODEL.md # Root summary and table of contents
658
+ ├── user-management/
659
+ │ ├── erd.mermaid
660
+ │ └── model.md
661
+ ├── order-management/
662
+ │ ├── erd.mermaid
663
+ │ └── model.md
664
+ └── inventory/
665
+ ├── erd.mermaid
666
+ └── model.md
667
+ ```
668
+
669
+ The root directory contains:
670
+ - `MODEL.md` — summary and table of contents linking to all module models
671
+
672
+ Each subdirectory contains exactly two files:
673
+ - `erd.mermaid` — the Mermaid ERD diagram for that module
674
+ - `model.md` — the full model documentation for that module
675
+
676
+ ---
677
+
678
+ ## Quality Gates (Self-Review)
679
+
680
+ Before presenting output, verify:
681
+
682
+ - [ ] Every user story has at least one corresponding entity
683
+ - [ ] Every entity has at least one source user story
684
+ - [ ] Every entity has an `id` field (UUID, DB-generated) and audit fields (or inherits from base entity)
685
+ - [ ] All primary keys use UUID type with database-level generation (not application-generated)
686
+ - [ ] Every state-change verb has a corresponding enum with transition rules
687
+ - [ ] Every "assign X to Y" pattern has a join entity
688
+ - [ ] Every NFR has been analyzed for model impact
689
+ - [ ] All M:N relationships have join entities
690
+ - [ ] No aggregate exceeds 4–5 entities
691
+ - [ ] No entity exceeds 15–20 attributes (decompose into value objects if larger)
692
+ - [ ] Naming conventions are consistent (PascalCase entities, camelCase attributes)
693
+ - [ ] The Mermaid ERD is syntactically valid
694
+ - [ ] All ambiguities are recorded with proposed defaults
695
+ - [ ] Root `MODEL.md` is generated with correct links to all module subdirectories
696
+ - [ ] `MODEL.md` module statistics (entity count, relationship count, story count) match actual output
697
+
698
+ ### Update Mode Quality Gates
699
+
700
+ When running in update mode, additionally verify:
701
+
702
+ - [ ] All removed stories have their model elements addressed (removed or re-sourced)
703
+ - [ ] All modified stories have their model elements re-evaluated
704
+ - [ ] No orphaned elements remain without explicit KEEP justification
705
+ - [ ] Changelog accurately reflects all changes
706
+ - [ ] Version annotations are correct (new elements get new version, unchanged keep original)
707
+ - [ ] MODEL.md Update History is current