@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,1381 @@
1
+ ---
2
+ name: testgen-functional
3
+ model: claude-opus-4-8
4
+ effort: high
5
+ description: >
6
+ Generate Playwright E2E test plan and specification documents from project artifacts
7
+ (user stories, module models, mockups, specifications). Produces a TEST_PLAN.md root
8
+ summary and per-module TEST_SPEC.md files containing test scenarios, data seeding
9
+ scripts, and cleanup scripts — all as detailed Markdown blueprints, not actual test code.
10
+ Input: application name (mandatory), version (mandatory), module (optional).
11
+ Output: TEST_PLAN.md + per-module TEST_SPEC.md files in the auto-resolved test output folder.
12
+ Trigger on keywords: "generate test plan",
13
+ "generate test spec", "create test specification", "E2E test plan", "Playwright test plan",
14
+ "test plan from user stories", "test spec from PRD.md", "generate test scenarios",
15
+ "create test blueprint". Accepts application name and version as input
16
+ (e.g., `/testgen-functional hub_middleware v1.0.3`).
17
+ Optionally accepts a module name to limit generation to test specs for that module only
18
+ (e.g., `/testgen-functional hub_middleware v1.0.3 module:Location Information`).
19
+ Automatically excludes strikethrough (deprecated/removed) items.
20
+ ---
21
+
22
+ # Test Generator
23
+
24
+ Generate Playwright E2E test plan and specification documents from PRD.md and
25
+ related project artifacts. Outputs are **Markdown documents** (TEST_PLAN.md and per-module
26
+ TEST_SPEC.md files) that serve as detailed blueprints for a developer or coding agent to
27
+ implement actual Playwright test code. This skill does NOT generate Playwright code.
28
+
29
+ ## Core Concept: 4-Layer Data Seeding Strategy
30
+
31
+ Every module is classified into one of 4 data seeding layers. This classification drives
32
+ the seeding strategy, execution order, and test design for each module.
33
+
34
+ | Layer | Purpose | Detection Heuristic | Seeding Tool |
35
+ |-------|---------|---------------------|--------------|
36
+ | L1: Auth | Test user setup | Modules about User/Auth; SSO/OAuth references in CLAUDE.md | Auth provider CLI (e.g., Keycloak `kcadm`, Laravel `artisan tinker`, or DB seed) |
37
+ | L2: Reference Data | Admin-configured master data | User stories with "manage", "configure" by admin roles; no inbound message queue trigger | Direct DB insert via database CLI (e.g., `mongosh`, `mysql`, `psql`, `artisan tinker`) |
38
+ | L3: Transactional Data | Message-driven data | NFRs mentioning "incoming messages", "message queue", "inbound messages"; Reference section linking to MESSAGE_*.md files | Message queue publish via broker CLI (e.g., `rabbitmqadmin`) |
39
+ | L4: Side-Effect Data | Data generated as byproduct | NFRs mentioning "auto-generated", "system generated", "automatically"; modules like Activities, Audit Trail, Notifications | No seeding — asserted as side effects of L2/L3 operations |
40
+
41
+ ## Input
42
+
43
+ This skill uses standardized input resolution. Provide:
44
+
45
+ | Argument | Required | Example | Description |
46
+ |----------|----------|---------|-------------|
47
+ | `<application>` | Yes | `hub_middleware` | Application name to locate the context folder |
48
+ | `<version>` | Yes | `v1.0.3` | Version to scope processing |
49
+ | `module:<name>` | No | `module:Location Information` | Limit to a single module |
50
+
51
+ ### Application Folder Resolution
52
+
53
+ The application name is matched against root-level application folders:
54
+ 1. Strip any leading `<number>_` prefix from folder names
55
+ 2. Match case-insensitively
56
+ 3. Accept snake_case, kebab-case, or title-case input
57
+ 4. If no match found, list available applications and stop
58
+
59
+ ### Auto-Resolved Paths
60
+
61
+ | File | Resolved Path |
62
+ |------|---------------|
63
+ | PRD.md | `<app_folder>/context/PRD.md` |
64
+ | Module Models | `<app_folder>/context/model/` |
65
+ | Specifications | `<app_folder>/context/specification/` |
66
+ | HTML Mockups | `<app_folder>/context/mockup/` |
67
+ | References | `<app_folder>/context/reference/` |
68
+ | Output (test) | `<app_folder>/context/test/` |
69
+
70
+ ### Example Invocations
71
+
72
+ - `/testgen-functional hub_middleware v1.0.3` (all modules, up to v1.0.3)
73
+ - `/testgen-functional hub_middleware v1.0.3 module:Location Information` (one module)
74
+ - `/testgen-functional "Hub Middleware" v1.0.3 module:Employer` (title-case)
75
+
76
+ ### Version and Module Filtering
77
+
78
+ - Only include user stories, NFRs, constraints, references, test instructions, and bug fixes
79
+ from sections whose version tag is **less than or equal to** the target version
80
+ - If a module is provided (e.g., `module:Location Information`), only generate the test spec
81
+ for that specific module. TEST_PLAN.md is still generated but scoped to that module.
82
+ - If no module is provided, process all modules (default behavior)
83
+
84
+ **Argument parsing**: The `module:` prefix is the canonical form. Also accept:
85
+ - `module:"Location Information"` (quoted, with space)
86
+ - `module:location_information` (snake_case — convert to title-case for matching)
87
+ - Natural language: `for Location Information module`, `only Location Information`
88
+
89
+ ---
90
+
91
+ ## Version Gate
92
+
93
+ 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`):
94
+
95
+ 1. If `<app_folder>/CHANGELOG.md` does not exist, skip this check (first-ever execution for this application).
96
+ 2. If `<app_folder>/CHANGELOG.md` exists, scan all `## vX.Y.Z` headings and determine the **highest version** using semantic versioning comparison.
97
+ 3. Compare the requested version against the highest version:
98
+ - If requested version **>=** highest version: proceed normally.
99
+ - 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.
100
+
101
+ ## Workflow
102
+
103
+ ### Step 1: Parse PRD.md
104
+
105
+ Read the file and extract:
106
+
107
+ 1. **Application name**: Derive from the parent folder name containing PRD.md.
108
+ Strip leading number and underscore prefix, then title-case.
109
+ Example: `1_hub_middleware` -> "Hub Middleware"
110
+
111
+ 2. **Application initials**: First letter of each word, uppercase.
112
+ Example: `1_hub_middleware` -> "HM"
113
+
114
+ 3. **Module categories and modules**: Each `# Module Category` heading groups related modules.
115
+ Each `## Module Name` section under a category is a module.
116
+ Record the module name, its category, and its description (the line after the heading).
117
+
118
+ 4. **User stories per module**: Lines matching `- [USxx#####] As a {Role} user, I want to...`
119
+ Extract: tag, role, action summary, sub-items (indented lines under the story).
120
+
121
+ 5. **NFRs per module**: Lines matching `- [NFRxx####] ...`
122
+ Extract: tag, full text.
123
+
124
+ 6. **Constraints per module**: Lines matching `- [CONSxx###] ...`
125
+ Extract: tag, full text.
126
+
127
+ 7. **References per module**: Lines matching `- [REFxx####] ...`
128
+ Extract: tag, description, linked file path (if any).
129
+
130
+ 8. **Test instructions per module**: Lines matching `- [TSTxx####] ...` under `### Test`
131
+ sections. These contain human-specified test setup instructions, test data requirements,
132
+ test edge cases, and test user configurations that MUST be incorporated into the test
133
+ plan and specs as **additional context** on top of the standard analysis of User Stories,
134
+ NFRs, Constraints, Module Models, HTML Mockups, and Technical Specs.
135
+ Extract: tag (e.g., `[TSTHM0003]`), version tag, full text of each bullet point
136
+ (including sub-bullets which provide detailed test parameters).
137
+ Test instructions serve as human-guided test scenario hints and edge cases that the
138
+ test spec generator should use to enrich and complement the auto-derived test scenarios.
139
+
140
+ 9. **Bug fixes per module**: Content under `### Bug` sections. These document previously
141
+ fixed bugs from prior development cycles. Each bug entry describes what was broken and
142
+ how it was fixed. Extract: version tag, bug tag (e.g., `[BUG-024]`), description.
143
+
144
+ 10. **Unique roles**: Collect all distinct roles from user stories.
145
+
146
+ 11. **Version tag per item**: Each `### User Story`, `### Non Functional Requirement`,
147
+ `### Constraint`, `### Test`, and `### Bug` section contains version blocks formatted
148
+ as `[v1.0.x]`. Items listed under a version tag belong to that version. Track the
149
+ version for every extracted user story, NFR, constraint, reference, test instruction,
150
+ and bug fix. Carry this version through to the Source Artifacts table, test scenario
151
+ Source fields, and Traceability Matrix.
152
+
153
+ 12. **Deprecated item tracking**: Items marked with strikethrough in a newer version may
154
+ have been replaced by a new item. When an item is removed in version X and replaced by
155
+ item Y, track this replacement. Include a "Removed / Replaced" subsection in the
156
+ Source Artifacts of the TEST_SPEC.md, following the same format used in SPEC.md:
157
+ | ID | Type | Removed In | Replaced By | Reason |
158
+
159
+ #### 1a: Version Filtering and Strikethrough Exclusion (MANDATORY)
160
+
161
+ PRD.md is a version-controlled document. Each section has a version tag in square
162
+ brackets, e.g., `[v1.0.1]`. Items may also be marked with strikethrough (`~~`).
163
+
164
+ **Strikethrough exclusion** (always applied, regardless of version parameter):
165
+ - Any line wrapped in `~~strikethrough~~` markup MUST be excluded from processing
166
+ - This includes user stories, NFRs, constraints, references, test instructions, and bug fixes
167
+ - Example: `~~[USHM00006] As a Hub Administrator user, I want to...~~` → **SKIP**
168
+ - Partially strikethrough lines (where only part is struck) should still be excluded
169
+ if the tag identifier is within the strikethrough
170
+
171
+ **Version filtering** (applied only when a target version is provided):
172
+ - Each section under a module has one or more version tags like `[v1.0.0]` or `[v1.0.1]`
173
+ - Items listed under a version tag belong to that version
174
+ - When a target version is specified (e.g., `v1.0.1`):
175
+ - **Include** items from sections whose version tag is **<= target version**
176
+ - **Exclude** items from sections whose version tag is **> target version**
177
+ - Version comparison uses semantic versioning: compare major, then minor, then patch
178
+ - When no target version is specified, include all items from all versions (but still
179
+ exclude strikethrough items)
180
+
181
+ #### 1b: Module Filtering (applied only when a module argument is provided)
182
+
183
+ When a `module` argument is present:
184
+
185
+ 1. **Match the specified module** against the list of parsed modules (case-insensitive).
186
+ Also accept snake_case input by converting to title-case for comparison.
187
+ 2. If no module matches, stop and report the available module names to the user.
188
+ 3. When module-filtered, generate TEST_PLAN.md scoped to that module and only that module's
189
+ TEST_SPEC.md file.
190
+
191
+ ---
192
+
193
+ ### Step 2: Extract Project Information from CLAUDE.md (Already in Context)
194
+
195
+ CLAUDE.md is automatically loaded into context. Extract the following from it:
196
+
197
+ 1. **Project name and description**
198
+ 2. **Infrastructure details**:
199
+ - Database type and version (MongoDB, MySQL, PostgreSQL)
200
+ - Database name(s) and connection info
201
+ - Message Queue type and version (RabbitMQ)
202
+ - Message Queue connection info (host, port, credentials)
203
+ - SSO/Auth type and version (Keycloak)
204
+ - SSO connection info (host, admin credentials, CLI path)
205
+ 3. **CLI tools available**: Map each infrastructure component to its CLI tool based on
206
+ what CLAUDE.md declares. Common mappings:
207
+ - MongoDB → `mongosh` (connection string from CLAUDE.md)
208
+ - MySQL → `mysql` (host, port, credentials from CLAUDE.md)
209
+ - PostgreSQL → `psql` (host, port, credentials from CLAUDE.md)
210
+ - RabbitMQ → `rabbitmqadmin` (host, port, credentials from CLAUDE.md)
211
+ - Keycloak → `kcadm` (CLI path, host, admin credentials from CLAUDE.md)
212
+ - Laravel artisan → `php artisan` (for seeder commands, tinker, queue management)
213
+
214
+ The skill auto-detects which tools apply from CLAUDE.md dependencies. Do not assume
215
+ a specific tech stack — read it from the project context.
216
+ 4. **Application dependencies**: What this application depends on (DB, MQ, SSO)
217
+ 5. **Environment variable mapping**: Map each infrastructure value from CLAUDE.md to a
218
+ standardized environment variable name. These env vars will be referenced in seeding
219
+ scripts and helper classes so that generated Playwright tests are portable across
220
+ machines. Common mappings:
221
+ - Database connection string → `TEST_DB_URI` (MongoDB) or `TEST_DB_HOST`, `TEST_DB_PORT`,
222
+ `TEST_DB_USER`, `TEST_DB_PASSWORD`, `TEST_DB_NAME` (MySQL/PostgreSQL)
223
+ - Message Queue → `TEST_MQ_HOST`, `TEST_MQ_PORT`, `TEST_MQ_USER`, `TEST_MQ_PASSWORD`,
224
+ `TEST_MQ_VHOST` (or `TEST_MQ_URL` for AMQP URL)
225
+ - SSO/Auth → `TEST_SSO_HOST`, `TEST_SSO_ADMIN_USER`, `TEST_SSO_ADMIN_PASSWORD`,
226
+ `TEST_SSO_CLI_PATH` (e.g., path to `kcadm.bat` or `kcadm.sh`), `TEST_SSO_REALM`
227
+ - Application → `TEST_APP_BASE_URL` (base URL for Playwright navigation)
228
+ - Additional CLI paths → `TEST_PHP_PATH`, `TEST_JAVA_HOME`, `TEST_MAVEN_PATH` (as needed)
229
+
230
+ Only include env vars for infrastructure components that actually exist in CLAUDE.md.
231
+
232
+ ---
233
+
234
+ ### Step 2a: Extract PRD.md Extended Sections
235
+
236
+ After extracting project information, check PRD.md for the following extended sections:
237
+
238
+ #### Design System
239
+
240
+ If PRD.md contains a `# Design System` section with a file reference:
241
+ 1. Resolve and read the referenced `DESIGN_SYSTEM.md` file
242
+ 2. Extract component patterns and expected visual appearances (e.g., badge styles, button patterns)
243
+ 3. Use these to generate visual consistency assertions in TEST_SPEC.md (e.g., "Assert status badge has class containing 'bg-green' for Active status", "Assert buttons use rounded-lg class")
244
+
245
+ If absent, skip visual consistency assertions.
246
+
247
+ #### Architecture Principle
248
+
249
+ If PRD.md contains an `# Architecture Principle` section, extract patterns that affect test strategy:
250
+
251
+ | Pattern | Test Impact |
252
+ |---|---|
253
+ | "Event-driven" | L3 transactional data may have async propagation delay — tests MUST include wait/retry patterns (e.g., `await expect.poll(() => ...).toPass({ timeout: 10000 })`) for eventual consistency assertions |
254
+ | "Message driven" | Confirms L3 classification heuristics — modules receiving data via message queues are L3 |
255
+ | "Stateless" | Tests should handle token refresh/expiry scenarios; include JWT expiry test case |
256
+ | ACK/NACK patterns | Generate assertion steps verifying messages published to correct queues with expected correlation IDs |
257
+ | "At-least-once delivery" | Include idempotency test — send same message twice, verify no duplicate records |
258
+
259
+ If absent, proceed with existing layer classification heuristics.
260
+
261
+ #### High Level Process Flow
262
+
263
+ If PRD.md contains a `# High Level Process Flow` section:
264
+ 1. Parse all named process flows with their ordered steps
265
+ 2. Each process flow becomes an **end-to-end test scenario** (or test suite) in TEST_SPEC.md:
266
+ - Happy path: each step → a test step with specific assertions
267
+ - Error paths (if described): each generates a separate error scenario
268
+ - ACK/NACK patterns generate queue assertion steps (verify messages in outbound queues)
269
+ 3. Process flows are the **primary source for L3 (Transactional Data) test scenarios**
270
+ 4. Process flows reveal cross-module dependencies that must be included in the test execution order
271
+
272
+ If absent, derive L3 scenarios from NFRs mentioning "message queue" or "incoming message" only (existing behavior).
273
+
274
+ ---
275
+
276
+ ### Step 3: Load Module Models
277
+
278
+ For each module, look for `<app_folder>/context/model/{module-kebab}/model.md`
279
+
280
+ Convert module name to kebab-case:
281
+ - Lowercase the module name, replace spaces with hyphens
282
+ - Examples: "Location Information" → `location-information`, "Employer" → `employer`
283
+
284
+ If the model file exists, extract:
285
+
286
+ 1. **Collection Catalog** (Section 2): collection names, DDD types, document types
287
+ 2. **Field Details** (Section 5): field name, type, nullable, constraints per collection
288
+ 3. **Embedded Document Definitions** (Section 6): embedded type name and sub-fields
289
+ 4. **Enum Definitions** (Section 7): enum name and allowed values
290
+ 5. **Index Recommendations** (Section 9): indexed fields (used for search/filter identification)
291
+ 6. **Module Prefix**: The prefix used for collections (e.g., `LIN`, `EMP`, `QUO`)
292
+
293
+ This data is used to:
294
+ - Generate realistic sample data for seeding scripts
295
+ - Identify searchable/filterable fields for search test scenarios
296
+ - Determine collection names for DB insert/cleanup commands
297
+ - Map enum values to expected UI dropdown options
298
+
299
+ ---
300
+
301
+ ### Step 4: Load Specifications
302
+
303
+ For each module, look for `<app_folder>/context/specification/{module-kebab}/SPEC.md`
304
+
305
+ If found, extract:
306
+
307
+ 1. **Traceability section**: Maps user stories → collections → mockup screens
308
+ 2. **Public API** (Service Interface): Method signatures showing available operations
309
+ 3. **DTOs**: Field definitions showing what the API exposes
310
+ 4. **Validation rules**: Any documented validation logic
311
+ 5. **Business logic rules**: Documented business rules and constraints
312
+ 6. **Version tags**: If the SPEC.md traceability section uses versioned tables
313
+ (with ID | Version | Description columns), extract the version for each item.
314
+ Cross-reference with PRD.md version tags for consistency.
315
+
316
+ This data enriches test scenarios with:
317
+ - Expected API behavior for assertions
318
+ - Validation rules to test (boundary conditions, required fields)
319
+ - Business rule scenarios
320
+
321
+ ---
322
+
323
+ ### Step 5: Load Mockups
324
+
325
+ For each module, scan `<app_folder>/context/mockup/{role_snake_case}/content/{module_snake_case}*.html`
326
+
327
+ If mockup files exist, extract:
328
+
329
+ 1. **DOM selectors**: IDs and classes used on key elements (tables, forms, buttons)
330
+ 2. **Navigation paths**: HTMX `hx-get` routes showing page navigation flow
331
+ 3. **Form field names**: Input names and types from form elements
332
+ 4. **Table column headers**: `<th>` content from data tables
333
+ 5. **Tab structure**: Tab names and their linked content files
334
+ 6. **Action buttons**: View/Edit/Delete/Create button patterns and their targets
335
+ 7. **Sidebar navigation**: Menu items and their routes for the module
336
+
337
+ This data provides:
338
+ - Actual CSS selectors for Playwright `page.locator()` calls
339
+ - Real navigation paths for `page.goto()` and click sequences
340
+ - Form field identifiers for fill operations
341
+ - Expected table column names for content assertions
342
+
343
+ ---
344
+
345
+ ### Step 6: Load Message References
346
+
347
+ Scan `<app_folder>/context/reference/message/MESSAGE_*.md` and `REF_*.md`
348
+
349
+ For modules classified as L3 (Transactional Data), these files provide:
350
+
351
+ 1. **Message structure**: JSON schema of inbound messages
352
+ 2. **Sample payloads**: Expanded JSON examples with realistic sample data
353
+ 3. **Referenced sub-structures**: `$REF_*.md` references that compose the full message
354
+ 4. **Metadata fields**: correlation ID, origin system, type, command, corridor info
355
+
356
+ This data is used to generate:
357
+ - Sample message JSON payloads for RabbitMQ seeding scripts
358
+ - Expected field values for asserting message-driven data in the UI
359
+
360
+ ---
361
+
362
+ ### Step 7: Classify Modules into Layers
363
+
364
+ For each module, apply the following classification heuristics **in order** (first match wins):
365
+
366
+ **L1: Auth** — Module is classified as L1 if:
367
+ - Module name is "User" or contains "Authentication", "Authorization", "SSO"
368
+ - User stories reference "profile", "password", "login", "logout"
369
+ - NFRs reference "JWT", "SSO", "Keycloak", "token", "authentication"
370
+
371
+ **L4: Side-Effect Data** — Module is classified as L4 if:
372
+ - Module name is "Activities", "Audit Trail", "Notification", or similar
373
+ - NFRs mention "auto-generated", "system generated", "automatically logged"
374
+ - NFRs mention "will be logged", "will be recorded automatically"
375
+ - No user stories with "manage" or "configure" actions (only "view" actions)
376
+
377
+ **L3: Transactional Data** — Module is classified as L3 if:
378
+ - NFRs mention "incoming messages", "message queue", "inbound messages"
379
+ - Reference section links to `MESSAGE_*.md` files
380
+ - NFRs mention "unique view ... based on incoming"
381
+ - User stories are primarily "view" and "search" (no "manage"/"configure"/"add"/"create")
382
+
383
+ **L2: Reference Data** — Module is classified as L2 if:
384
+ - User stories contain "manage", "configure", "add", "create", "edit", "delete"
385
+ - Actions are performed by admin roles
386
+ - No message queue triggers (no MESSAGE_*.md references)
387
+ - Data is master/reference data maintained through the UI
388
+
389
+ **Record the classification** for each module with the reasoning (which heuristic matched).
390
+
391
+ ---
392
+
393
+ ### Step 8: Determine Dependencies
394
+
395
+ Build a dependency graph between modules:
396
+
397
+ 1. **Model references**: If a module's model references another module's collection
398
+ (e.g., `countryCode` referencing `lin_countries`), the referencing module depends on
399
+ the referenced module.
400
+
401
+ 2. **NFR references**: If NFRs state data is "based on incoming X messages" and X is
402
+ another module, there is a dependency.
403
+
404
+ 3. **User story references**: If user stories mention "view associated X" where X is
405
+ another module, there is a dependency.
406
+
407
+ 4. **Layer ordering**: L1 → L2 → L3 → L4 (higher layers depend on lower layers implicitly)
408
+
409
+ 5. **Within-layer dependencies**: Within L2, reference data that other L2 modules depend on
410
+ must be seeded first (e.g., Location Information before Employer, since employers have
411
+ country codes).
412
+
413
+ **Output**: An ordered list of modules for test execution, respecting all dependencies.
414
+
415
+ ---
416
+
417
+ ### Step 9: Generate TEST_PLAN.md
418
+
419
+ Write `<app_folder>/context/test/TEST_PLAN.md` with the following structure:
420
+
421
+ ```markdown
422
+ # E2E Test Plan: {Application Name}
423
+
424
+ **Generated**: {date}
425
+ **Source**: {PRD.md path}
426
+ **Version**: {target version or "all versions"}
427
+ **Versions Covered**: v1.0.0 — v{LATEST_VERSION}
428
+ **Module Filter**: {module name or "all modules"}
429
+
430
+ ---
431
+
432
+ ## 1. Application Overview
433
+
434
+ - **Application**: {Application Name} ({Initials})
435
+ - **Description**: {from PRD.md context line or CLAUDE.md}
436
+ - **Stack**: {from CLAUDE.md — e.g., "Spring Boot 3 + MongoDB + Keycloak + RabbitMQ" or "Laravel 12 + MySQL + Keycloak + RabbitMQ"}
437
+
438
+ ---
439
+
440
+ ## 2. Test Infrastructure
441
+
442
+ | Component | Type | CLI Tool | Connection |
443
+ |-----------|------|----------|------------|
444
+ | Database | {type + version from CLAUDE.md} | {CLI tool for that DB} | {connection string} |
445
+ | Message Queue | {type + version from CLAUDE.md} | {CLI tool for that MQ} | {AMQP URL} |
446
+ | SSO / Auth | {type + version from CLAUDE.md} | {CLI tool or artisan command} | {host URL} |
447
+
448
+ ### CLI Commands Reference
449
+
450
+ {For each infrastructure component, provide the exact CLI command template with
451
+ connection parameters filled in from CLAUDE.md}
452
+
453
+ ---
454
+
455
+ ## 2a. Environment Variables (.env)
456
+
457
+ {Generate a `.env.example` block listing all environment variables needed by Playwright
458
+ test helpers and seeding scripts. Values come from CLAUDE.md. This block serves as the
459
+ template for each developer's local `.env` file (which is git-ignored). Only include
460
+ variables for infrastructure components that exist in CLAUDE.md.}
461
+
462
+ ```dotenv
463
+ # Application
464
+ TEST_APP_BASE_URL={base URL from CLAUDE.md, e.g., http://localhost:8080}
465
+
466
+ # Database ({type from CLAUDE.md})
467
+ {If MongoDB:}
468
+ TEST_DB_URI={full connection string from CLAUDE.md}
469
+ {If MySQL or PostgreSQL:}
470
+ TEST_DB_HOST={host}
471
+ TEST_DB_PORT={port}
472
+ TEST_DB_USER={username}
473
+ TEST_DB_PASSWORD={password}
474
+ TEST_DB_NAME={database name}
475
+
476
+ # Message Queue ({type from CLAUDE.md}) — include only if MQ exists
477
+ TEST_MQ_HOST={host}
478
+ TEST_MQ_PORT={port}
479
+ TEST_MQ_USER={username}
480
+ TEST_MQ_PASSWORD={password}
481
+ TEST_MQ_VHOST={vhost}
482
+ TEST_MQ_URL={full AMQP URL}
483
+
484
+ # SSO / Auth ({type from CLAUDE.md}) — include only if SSO exists
485
+ TEST_SSO_HOST={host URL, e.g., http://localhost:8180}
486
+ TEST_SSO_ADMIN_USER={admin username}
487
+ TEST_SSO_ADMIN_PASSWORD={admin password}
488
+ TEST_SSO_CLI_PATH={absolute path to CLI tool, e.g., /opt/keycloak/bin/kcadm.sh}
489
+ TEST_SSO_REALM={test realm name}
490
+ ```
491
+
492
+ **Important**: The `.env` file MUST be added to `.gitignore`. The `.env.example` file
493
+ (with placeholder descriptions, NOT actual credentials) is committed to the repository
494
+ so that other developers know which variables to configure.
495
+
496
+ ---
497
+
498
+ ## 3. Test Users
499
+
500
+ {Populate this table from TWO sources:
501
+ 1. `### Test` sections in PRD.md — human-specified test users with exact credentials
502
+ and roles. These take precedence and MUST be used as-is (e.g., the Authentication
503
+ module's `### Test` section may specify exact usernames, passwords, and roles).
504
+ 2. Auto-derived from user story roles — for any role NOT already covered by a
505
+ `### Test` section, generate a test user entry.}
506
+
507
+ | User | Role | Purpose | Seeding Method | Source |
508
+ |------|------|---------|----------------|--------|
509
+ | {username} | {role} | {what this user tests} | {Keycloak CLI / DB seed} | {PRD.md `### Test` or Auto-derived} |
510
+
511
+ ---
512
+
513
+ ## 4. Layer Classification Summary
514
+
515
+ | Module | Category | Layer | Seeding Strategy | Versions | Dependencies |
516
+ |--------|----------|-------|-----------------|----------|--------------|
517
+ | {module} | {System/Business} | {L1/L2/L3/L4} | {strategy} | {versions from PRD.md} | {deps} |
518
+
519
+ ---
520
+
521
+ ## 5. Execution Order
522
+
523
+ {Ordered list of modules, respecting layer ordering and within-layer dependencies}
524
+
525
+ 1. **L1 — Auth Setup**: {modules}
526
+ 2. **L2 — Reference Data**: {modules in dependency order}
527
+ 3. **L3 — Transactional Data**: {modules in dependency order}
528
+ 4. **L4 — Side-Effect Assertions**: {modules}
529
+
530
+ ---
531
+
532
+ ## 6. Table of Contents
533
+
534
+ {List all test spec files in strict dependency order derived from the dependency graph
535
+ built in Step 8. A module only appears after ALL modules it depends on have been listed.
536
+ Apply a topological sort within each layer, then order layers L1 → L2 → L3 → L4.
537
+ Group by layer in the TOC for readability, but the numbering is globally sequential
538
+ and reflects the dependency-resolved execution order throughout.}
539
+
540
+ ### L1 — Auth Setup
541
+
542
+ 1. [{Module Name}]({module-kebab}/TEST_SPEC.md) — Versions: {comma-separated versions} — [Summary](#module-{module-anchor})
543
+
544
+ ### L2 — Reference Data
545
+
546
+ {List L2 modules in topological order: if Module B depends on Module A, Module A comes first.}
547
+
548
+ 2. [{Module Name}]({module-kebab}/TEST_SPEC.md) — Versions: {versions} — [Summary](#module-{module-anchor})
549
+ 3. [{Module Name}]({module-kebab}/TEST_SPEC.md) — Versions: {versions} — [Summary](#module-{module-anchor})
550
+
551
+ ### L3 — Transactional Data
552
+
553
+ {List L3 modules in topological order by their inter-module dependencies.}
554
+
555
+ 4. [{Module Name}]({module-kebab}/TEST_SPEC.md) — Versions: {versions} — [Summary](#module-{module-anchor})
556
+
557
+ ### L4 — Side-Effect Assertions
558
+
559
+ {List L4 modules after all upstream L1–L3 modules they assert against.}
560
+
561
+ 5. [{Module Name}]({module-kebab}/TEST_SPEC.md) — Versions: {versions} — [Summary](#module-{module-anchor})
562
+
563
+ ---
564
+
565
+ ## 7. Module Summaries
566
+
567
+ {One subsection per module. The order of subsections MUST follow the topological sort of
568
+ the dependency graph (Step 8): a module's subsection only appears after all modules it
569
+ depends on have already appeared. This is the same order as the TOC in Section 6.
570
+ Each subsection summarizes what the module's TEST_SPEC.md covers, what data it seeds,
571
+ what it depends on, and a breakdown of its test scenarios by type.}
572
+
573
+ ### Module: {Module Name} {#module-{module-anchor}}
574
+
575
+ **Layer**: {L1/L2/L3/L4} — {layer purpose}
576
+ **Seeding Strategy**: {Keycloak CLI / DB Insert / MQ Publish / No seeding (side effect)}
577
+ **Spec File**: [{module-kebab}/TEST_SPEC.md]({module-kebab}/TEST_SPEC.md)
578
+
579
+ **Dependencies**:
580
+
581
+ | Prerequisite Module | Layer | Reason |
582
+ |--------------------|-------|--------|
583
+ | {module name} | {L1/L2/L3} | {why this module must be seeded first} |
584
+
585
+ _(None — this module has no prerequisites.)_ ← use when no deps
586
+
587
+ **Data Seeded**:
588
+
589
+ | Collection / Entity | Record Count | Key Sample Fields |
590
+ |--------------------|-------------|-------------------|
591
+ | {collection} | {count} | {field: value, ...} |
592
+
593
+ _(No seeding required — data is a side effect of upstream operations.)_ ← use for L4
594
+
595
+ **Test Scenarios Summary**:
596
+
597
+ | Type | Count | Description |
598
+ |------|-------|-------------|
599
+ | Navigation | {n} | Verify sidebar link reaches the {Module Name} screen |
600
+ | Search | {n} | Search by {param1}, {param2}, ... |
601
+ | View / Detail | {n} | View detail of {entity} with tabs: {tab names} |
602
+ | CRUD — Create | {n} | Create new {entity} with required fields |
603
+ | CRUD — Edit | {n} | Update {field} of an existing {entity} |
604
+ | CRUD — Delete | {n} | Delete {entity} with confirmation dialog |
605
+ | Validation | {n} | Required fields, {constraint description}, ... |
606
+ | Mapping | {n} | Map {entity A} to {entity B} |
607
+ | Toggle | {n} | Activate / Deactivate {entity} |
608
+ | History / Audit | {n} | View change history of {entity} |
609
+ | Raw Message | {n} | View raw inbound message payload |
610
+ | Pagination | {n} | Paginate {entity} list, change page size |
611
+ | Regression | {n} | Verify previously fixed bugs still hold |
612
+ | Test Instruction | {n} | Human-guided scenarios from `### Test` section |
613
+ | **Total** | **{total}** | |
614
+
615
+ _{Omit rows for types with 0 scenarios.}_
616
+
617
+ **Roles Tested**: {comma-separated list of roles exercised in this module's scenarios}
618
+
619
+ **Key Assertions**:
620
+ - {Brief bullet summarising the most important expected behaviours to verify}
621
+ - {e.g., "Dropdown for Country Code is populated from Location Information reference data"}
622
+ - {e.g., "Status badge changes colour immediately after toggle without page reload"}
623
+
624
+ ---
625
+
626
+ {Repeat the Module subsection above for every module, in execution order}
627
+
628
+ ---
629
+
630
+ ## 8. Global Setup
631
+
632
+ ### 8a. Auth Setup (L1)
633
+
634
+ {Keycloak CLI commands to create test realm, clients, roles, and users}
635
+
636
+ ### 8b. Reference Data Setup (L2)
637
+
638
+ {Summary of L2 modules and their seeding order}
639
+
640
+ ### 8c. Message Publishing (L3)
641
+
642
+ {Summary of L3 modules and the messages to publish}
643
+
644
+ ---
645
+
646
+ ## 9. Global Teardown
647
+
648
+ {Cleanup strategy — reverse order of setup}
649
+
650
+ ### 9a. Database Cleanup
651
+
652
+ {CLI commands to drop test data from each collection/table, in reverse dependency order}
653
+
654
+ ### 9b. Message Queue Cleanup
655
+
656
+ {CLI commands to purge test queues}
657
+
658
+ ### 9c. Auth Cleanup
659
+
660
+ {CLI commands to remove test users/realm}
661
+ ```
662
+
663
+ ---
664
+
665
+ ### Step 10: Generate Per-Module TEST_SPEC.md
666
+
667
+ For each module (or the filtered module), write `<app_folder>/context/test/{module-kebab}/TEST_SPEC.md`:
668
+
669
+ ```markdown
670
+ # TEST_SPEC: {Module Name}
671
+
672
+ **Application**: {Application Name} ({Initials})
673
+ **Module**: {Module Name}
674
+ **Category**: {System Module / Business Module}
675
+ **Layer**: {L1 / L2 / L3 / L4} — {layer purpose}
676
+ **Seeding Strategy**: {Keycloak CLI / DB Insert / MQ Publish / No seeding (side effect)}
677
+ **Generated**: {date}
678
+ **Version**: {target version or "all versions"}
679
+ **Versions Covered**: {comma-separated list of versions present in this module}
680
+
681
+ ---
682
+
683
+ ## 1. Module Overview
684
+
685
+ {Module description from PRD.md}
686
+
687
+ ### Layer Classification Reasoning
688
+
689
+ {Why this module was classified into its layer — which heuristic matched}
690
+
691
+ ### Source Artifacts
692
+
693
+ | Artifact Type | Reference | Version |
694
+ |---------------|-----------|---------|
695
+ | User Story | {USHM tag} | {v1.0.x from PRD.md} |
696
+ | NFR | {NFRHM tag} | {v1.0.x} |
697
+ | Constraint | {CONSHM tag} | {v1.0.x} |
698
+ | Test | {TSTHM tag} | {v1.0.x} |
699
+ | Bug Fix | {BUG tag} | {v1.0.x} |
700
+
701
+ | Artifact | Path | Status |
702
+ |----------|------|--------|
703
+ | User Stories | {PRD.md path} | Found |
704
+ | Module Model | {model path or "Not found"} | {Found/Not found} |
705
+ | Specification | {spec path or "Not found"} | {Found/Not found} |
706
+ | Mockup | {mockup path or "Not found"} | {Found/Not found} |
707
+ | Message Reference | {message ref path or "Not found"} | {Found/Not found} |
708
+
709
+ {If any items were deprecated/removed and replaced, include:}
710
+
711
+ ### Removed / Replaced
712
+
713
+ | ID | Type | Removed In | Replaced By | Reason |
714
+ |---|---|---|---|---|
715
+ | {old ID} | {User Story/NFR/Constraint} | {version removed} | {new ID or "—"} | {reason} |
716
+
717
+ ### Test Instructions (from PRD.md)
718
+
719
+ {If the module has a `### Test` section in PRD.md, list all tagged test instructions here.
720
+ These are human-specified test scenario hints, test edge cases, test data requirements,
721
+ and test setup instructions that serve as **additional context** on top of the standard
722
+ auto-derived test scenarios from User Stories, NFRs, Constraints, Module Models, HTML
723
+ Mockups, and Technical Specs. They MUST be incorporated into the test scenarios in
724
+ Section 4.
725
+
726
+ Test instructions guide the test spec generator on specific scenarios or edge cases that
727
+ a human tester has identified as important. They do NOT replace the auto-derived scenarios
728
+ but complement them — ensuring critical test paths are not missed.
729
+
730
+ When a test instruction specifies exact test data (e.g., usernames, passwords, field values),
731
+ use those values as-is in the relevant seeding scripts and test scenarios.}
732
+
733
+ | Tag | Version | Instruction |
734
+ |-----|---------|-------------|
735
+ | {TSTHM tag} | {v1.0.x} | {Full text of the test instruction from PRD.md} |
736
+
737
+ {Example: `[TSTHM0003]` specifies exact test user credentials and roles for the Auth
738
+ module — these MUST be used in the L1 Auth seeding script instead of auto-generated
739
+ user data. `[TSTHA0006]` describes specific validation edge cases for the Employer
740
+ module — these should generate additional VAL- test scenarios in Section 4.}
741
+
742
+ _(No test instructions for this module.)_ ← use when the `### Test` section is empty or has no tagged items
743
+
744
+ ### Bug Fix Regression Coverage
745
+
746
+ {If the module has a `### Bug` section in PRD.md, list each bug fix and its corresponding
747
+ regression test requirement. Each bug fix MUST have at least one test scenario that verifies
748
+ the fix still holds — preventing the same bug from reappearing.}
749
+
750
+ | Bug Tag | Version | Description | Regression Scenario |
751
+ |---------|---------|-------------|-------------------|
752
+ | {BUG-XXX} | {v1.0.x} | {Bug fix description from PRD.md} | {REG-prefix-NNN: scenario ID in Section 4} |
753
+
754
+ _(No bug fixes recorded for this module.)_ ← use when the `### Bug` section is empty or absent
755
+
756
+ ---
757
+
758
+ ## 2. Prerequisites
759
+
760
+ {What must exist before tests for this module can run}
761
+
762
+ | Prerequisite | Module | Layer | How to Verify |
763
+ |-------------|--------|-------|--------------|
764
+ | {description} | {module name} | {L1/L2/L3} | {verification method} |
765
+
766
+ ---
767
+
768
+ ## 3. Data Seeding
769
+
770
+ ### 3a. Seeding Script
771
+
772
+ {Based on layer classification, generate appropriate seeding commands}
773
+
774
+ **IMPORTANT**: All seeding scripts MUST reference environment variables (from Section 2a
775
+ of TEST_PLAN.md) instead of hardcoded paths, credentials, or connection strings. This
776
+ ensures Playwright tests are portable across developer machines. Use `$ENV_VAR` syntax
777
+ in bash command templates and note that the actual Playwright helper code should read
778
+ these from `process.env.*` via a `.env` file.
779
+
780
+ **For L1 (Auth)** — use the auth provider's CLI or framework seeder:
781
+
782
+ *If Keycloak (detected from CLAUDE.md):*
783
+ ```bash
784
+ # Create test user in Keycloak
785
+ # Env vars: TEST_SSO_CLI_PATH, TEST_SSO_HOST, TEST_SSO_ADMIN_USER, TEST_SSO_ADMIN_PASSWORD, TEST_SSO_REALM
786
+ "$TEST_SSO_CLI_PATH" config credentials --server "$TEST_SSO_HOST" --realm master --user "$TEST_SSO_ADMIN_USER" --password "$TEST_SSO_ADMIN_PASSWORD"
787
+ "$TEST_SSO_CLI_PATH" create users -r "$TEST_SSO_REALM" -s username={user} -s enabled=true ...
788
+ ```
789
+
790
+ *If Laravel with DB-backed auth (detected from CLAUDE.md):*
791
+ ```bash
792
+ # Seed test users via artisan
793
+ # Env vars: TEST_PHP_PATH (optional, defaults to 'php')
794
+ php artisan tinker --execute="
795
+ \App\Models\User::factory()->create([
796
+ 'name' => '{user}', 'email' => '{email}', 'password' => bcrypt('{pass}')
797
+ ])->assignRole('{role}');
798
+ "
799
+ ```
800
+
801
+ **For L2 (Reference Data / DB Insert)** — use the database CLI matching CLAUDE.md:
802
+
803
+ *If MongoDB:*
804
+ ```bash
805
+ # Env vars: TEST_DB_URI
806
+ mongosh "$TEST_DB_URI" --eval '
807
+ db.{collection}.insertMany([
808
+ {sample document based on model fields},
809
+ ...
810
+ ])
811
+ '
812
+ ```
813
+
814
+ *If MySQL:*
815
+ ```bash
816
+ # Env vars: TEST_DB_HOST, TEST_DB_PORT, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB_NAME
817
+ mysql -h "$TEST_DB_HOST" -P "$TEST_DB_PORT" -u "$TEST_DB_USER" -p"$TEST_DB_PASSWORD" "$TEST_DB_NAME" -e "
818
+ INSERT INTO {table} ({columns}) VALUES
819
+ ({sample row based on model fields}),
820
+ ...;
821
+ "
822
+ ```
823
+
824
+ *If PostgreSQL:*
825
+ ```bash
826
+ # Env vars: TEST_DB_HOST, TEST_DB_PORT, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB_NAME
827
+ psql "postgresql://$TEST_DB_USER:$TEST_DB_PASSWORD@$TEST_DB_HOST:$TEST_DB_PORT/$TEST_DB_NAME" -c "
828
+ INSERT INTO {table} ({columns}) VALUES
829
+ ({sample row based on model fields}),
830
+ ...;
831
+ "
832
+ ```
833
+
834
+ *If Laravel (alternative to raw CLI):*
835
+ ```bash
836
+ php artisan db:seed --class=Test{Module}Seeder
837
+ ```
838
+
839
+ **For L3 (Transactional Data / MQ Publish)** — use the message broker CLI:
840
+
841
+ *If RabbitMQ:*
842
+ ```bash
843
+ # Env vars: TEST_MQ_HOST, TEST_MQ_PORT, TEST_MQ_USER, TEST_MQ_PASSWORD, TEST_MQ_VHOST
844
+ rabbitmqadmin -H "$TEST_MQ_HOST" -P "$TEST_MQ_PORT" -u "$TEST_MQ_USER" -p "$TEST_MQ_PASSWORD" -V "$TEST_MQ_VHOST" publish exchange={exchange} routing_key={key} payload='{
845
+ {sample message JSON from MESSAGE_*.md}
846
+ }'
847
+ ```
848
+
849
+ **For L4 (Side Effect)**:
850
+ ```
851
+ No seeding required — data is generated as a side effect of L2/L3 operations.
852
+ Assert existence after upstream tests complete.
853
+ ```
854
+
855
+ ### 3b. Seeded Data Summary
856
+
857
+ | Collection/Entity | Record Count | Key Fields | Sample Values |
858
+ |-------------------|-------------|------------|---------------|
859
+ | {collection} | {count} | {key fields from model} | {sample values} |
860
+
861
+ ---
862
+
863
+ ## 4. Test Scenarios
864
+
865
+ {Derived from user stories, grouped by test type. Each scenario includes:
866
+ - Scenario ID (module prefix + sequential number)
867
+ - Description
868
+ - Source user story tag(s)
869
+ - Role performing the test
870
+ - Preconditions
871
+ - Steps (numbered)
872
+ - Expected results
873
+ - Selectors (from mockups, if available)}
874
+
875
+ ### 4a. Navigation Tests
876
+
877
+ {Derived from mockup sidebar links — verify the module screen is accessible}
878
+
879
+ #### NAV-{prefix}-001: Navigate to {Module} screen
880
+
881
+ - **Source**: Sidebar navigation [v1.0.x]
882
+ - **Role**: {role}
883
+ - **Preconditions**: User is logged in
884
+ - **Steps**:
885
+ 1. Click "{Module Name}" in the sidebar navigation
886
+ 2. Wait for content area to load
887
+ - **Expected**:
888
+ - URL contains `/{role_snake_case}/{module_snake_case}`
889
+ - Page title/heading shows "{Module Name}"
890
+ - {If mockup exists: specific heading selector from mockup}
891
+ - **Selectors** (from mockup):
892
+ - Sidebar link: `{selector from sidebar HTML}`
893
+ - Page heading: `{selector from content HTML}`
894
+
895
+ ### 4b. Search Tests
896
+
897
+ {Derived from user stories matching "search for X based on Y"}
898
+
899
+ #### SRCH-{prefix}-001: Search {entity} by {parameter}
900
+
901
+ - **Source**: {user story tag} [v1.0.x]
902
+ - **Role**: {role}
903
+ - **Preconditions**: {seeded data exists}
904
+ - **Steps**:
905
+ 1. Navigate to {module} screen
906
+ 2. Enter "{sample value}" in the {parameter} filter field
907
+ 3. Click "Search" / press Enter
908
+ 4. Wait for results to load
909
+ - **Expected**:
910
+ - Results table shows matching records
911
+ - Each result row contains the search term in the {parameter} column
912
+ - Result count is displayed (e.g., "Showing 1-N of N results")
913
+ - **Selectors** (from mockup):
914
+ - Filter input: `{selector}`
915
+ - Search button: `{selector}`
916
+ - Results table: `{selector}`
917
+ - Result count text: `{selector}`
918
+
919
+ ### 4c. View/Detail Tests
920
+
921
+ {Derived from user stories matching "view details of X"}
922
+
923
+ #### VIEW-{prefix}-001: View {entity} details
924
+
925
+ - **Source**: {user story tag} [v1.0.x]
926
+ - **Role**: {role}
927
+ - **Preconditions**: {entity exists in system}
928
+ - **Steps**:
929
+ 1. Navigate to {module} list screen
930
+ 2. Click "View" action on a record
931
+ 3. Wait for detail page to load
932
+ - **Expected**:
933
+ - Detail page shows all expected fields
934
+ - {For each field from model: field label and value are visible}
935
+ - Back button navigates to list
936
+ - **Selectors** (from mockup):
937
+ - View button: `{selector}`
938
+ - Detail card: `{selector}`
939
+ - Back button: `{selector}`
940
+
941
+ ### 4d. CRUD Tests
942
+
943
+ {Derived from user stories matching "manage", "configure", "add/create", "edit/update", "delete"}
944
+
945
+ #### CRUD-{prefix}-001: Create new {entity}
946
+
947
+ - **Source**: {user story tag} [v1.0.x]
948
+ - **Role**: {role}
949
+ - **Preconditions**: User has create permission
950
+ - **Steps**:
951
+ 1. Navigate to {module} list screen
952
+ 2. Click "Add New" button
953
+ 3. Fill in required fields:
954
+ {For each required field from model:}
955
+ - {field name}: "{sample value}"
956
+ 4. Click "Save" / "Submit"
957
+ - **Expected**:
958
+ - Success notification appears
959
+ - Redirected to list or detail screen
960
+ - New record appears in list
961
+ - **Form Fields** (from mockup/model):
962
+ | Field | Selector | Type | Required | Sample Value |
963
+ |-------|----------|------|----------|--------------|
964
+ | {field} | {selector} | {input type} | {yes/no} | {value} |
965
+
966
+ #### CRUD-{prefix}-002: Edit existing {entity}
967
+
968
+ - **Source**: {user story tag} [v1.0.x]
969
+ - **Role**: {role}
970
+ - **Preconditions**: {entity exists}
971
+ - **Steps**:
972
+ 1. Navigate to {module} list or detail screen
973
+ 2. Click "Edit" action
974
+ 3. Modify field: {field name} = "{new value}"
975
+ 4. Click "Save"
976
+ - **Expected**:
977
+ - Success notification appears
978
+ - Updated value is reflected in detail/list view
979
+ - {Read-only fields remain unchanged}
980
+
981
+ #### CRUD-{prefix}-003: Delete {entity}
982
+
983
+ - **Source**: {user story tag} [v1.0.x]
984
+ - **Role**: {role}
985
+ - **Preconditions**: {entity exists}
986
+ - **Steps**:
987
+ 1. Navigate to {module} list screen
988
+ 2. Click "Delete" action on a record
989
+ 3. Confirm deletion in dialog
990
+ - **Expected**:
991
+ - Confirmation dialog appears before deletion
992
+ - Record is removed from list after confirmation
993
+ - {If soft delete: record is flagged, not physically removed}
994
+
995
+ ### 4e. Validation Tests
996
+
997
+ {Derived from constraints, NFRs, spec validation rules, and model field constraints}
998
+
999
+ #### VAL-{prefix}-001: Required field validation on {entity} create
1000
+
1001
+ - **Source**: {constraint/NFR tag} [v1.0.x]
1002
+ - **Role**: {role}
1003
+ - **Preconditions**: None
1004
+ - **Steps**:
1005
+ 1. Navigate to create {entity} screen
1006
+ 2. Leave all required fields empty
1007
+ 3. Click "Save"
1008
+ - **Expected**:
1009
+ - Form is NOT submitted
1010
+ - Validation errors appear for each required field:
1011
+ {For each required field from model:}
1012
+ - {field name}: shows required error message
1013
+
1014
+ #### VAL-{prefix}-002: {Specific constraint validation}
1015
+
1016
+ - **Source**: {constraint tag} [v1.0.x]
1017
+ - **Role**: {role}
1018
+ - **Steps**: {specific to the constraint}
1019
+ - **Expected**: {specific validation behavior}
1020
+
1021
+ ### 4f. Mapping Tests
1022
+
1023
+ {Derived from user stories matching "map X to Y"}
1024
+
1025
+ ### 4g. Toggle Tests
1026
+
1027
+ {Derived from user stories matching "activate/deactivate"}
1028
+
1029
+ #### TOG-{prefix}-001: Toggle {entity} status
1030
+
1031
+ - **Source**: {user story tag}
1032
+ - **Role**: {role}
1033
+ - **Steps**:
1034
+ 1. Navigate to {module} screen
1035
+ 2. Find an active {entity}
1036
+ 3. Click the toggle/deactivate control
1037
+ 4. Confirm if prompted
1038
+ - **Expected**:
1039
+ - Status changes from Active to Inactive (or vice versa)
1040
+ - Visual indicator updates (badge color, toggle state)
1041
+
1042
+ ### 4h. History/Audit Tests
1043
+
1044
+ {Derived from user stories matching "view history", "view changes", "audit"}
1045
+
1046
+ #### HIST-{prefix}-001: View {entity} change history
1047
+
1048
+ - **Source**: {user story tag}
1049
+ - **Role**: {role}
1050
+ - **Preconditions**: {entity has been modified at least once}
1051
+ - **Steps**:
1052
+ 1. Navigate to {entity} detail screen
1053
+ 2. Click "History" tab or link
1054
+ 3. Wait for history records to load
1055
+ - **Expected**:
1056
+ - History table shows chronological list of changes
1057
+ - Each entry shows: change type, field changed, old value, new value, timestamp, changed by
1058
+ - Most recent changes appear first
1059
+
1060
+ ### 4i. Raw Message View Tests
1061
+
1062
+ {Derived from user stories referencing "view raw message" — typically for L3 modules}
1063
+
1064
+ #### RAW-{prefix}-001: View raw inbound message
1065
+
1066
+ - **Source**: {user story tag}
1067
+ - **Role**: {role}
1068
+ - **Steps**:
1069
+ 1. Navigate to {entity} detail screen
1070
+ 2. Click "Raw Message" tab
1071
+ 3. Wait for raw data to load
1072
+ - **Expected**:
1073
+ - Raw JSON message is displayed
1074
+ - JSON is formatted/syntax-highlighted
1075
+ - Message contains expected fields from MESSAGE_*.md structure
1076
+
1077
+ ### 4j. Pagination Tests
1078
+
1079
+ {Applied to every list screen — verify pagination works correctly}
1080
+
1081
+ #### PAGE-{prefix}-001: Verify pagination on {entity} list
1082
+
1083
+ - **Source**: General requirement (all list screens must paginate)
1084
+ - **Role**: {role}
1085
+ - **Preconditions**: More than 10 {entities} exist in system
1086
+ - **Steps**:
1087
+ 1. Navigate to {module} list screen
1088
+ 2. Verify default page shows 10 items
1089
+ 3. Click "Next" page button
1090
+ 4. Verify next page loads with different records
1091
+ 5. Change page size to 25
1092
+ 6. Verify 25 items are displayed
1093
+ - **Expected**:
1094
+ - "Showing X-Y of Z results" text is accurate
1095
+ - Page navigation buttons work correctly
1096
+ - Page size selector changes the number of visible rows
1097
+
1098
+ ### 4k. Regression Tests
1099
+
1100
+ {Derived from `### Bug` sections in PRD.md. For each bug fix recorded in the module,
1101
+ generate a regression test scenario that verifies the fix still holds. This prevents
1102
+ previously fixed bugs from reappearing during redevelopment.}
1103
+
1104
+ #### REG-{prefix}-001: Verify fix for {BUG-XXX}
1105
+
1106
+ - **Source**: {BUG-XXX} [v1.0.x] from `### Bug` section
1107
+ - **Bug Description**: {description of what was broken and how it was fixed}
1108
+ - **Role**: {role — infer from the bug context or use the most common module role}
1109
+ - **Preconditions**: {relevant seeded data exists}
1110
+ - **Steps**:
1111
+ 1. {Steps that would have triggered the original bug}
1112
+ 2. {Navigate to the affected screen/feature}
1113
+ 3. {Perform the action that was broken}
1114
+ - **Expected**:
1115
+ - {The corrected behavior as described in the bug fix}
1116
+ - {The bug does NOT reappear — the fix is still in effect}
1117
+
1118
+ {Repeat for each bug fix in the module's `### Bug` section.
1119
+ If no `### Bug` section exists for this module, omit Section 4k entirely.}
1120
+
1121
+ ### 4l. Test Instruction Scenarios
1122
+
1123
+ {Derived from tagged `### Test` items in PRD.md. These are human-guided test scenarios
1124
+ and edge cases that complement the auto-derived scenarios above. Each tagged test
1125
+ instruction (`[TSTxx####]`) should produce one or more test scenarios that cover the
1126
+ specific test paths, edge cases, or setup requirements described by the human tester.
1127
+
1128
+ Test instruction scenarios may overlap with auto-derived scenarios (e.g., a test
1129
+ instruction about validation edge cases may produce scenarios similar to Section 4e).
1130
+ When overlap occurs, merge the human-guided details INTO the existing auto-derived
1131
+ scenario rather than creating a duplicate. Add the TST tag as an additional Source
1132
+ reference. Only create a NEW scenario in this section when the test instruction describes
1133
+ a test path not already covered by any auto-derived scenario.}
1134
+
1135
+ #### TSTI-{prefix}-001: {Test instruction description}
1136
+
1137
+ - **Source**: {TST tag} [v1.0.x] from `### Test` section
1138
+ - **Instruction**: {Full text of the tagged test instruction}
1139
+ - **Role**: {role — infer from instruction context}
1140
+ - **Preconditions**: {relevant seeded data or setup}
1141
+ - **Steps**:
1142
+ 1. {Steps derived from the human test instruction}
1143
+ 2. {Include specific values/data mentioned in the instruction}
1144
+ - **Expected**:
1145
+ - {Expected behavior described or implied by the instruction}
1146
+
1147
+ {Repeat for each tagged test instruction in the module's `### Test` section.
1148
+ If no tagged items exist in `### Test`, omit Section 4l entirely.}
1149
+
1150
+ ---
1151
+
1152
+ ## 5. Data Cleanup
1153
+
1154
+ ### 5a. Cleanup Script
1155
+
1156
+ {Reverse of seeding — remove all test data}
1157
+
1158
+ **IMPORTANT**: Cleanup scripts MUST use the same environment variables as seeding scripts
1159
+ (from Section 2a of TEST_PLAN.md). Never hardcode paths, credentials, or connection strings.
1160
+
1161
+ **For L2 (DB cleanup)** — use the database CLI matching CLAUDE.md:
1162
+
1163
+ *If MongoDB:*
1164
+ ```bash
1165
+ # Env vars: TEST_DB_URI
1166
+ mongosh "$TEST_DB_URI" --eval '
1167
+ db.{collection}.deleteMany({ _testData: true })
1168
+ '
1169
+ ```
1170
+
1171
+ *If MySQL:*
1172
+ ```bash
1173
+ # Env vars: TEST_DB_HOST, TEST_DB_PORT, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB_NAME
1174
+ mysql -h "$TEST_DB_HOST" -P "$TEST_DB_PORT" -u "$TEST_DB_USER" -p"$TEST_DB_PASSWORD" "$TEST_DB_NAME" -e "
1175
+ DELETE FROM {table} WHERE _test_data = 1;
1176
+ "
1177
+ ```
1178
+
1179
+ *If PostgreSQL:*
1180
+ ```bash
1181
+ # Env vars: TEST_DB_HOST, TEST_DB_PORT, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB_NAME
1182
+ psql "postgresql://$TEST_DB_USER:$TEST_DB_PASSWORD@$TEST_DB_HOST:$TEST_DB_PORT/$TEST_DB_NAME" -c "
1183
+ DELETE FROM {table} WHERE _test_data = true;
1184
+ "
1185
+ ```
1186
+
1187
+ *If Laravel (alternative):*
1188
+ ```bash
1189
+ php artisan test:cleanup --module={module}
1190
+ ```
1191
+
1192
+ **For L3 (Queue cleanup)** — use the message broker CLI:
1193
+
1194
+ *If RabbitMQ:*
1195
+ ```bash
1196
+ # Env vars: TEST_MQ_HOST, TEST_MQ_PORT, TEST_MQ_USER, TEST_MQ_PASSWORD, TEST_MQ_VHOST
1197
+ rabbitmqadmin -H "$TEST_MQ_HOST" -P "$TEST_MQ_PORT" -u "$TEST_MQ_USER" -p "$TEST_MQ_PASSWORD" -V "$TEST_MQ_VHOST" purge queue name={queue_name}
1198
+ ```
1199
+
1200
+ ### 5b. Cleanup Order
1201
+
1202
+ {Reverse dependency order — clean dependents first, then dependencies}
1203
+
1204
+ 1. {last module in dependency order}
1205
+ 2. ...
1206
+ 3. {first module}
1207
+
1208
+ ---
1209
+
1210
+ ## 6. Traceability Matrix
1211
+
1212
+ | Test Scenario ID | User Story | Bug Fix | Test Instruction | Version | NFR(s) | Constraint(s) | Test Type |
1213
+ |-----------------|------------|---------|-----------------|---------|--------|---------------|-----------|
1214
+ | NAV-{prefix}-001 | — | — | — | — | — | — | Navigation |
1215
+ | SRCH-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | Search |
1216
+ | VIEW-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | View |
1217
+ | CRUD-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | Create |
1218
+ | CRUD-{prefix}-002 | {tag} | — | — | v1.0.x | — | — | Edit |
1219
+ | CRUD-{prefix}-003 | {tag} | — | — | v1.0.x | — | — | Delete |
1220
+ | VAL-{prefix}-001 | — | — | {TST tag or —} | v1.0.x | — | {tag} | Validation |
1221
+ | TOG-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | Toggle |
1222
+ | HIST-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | History |
1223
+ | RAW-{prefix}-001 | {tag} | — | — | v1.0.x | — | — | Raw Message |
1224
+ | PAGE-{prefix}-001 | — | — | — | — | — | — | Pagination |
1225
+ | REG-{prefix}-001 | — | {BUG-XXX} | — | v1.0.x | — | — | Regression |
1226
+ | TSTI-{prefix}-001 | — | — | {TST tag} | v1.0.x | — | — | Test Instruction |
1227
+ ```
1228
+
1229
+ ---
1230
+
1231
+ ### Step 11: Output Summary
1232
+
1233
+ After generation, print a summary:
1234
+
1235
+ ```
1236
+ Test Specification Generation Complete
1237
+ =======================================
1238
+ Application: {App Name} ({Initials})
1239
+ Target Version: {version or "latest (all versions)"}
1240
+ Module Filter: {module name or "all modules"}
1241
+ Output: {output path}/
1242
+
1243
+ Filtering Summary:
1244
+ - User stories included: {count}
1245
+ - User stories excluded (strikethrough): {count}
1246
+ - User stories excluded (version filter): {count}
1247
+ - User stories excluded (module filter): {count}
1248
+ - NFRs/Constraints included: {count}
1249
+ - NFRs/Constraints excluded: {count}
1250
+
1251
+ Layer Classification:
1252
+ | Layer | Modules | Count |
1253
+ |-------|---------|-------|
1254
+ | L1: Auth | {modules} | {count} |
1255
+ | L2: Reference Data | {modules} | {count} |
1256
+ | L3: Transactional Data | {modules} | {count} |
1257
+ | L4: Side-Effect Data | {modules} | {count} |
1258
+
1259
+ Files generated:
1260
+ - TEST_PLAN.md
1261
+ - {module-kebab}/TEST_SPEC.md (× {N} modules)
1262
+
1263
+ | Module | Layer | Scenarios | Spec File |
1264
+ |--------|-------|-----------|-----------|
1265
+ | {module} | {layer} | {count} | {module-kebab}/TEST_SPEC.md |
1266
+
1267
+ Total: {N} files, {M} test scenarios
1268
+ ```
1269
+
1270
+ ---
1271
+
1272
+ ## Changelog Append
1273
+
1274
+ After all test specification files are successfully generated, append an entry to `CHANGELOG.md` in the application folder (`<app_folder>/CHANGELOG.md`):
1275
+
1276
+ 1. Read `<app_folder>/CHANGELOG.md`. If it does not exist, create it with:
1277
+ ```markdown
1278
+ # Changelog
1279
+
1280
+ - This file tracks all skill executions by version for this application.
1281
+ - The highest version recorded here is the current application version.
1282
+ - Skills MUST NOT execute for a version lower than the highest version in this file.
1283
+
1284
+ ---
1285
+ ```
1286
+ 2. Search for a `## {version}` heading matching the current version.
1287
+ 3. If the section **exists**: append a new row to its table.
1288
+ 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.
1289
+ 5. Row format: `| {YYYY-MM-DD} | {application_name} | testgen-functional | {module or "All"} | Generated Playwright E2E test specifications |`
1290
+ 6. **Never modify or delete existing rows.**
1291
+
1292
+ ## Important Rules
1293
+
1294
+ ### Generic Design
1295
+ - **No hardcoded module names**: Module names, collection names, prefixes, and message types
1296
+ are ALL derived from input artifacts. Never hardcode "Employer", "Quota", etc.
1297
+ - **No hardcoded collection prefixes**: Read the prefix from the model's Module Prefix Map.
1298
+ - **No hardcoded message types**: Read message types from MESSAGE_*.md files.
1299
+ - **Infrastructure from CLAUDE.md**: CLI paths, connection strings, and credentials come
1300
+ from CLAUDE.md. Use generic placeholders if CLAUDE.md is not found.
1301
+ - **Environment variable portability**: All seeding scripts, cleanup scripts, and CLI
1302
+ command templates in TEST_PLAN.md and TEST_SPEC.md MUST reference environment variables
1303
+ (e.g., `$TEST_DB_URI`, `$TEST_SSO_CLI_PATH`) instead of hardcoded values. The env var
1304
+ names and their values from CLAUDE.md are documented in TEST_PLAN.md Section 2a. This
1305
+ ensures the generated test blueprints are portable — developers configure their local
1306
+ `.env` file once and all test helpers work regardless of machine-specific paths.
1307
+
1308
+ ### Document Quality
1309
+ - **Documents, not code**: Output is Markdown spec documents. Never generate Playwright
1310
+ JavaScript/TypeScript code.
1311
+ - **Actionable steps**: Each test scenario must have specific enough steps that a developer
1312
+ can implement the Playwright test without ambiguity.
1313
+ - **Real selectors**: When mockup HTML files exist, extract actual CSS selectors, IDs, and
1314
+ classes. Do not invent selectors.
1315
+ - **Real sample data**: When model files exist, use field names, types, enum values, and
1316
+ constraints to generate realistic sample data. Do not use generic placeholders.
1317
+ - **Real message payloads**: When MESSAGE_*.md files exist, use the expanded sample JSON
1318
+ as the basis for MQ seeding payloads.
1319
+
1320
+ ### Parsing Rules
1321
+ - **Strikethrough items MUST always be excluded**: Lines wrapped in `~~` are deprecated/removed.
1322
+ - **Version filtering**: When a target version is provided, only include items from sections
1323
+ with version tags <= target version. This applies to all section types: User Story, NFR,
1324
+ Constraint, Reference, Test, and Bug.
1325
+ - **Test instructions from PRD.md are authoritative**: When a `### Test` section specifies
1326
+ exact test users, credentials, or setup procedures, use them as-is. Do not override with
1327
+ auto-generated values. Tagged test instructions (`[TSTxx####]`) provide human-guided
1328
+ test scenarios and edge cases that MUST be incorporated into the test spec — either by
1329
+ merging into existing auto-derived scenarios or by creating new TSTI-* scenarios.
1330
+ - **Test instructions are additive, not exclusive**: Test instructions complement the
1331
+ standard auto-derived scenarios from User Stories, NFRs, Constraints, Models, Mockups,
1332
+ and Specs. They do NOT replace or limit the auto-derived scenarios. Think of them as
1333
+ "the human tester also wants to make sure these specific things are tested."
1334
+ - **Bug fixes MUST have regression coverage**: Every bug fix in a `### Bug` section must
1335
+ produce at least one REG-* test scenario in the module's TEST_SPEC.md.
1336
+ - **Version + module are independent axes**: Both may be combined freely. A story must
1337
+ satisfy BOTH filters to be included.
1338
+
1339
+ ### Layer Classification
1340
+ - **Classification order matters**: Check L1 first, then L4, then L3, then L2 (L2 is the
1341
+ default/fallback).
1342
+ - **One layer per module**: Each module belongs to exactly one layer.
1343
+ - **Record reasoning**: Always document which heuristic matched for each classification.
1344
+
1345
+ ### Dependencies
1346
+ - **Respect execution order**: L1 → L2 → L3 → L4. Within each layer, respect inter-module
1347
+ dependencies.
1348
+ - **Seeding before testing**: All prerequisite data must be seeded before a module's tests run.
1349
+ - **Cleanup in reverse order**: Clean up in reverse dependency order to avoid foreign key
1350
+ or reference violations.
1351
+
1352
+ ### Traceability
1353
+ - **Every test scenario maps to at least one source**: User story, NFR, constraint, or
1354
+ general requirement (like pagination).
1355
+ - **Every user story should produce at least one test scenario**: If a user story has no
1356
+ corresponding test scenario, flag it in the traceability matrix.
1357
+ - **Traceability matrix must be complete**: No gaps between user stories and test coverage.
1358
+
1359
+ ### Mockup Integration
1360
+ - **Selector accuracy**: Only reference selectors that actually exist in the mockup HTML.
1361
+ If no mockup exists, omit the Selectors section from test scenarios.
1362
+ - **Navigation paths**: Use actual HTMX routes from mockups for navigation steps.
1363
+ - **Form fields**: Use actual input names and types from mockup forms.
1364
+
1365
+ ### Version Tracking in Output
1366
+ - **Version tags in Source Artifacts**: Every user story, NFR, and constraint in the
1367
+ Source Artifacts table must include its version from PRD.md.
1368
+ - **Version tags in test scenarios**: The "Source" field in each test scenario must
1369
+ include the version tag (e.g., `USHM00228 [v1.0.3]`).
1370
+ - **Version column in Traceability Matrix**: The traceability matrix must include a
1371
+ Version column showing which version introduced each test scenario's source requirement.
1372
+ - **Removed / Replaced tracking**: When items are deprecated/removed in a newer version
1373
+ and replaced by new items, include a "Removed / Replaced" subsection in Source Artifacts.
1374
+ - **Versions Covered field**: Both TEST_PLAN.md and TEST_SPEC.md must include a
1375
+ "Versions Covered" field showing the range of versions included.
1376
+
1377
+ ### Following Existing Patterns
1378
+ - Same frontmatter format as mockgen-tailwind, specgen-spring-jpa-jtehtmx, and specgen-laravel-eloquent-bladehtmx skills
1379
+ - Same argument parsing conventions (module:, version, path)
1380
+ - Same version filtering and strikethrough exclusion logic
1381
+ - Same output summary format (table-based, with file counts)