@anhth2/spec-driven-dev-plugin 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/ARCHITECTURE.md +243 -0
  2. package/bin/build.js +230 -0
  3. package/bin/index.js +311 -0
  4. package/commands/debug.md +374 -0
  5. package/commands/debug.tmpl +77 -0
  6. package/commands/define-product.md +451 -0
  7. package/commands/define-product.tmpl +154 -0
  8. package/commands/fix-bug.md +379 -0
  9. package/commands/fix-bug.tmpl +82 -0
  10. package/commands/generate-bdd.md +591 -0
  11. package/commands/generate-bdd.tmpl +294 -0
  12. package/commands/generate-code.md +395 -0
  13. package/commands/generate-code.tmpl +98 -0
  14. package/commands/generate-prd.md +488 -0
  15. package/commands/generate-prd.tmpl +191 -0
  16. package/commands/generate-tech-docs.md +362 -0
  17. package/commands/generate-tech-docs.tmpl +65 -0
  18. package/commands/generate-tests.md +377 -0
  19. package/commands/generate-tests.tmpl +80 -0
  20. package/commands/refine-prd.md +408 -0
  21. package/commands/refine-prd.tmpl +111 -0
  22. package/commands/review-code.md +354 -0
  23. package/commands/review-code.tmpl +57 -0
  24. package/commands/review-context.md +646 -0
  25. package/commands/review-context.tmpl +349 -0
  26. package/commands/review-tech-docs.md +518 -0
  27. package/commands/review-tech-docs.tmpl +221 -0
  28. package/commands/run-tests.md +343 -0
  29. package/commands/run-tests.tmpl +46 -0
  30. package/commands/setup-ai-first.md +278 -0
  31. package/commands/setup-ai-first.tmpl +197 -0
  32. package/commands/smoke-test.md +366 -0
  33. package/commands/smoke-test.tmpl +69 -0
  34. package/commands/validate-traces.md +529 -0
  35. package/commands/validate-traces.tmpl +232 -0
  36. package/core/FRAMEWORK_VERSION +1 -0
  37. package/core/commands/debug.md +374 -0
  38. package/core/commands/define-product.md +451 -0
  39. package/core/commands/fix-bug.md +379 -0
  40. package/core/commands/generate-bdd.md +591 -0
  41. package/core/commands/generate-code.md +395 -0
  42. package/core/commands/generate-prd.md +488 -0
  43. package/core/commands/generate-tech-docs.md +362 -0
  44. package/core/commands/generate-tests.md +377 -0
  45. package/core/commands/refine-prd.md +408 -0
  46. package/core/commands/review-code.md +354 -0
  47. package/core/commands/review-context.md +646 -0
  48. package/core/commands/review-tech-docs.md +518 -0
  49. package/core/commands/run-tests.md +343 -0
  50. package/core/commands/setup-ai-first.md +278 -0
  51. package/core/commands/smoke-test.md +366 -0
  52. package/core/commands/validate-traces.md +529 -0
  53. package/core/hooks/data-guard.js +141 -0
  54. package/core/hooks/settings.json +18 -0
  55. package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
  56. package/core/modules/angular/module.yaml +6 -0
  57. package/core/modules/angular/stack-profile.yaml +38 -0
  58. package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  59. package/core/modules/context-engineering/module.yaml +9 -0
  60. package/core/modules/context-engineering/stack-profile.yaml +61 -0
  61. package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  62. package/core/modules/dotnet/module.yaml +6 -0
  63. package/core/modules/dotnet/stack-profile.yaml +50 -0
  64. package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
  65. package/core/modules/golang/module.yaml +6 -0
  66. package/core/modules/golang/stack-profile.yaml +40 -0
  67. package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  68. package/core/modules/java-spring/module.yaml +15 -0
  69. package/core/modules/java-spring/stack-profile.yaml +28 -0
  70. package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  71. package/core/modules/nextjs/module.yaml +14 -0
  72. package/core/modules/nextjs/stack-profile.yaml +74 -0
  73. package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  74. package/core/modules/php-laravel/module.yaml +15 -0
  75. package/core/modules/php-laravel/stack-profile.yaml +56 -0
  76. package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  77. package/core/modules/react/module.yaml +14 -0
  78. package/core/modules/react/stack-profile.yaml +63 -0
  79. package/core/rules/data-protection.md +80 -0
  80. package/core/rules/workflow.md +44 -0
  81. package/core/skills/code/SKILL.md +526 -0
  82. package/core/skills/debug/SKILL.md +584 -0
  83. package/core/skills/discovery/SKILL.md +363 -0
  84. package/core/skills/prd/SKILL.md +456 -0
  85. package/core/skills/setup-ai-first/SKILL.md +160 -0
  86. package/core/skills/spec/SKILL.md +361 -0
  87. package/core/skills/test/SKILL.md +862 -0
  88. package/core/steps/context-loader.md +163 -0
  89. package/core/steps/gate.md +81 -0
  90. package/core/steps/report-footer.md +53 -0
  91. package/core/steps/spawn-agent.md +123 -0
  92. package/core/templates/architecture.template.md +113 -0
  93. package/core/templates/feature.template +259 -0
  94. package/core/templates/platform-guide.template.md +145 -0
  95. package/core/templates/prd.template.md +312 -0
  96. package/core/templates/product-definition.template.md +168 -0
  97. package/core/templates/project-context.yaml +78 -0
  98. package/hooks/data-guard.js +141 -0
  99. package/hooks/settings.json +18 -0
  100. package/modules/angular/architecture-snippets/component-patterns.md +187 -0
  101. package/modules/angular/module.yaml +6 -0
  102. package/modules/angular/stack-profile.yaml +38 -0
  103. package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
  104. package/modules/context-engineering/module.yaml +9 -0
  105. package/modules/context-engineering/stack-profile.yaml +61 -0
  106. package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
  107. package/modules/dotnet/module.yaml +6 -0
  108. package/modules/dotnet/stack-profile.yaml +50 -0
  109. package/modules/golang/architecture-snippets/domain-layout.md +283 -0
  110. package/modules/golang/module.yaml +6 -0
  111. package/modules/golang/stack-profile.yaml +40 -0
  112. package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
  113. package/modules/java-spring/module.yaml +15 -0
  114. package/modules/java-spring/stack-profile.yaml +28 -0
  115. package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
  116. package/modules/nextjs/module.yaml +14 -0
  117. package/modules/nextjs/stack-profile.yaml +74 -0
  118. package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
  119. package/modules/php-laravel/module.yaml +15 -0
  120. package/modules/php-laravel/stack-profile.yaml +56 -0
  121. package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
  122. package/modules/react/module.yaml +14 -0
  123. package/modules/react/stack-profile.yaml +63 -0
  124. package/package.json +42 -0
  125. package/rules/data-protection.md +80 -0
  126. package/rules/workflow.md +44 -0
  127. package/scripts/init.sh +49 -0
  128. package/scripts/upgrade.sh +94 -0
  129. package/skills/code/SKILL.md +526 -0
  130. package/skills/code/SKILL.tmpl +176 -0
  131. package/skills/debug/SKILL.md +584 -0
  132. package/skills/debug/SKILL.tmpl +262 -0
  133. package/skills/discovery/SKILL.md +363 -0
  134. package/skills/discovery/SKILL.tmpl +147 -0
  135. package/skills/prd/SKILL.md +456 -0
  136. package/skills/prd/SKILL.tmpl +188 -0
  137. package/skills/setup-ai-first/SKILL.md +160 -0
  138. package/skills/setup-ai-first/SKILL.tmpl +107 -0
  139. package/skills/spec/SKILL.md +361 -0
  140. package/skills/spec/SKILL.tmpl +174 -0
  141. package/skills/test/SKILL.md +862 -0
  142. package/skills/test/SKILL.tmpl +296 -0
  143. package/steps/context-loader.md +163 -0
  144. package/steps/gate.md +81 -0
  145. package/steps/report-footer.md +53 -0
  146. package/steps/spawn-agent.md +123 -0
  147. package/templates/architecture.template.md +113 -0
  148. package/templates/feature.template +259 -0
  149. package/templates/platform-guide.template.md +145 -0
  150. package/templates/prd.template.md +312 -0
  151. package/templates/product-definition.template.md +168 -0
  152. package/templates/project-context.yaml +78 -0
@@ -0,0 +1,862 @@
1
+ ---
2
+ description: Generates unit and integration tests from BDD specs, runs the test suite and reports results, or smoke-tests live API endpoints on a running service. Trigger when: "/generate-tests", "/run-tests", "/smoke-test", "tạo test", "viết test", "chạy test", "generate tests", "run tests", "test kết quả", "smoke test", "test API", "kiểm tra endpoint đang chạy".
3
+ ---
4
+
5
+ # Test Skills — Generate, Run & Smoke Test
6
+
7
+ This skill handles three commands: `/generate-tests`, `/run-tests`, and `/smoke-test`.
8
+
9
+ ---
10
+
11
+ ## /generate-tests — Generate Unit & Integration Tests
12
+
13
+ ### Gate
14
+
15
+ <!-- Directory: specs/bdd/**/*.feature — or pass UC-ID/class path as argument -->
16
+ # Gate — Universal Entry Procedure
17
+
18
+ Every command must execute this gate before proceeding with its specific logic.
19
+
20
+ ## Step 0 — Sub-Agent Mode Check
21
+
22
+ Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
23
+
24
+ 1. Attempt to parse `$ARGUMENTS` as JSON.
25
+ 2. If it parses successfully **and** contains `"_agent_mode": true`:
26
+ - **Skip Steps 1, 2, and 3 of this Gate entirely.**
27
+ - Set target file = `payload.target_file`
28
+ - Set loaded context = `payload.context` (do NOT run context-loader.md)
29
+ - Set UC scope = `payload.uc_id` (process only this UC)
30
+ - Set line range = `payload.uc_section` (read only that PRD section)
31
+ - Proceed directly to the command-specific logic.
32
+ 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
33
+
34
+ ## Step 0-B — Model Check
35
+
36
+ *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
37
+
38
+ Complex generation and review commands require strong reasoning.
39
+ Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
40
+
41
+ Display and wait for response:
42
+
43
+ ```
44
+ ⚙️ MODEL CHECK
45
+ ──────────────────────────────────────────────────────────────────
46
+ Recommended : claude-opus-4-5 (or claude-opus-4)
47
+ Why needed : Spec analysis, architecture review, code generation
48
+ require deep reasoning. Smaller models miss edge cases.
49
+
50
+ To switch in Claude Code:
51
+ • Settings → Model → select "claude-opus"
52
+ • or: /model → choose claude-opus
53
+
54
+ Running on claude-opus?
55
+ Y — yes, on claude-opus → proceed
56
+ S — skip check (I accept lower quality risk with current model)
57
+ ──────────────────────────────────────────────────────────────────
58
+ ```
59
+
60
+ - "Y" → proceed to Step 1.
61
+ - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
62
+ - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
63
+
64
+ ## Step 1 — Resolve Target File
65
+
66
+ 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
67
+ 2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
68
+ 3. If `$ARGUMENTS` is empty or no match found:
69
+ - List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
70
+ - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
71
+ - Wait for user selection before continuing.
72
+
73
+ ## Step 2 — Execute Context Loader
74
+
75
+ Load all project context by following the procedure in `steps/context-loader.md`.
76
+ Store all loaded context in memory for use throughout this command session.
77
+
78
+ ## Step 3 — CHECKPOINT
79
+
80
+ After completing Steps 1 and 2, display a summary and wait for confirmation:
81
+
82
+ ```
83
+ CHECKPOINT
84
+ -----------
85
+ Target : {resolved file path}
86
+ Project : {project.name from project-context.yaml}
87
+ Tech stack : {language} / {framework}
88
+ Module : {module if set, else "not configured"}
89
+ Domains : {comma-separated domain list}
90
+
91
+ Proceed? (Y/N)
92
+ ```
93
+
94
+ Wait for explicit "Y" or "N" from the user before continuing.
95
+ - "Y" → proceed to the command-specific steps below.
96
+ - "N" → stop and ask what the user wants to change.
97
+
98
+
99
+ Also read:
100
+ - `.feature` file to understand expected behaviors
101
+ - Find files to test: Controllers with `@trace.implements={UC-ID}`, Service implementations, Facade implementations (if applicable)
102
+
103
+ ### CHECKPOINT — Test Plan
104
+
105
+ Before generating, present plan:
106
+
107
+ ```
108
+ Test Plan — {UC-ID}:
109
+
110
+ Unit Tests ({unit test framework}):
111
+ - {ServiceName}ServiceImplTest
112
+ • {method}: {scenario} → {expected result}
113
+ - {FacadeName}FacadeImplTest (if applicable)
114
+ • {method}: {scenario} → {expected result}
115
+
116
+ Integration Tests:
117
+ - {ControllerName}ControllerTest
118
+ • {endpoint}: {scenario} → HTTP {status}
119
+
120
+ Total: {N} test classes, ~{M} test cases
121
+ Proceed? (Y/N)
122
+ ```
123
+
124
+ Wait for confirmation.
125
+
126
+ ### Generate
127
+
128
+ #### Unit Test Template
129
+
130
+ ```
131
+ // @trace.verifies={UC-ID}
132
+ // @trace.test_type=unit
133
+ [Test class using your project's test framework]
134
+
135
+ class {Resource}ServiceImplTest {
136
+
137
+ // Mock dependencies
138
+
139
+ @Test
140
+ // "Should {expected outcome} when {condition}"
141
+ void methodName_whenValid_shouldReturnExpected() {
142
+ // Given — set up mocks and inputs
143
+ // When — call the method under test
144
+ // Then — assert results and verify interactions
145
+ }
146
+
147
+ @Test
148
+ // "Should throw {Exception} when {resource} not found"
149
+ void methodName_whenNotFound_shouldThrowException() {
150
+ // Given — mock returns empty/null
151
+ // When & Then — assert exception is thrown
152
+ }
153
+ }
154
+ ```
155
+
156
+ #### Integration Test Template (Controller/HTTP layer)
157
+
158
+ ```
159
+ // @trace.verifies={UC-ID}
160
+ // @trace.test_type=integration
161
+ [Integration test class for HTTP layer]
162
+
163
+ class {Resource}ControllerTest {
164
+
165
+ // Inject MockMvc or HTTP test client
166
+ // MockBean/stub the Facade/Service
167
+
168
+ @Test
169
+ // "GET /v1/{resource} - should return 200 with data"
170
+ void filter_shouldReturn200() {
171
+ // Given — stub facade/service
172
+ // When — perform HTTP GET
173
+ // Then — assert status 200 and response body
174
+ }
175
+
176
+ @Test
177
+ // "POST /v1/{resource} - should return 201 when valid"
178
+ void create_shouldReturn201() {
179
+ // Given — stub facade/service
180
+ // When — perform HTTP POST with valid body
181
+ // Then — assert status 201
182
+ }
183
+
184
+ @Test
185
+ // "POST /v1/{resource} - should return 400 when invalid"
186
+ void create_shouldReturn400WhenInvalid() {
187
+ // Given — no stub needed
188
+ // When — perform HTTP POST with missing required fields
189
+ // Then — assert status 400
190
+ }
191
+ }
192
+ ```
193
+
194
+ ### File Placement
195
+
196
+ Follow project test structure from CLAUDE.md. Typical:
197
+ ```
198
+ src/test/{language}/{package}/
199
+ ├── service/impl/{Resource}ServiceImplTest.{ext}
200
+ ├── facade/impl/{Resource}FacadeImplTest.{ext} (if applicable)
201
+ └── controller/{Resource}ControllerTest.{ext}
202
+ ```
203
+
204
+ ### Self-Review Checklist
205
+
206
+ - [ ] `@trace.verifies` tag on every test class
207
+ - [ ] Every scenario in .feature has at least one test
208
+ - [ ] Mock only the correct layer (no repo mocks in controller tests)
209
+ - [ ] Test names follow `methodName_whenCondition_shouldOutcome` pattern
210
+ - [ ] No debug print statements in tests
211
+
212
+ ### Output
213
+
214
+ ```
215
+ /generate-tests Complete — {UC-ID}:
216
+ ✅ service/{Service}Test.{ext} ({M} tests)
217
+ ✅ facade/{Facade}Test.{ext} ({M} tests)
218
+ ✅ controller/{Controller}Test.{ext} ({M} tests)
219
+ ```
220
+
221
+ # Report Footer — Standard Command Output Format
222
+
223
+ Every command report must end with this standard footer section.
224
+
225
+ ## Status Badge
226
+
227
+ Choose one based on outcome:
228
+ - `✅ Complete` — all steps succeeded, no issues found
229
+ - `❌ Failed` — command could not complete due to a blocking error
230
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
231
+
232
+ ## Output Artifacts
233
+
234
+ List every file created or modified by this command:
235
+ ```
236
+ Output Artifacts:
237
+ {created|updated} {file-path} ({brief description})
238
+ {created|updated} {file-path} ({brief description})
239
+ ```
240
+
241
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
242
+
243
+ ## Next Command Suggestion
244
+
245
+ Suggest the logical next command based on workflow phase:
246
+
247
+ | Current command | Suggest next |
248
+ |-------------------------|-----------------------------------------------|
249
+ | /define-product | `/generate-prd {product-definition-file}` |
250
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
251
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
252
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
253
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
254
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
255
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
256
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
257
+ | /generate-code | `/generate-tests {UC-ID}` |
258
+ | /generate-tests | `/run-tests {UC-ID}` |
259
+ | /run-tests (passing) | `/review-code {UC-ID}` |
260
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
261
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
262
+ | /smoke-test | Create PR and link to ticket |
263
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
264
+ | /fix-bug | Create PR and link to ticket |
265
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
266
+
267
+ Format the footer as:
268
+ ```
269
+ ---
270
+ Status : {badge}
271
+ {Output Artifacts block}
272
+ Next : {suggested command with example arguments}
273
+ ```
274
+
275
+
276
+ ---
277
+
278
+ ## /run-tests — Run Tests & Report Results
279
+
280
+ ### Gate
281
+
282
+ # Context Loader — Load All Project Context
283
+
284
+ Execute these steps in order. Store everything in memory for the duration of the command session.
285
+
286
+ **Priority guide (anti-lost-in-middle):**
287
+ - Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
288
+ - Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
289
+ - Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
290
+ - Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
291
+ - Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
292
+
293
+ ---
294
+
295
+ ## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
296
+
297
+ Read `.agent/project-context.yaml`. Extract and store:
298
+
299
+ **Tech Stack:**
300
+ - `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
301
+ - `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
302
+ - `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
303
+ - `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
304
+ - `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
305
+ - `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
306
+
307
+ **Conventions:**
308
+ - `conventions.build_command` → how to compile/build
309
+ - `conventions.test_command` → how to run tests
310
+ - `conventions.service_run` → how to start the service
311
+ - `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
312
+
313
+ **Domains:**
314
+ - `domains` → list of active business domains
315
+
316
+ **Paths (if present):**
317
+ - `paths.specs_dir` → BDD specs root
318
+ - `paths.prd_dir` → PRD documents root
319
+ - `paths.refinement_dir` → findings/review output dir
320
+ - `paths.product_definitions_dir` → product definitions root
321
+ - `paths.domain_knowledge_dir` → domain knowledge root
322
+ - `paths.business_dictionary` → path to business-dictionary.md
323
+ - `paths.core_entities` → path to core-entities.md
324
+ - `paths.tech_docs_dir` → technical documentation root
325
+ - `paths.trace_dir` → trace state directory
326
+
327
+ If `paths` section is absent, use these defaults:
328
+ - `specs_dir` = `specs/bdd`
329
+ - `prd_dir` = `specs/prd`
330
+ - `refinement_dir` = `.agent/review`
331
+ - `product_definitions_dir` = `specs/product-definition`
332
+ - `domain_knowledge_dir` = `specs/domain-knowledge`
333
+ - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
334
+ - `core_entities` = `specs/domain-knowledge/core-entities.md`
335
+ - `tech_docs_dir` = `tech-docs`
336
+ - `trace_dir` = `.trace`
337
+
338
+ If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
339
+
340
+ ---
341
+
342
+ ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
343
+
344
+ If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
345
+ Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
346
+ If the file does not exist → skip silently.
347
+
348
+ ---
349
+
350
+ ## Step 3 — [CRITICAL] Load CLAUDE.md
351
+
352
+ *This is the highest-priority context — it defines HOW to write code and documents for this project.*
353
+
354
+ Read `CLAUDE.md`. Extract and store:
355
+
356
+ - **§1 Project Overview** → project name, language, framework, build/test commands, domains
357
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
358
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
359
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
360
+ - **§7 Git Conventions** → branch naming pattern, commit message format
361
+
362
+ If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
363
+
364
+ ---
365
+
366
+ ## Step 4 — [SAFETY] Load Data Protection Rules
367
+
368
+ Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
369
+
370
+ Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
371
+
372
+ If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
373
+
374
+ ---
375
+
376
+ ## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
377
+
378
+ Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
379
+
380
+ If it exists, read it and extract:
381
+ - **Canonical Terms** → complete list of approved terms and their definitions
382
+ - **Banned Terms** → complete list of banned terms and their canonical replacements
383
+ - **Status / Enum Registry** → allowed enum values per entity
384
+
385
+ Store the banned terms list for **active enforcement** throughout the command session:
386
+ - When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
387
+ - Replace banned terms with their canonical equivalents automatically
388
+
389
+ If the file does not exist → skip silently. Do not warn or block.
390
+
391
+ ---
392
+
393
+ ## Step 6 — [DOMAIN] Load Core Entities (conditional)
394
+
395
+ Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
396
+ Default path: `specs/domain-knowledge/core-entities.md`.
397
+
398
+ If it exists, read it and store:
399
+ - **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
400
+ - **Field name registry** → canonical field names to use in generated code and documents
401
+ - **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
402
+
403
+ **How to use this catalog:**
404
+ - When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
405
+ - When generating PRD/BDD: reference entity names from this catalog for consistency
406
+ - When generating tech-docs: use this catalog as the source-of-truth for entity definitions
407
+
408
+ If the file does not exist → skip silently.
409
+
410
+ ---
411
+
412
+ ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
413
+
414
+ After loading all context, synthesize and output a compact summary block.
415
+ This recap ensures the most critical facts are stated at the END of context loading
416
+ (recency effect — freshest in working memory when the task begins).
417
+
418
+ Output exactly this block:
419
+ ```
420
+ [CTX LOADED]
421
+ Stack : {language} / {framework} / {database}
422
+ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
423
+ Ticket : {ticket_prefix}-
424
+ Dict : {loaded — N canonical terms, M banned terms | missing}
425
+ Entities : {loaded — EntityA, EntityB, EntityC | missing}
426
+ Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
427
+ ```
428
+
429
+ If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
430
+
431
+ ---
432
+
433
+ ## Context Load Complete
434
+
435
+ After completing all steps, you have loaded:
436
+ - Project identity, tech stack, module conventions
437
+ - Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
438
+ - Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
439
+ - Data protection rules (sensitive file patterns to never access)
440
+ - Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
441
+ - Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
442
+ - All configured paths
443
+
444
+ Proceed to the next step of the calling command.
445
+
446
+
447
+ Identify service/module from argument (UC-ID or service name).
448
+ Read `conventions.test_command` from the loaded project context.
449
+
450
+ ### Run
451
+
452
+ ```bash
453
+ # Run all tests in module
454
+ {TEST_COMMAND}
455
+
456
+ # Run specific test class (faster)
457
+ {TEST_COMMAND_FOR_CLASS}
458
+
459
+ # Run by pattern
460
+ {TEST_COMMAND_BY_PATTERN}
461
+ ```
462
+
463
+ ### Analyze Results
464
+
465
+ #### When tests PASS
466
+
467
+ ```
468
+ ✅ Tests passed
469
+ - Total: {N}
470
+ - Passed: {N}
471
+ - Duration: {X}s
472
+ ```
473
+
474
+ #### When tests FAIL — Debug Mode
475
+
476
+ Read stack trace and analyze:
477
+
478
+ | Error Pattern | Common Cause | Suggested Fix |
479
+ |---|---|---|
480
+ | NullPointerException in test | Missing mock setup | Check `given(...)` setup for null dependency |
481
+ | Bean/dependency not found | Missing mock/stub declaration | Add mock for missing dependency |
482
+ | Expected 200 but got 403 | Missing auth setup in test | Add auth user/role to test context |
483
+ | Expected 200 but got 400 | Request body fails validation | Check required fields in request DTO |
484
+ | LazyInitializationException | Lazy collection accessed outside transaction | Add `@Transactional` on test or use eager fetch |
485
+ | Mapper/mapper implementation not found | Code generator (e.g. MapStruct) not run | Run compile step before tests |
486
+
487
+ ### Output
488
+
489
+ ```
490
+ /run-tests Report — {service}
491
+ Run at: {datetime}
492
+
493
+ ## Summary
494
+ ✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K}
495
+ Duration: {X}s
496
+
497
+ ## Failed Tests
498
+ | Test | Error | Root Cause |
499
+ |------|-------|-----------|
500
+ | {TestClass}.{method} | {exception} | {analysis} |
501
+
502
+ ## Recommendations
503
+ {specific fix for each failure}
504
+ ```
505
+
506
+ # Report Footer — Standard Command Output Format
507
+
508
+ Every command report must end with this standard footer section.
509
+
510
+ ## Status Badge
511
+
512
+ Choose one based on outcome:
513
+ - `✅ Complete` — all steps succeeded, no issues found
514
+ - `❌ Failed` — command could not complete due to a blocking error
515
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
516
+
517
+ ## Output Artifacts
518
+
519
+ List every file created or modified by this command:
520
+ ```
521
+ Output Artifacts:
522
+ {created|updated} {file-path} ({brief description})
523
+ {created|updated} {file-path} ({brief description})
524
+ ```
525
+
526
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
527
+
528
+ ## Next Command Suggestion
529
+
530
+ Suggest the logical next command based on workflow phase:
531
+
532
+ | Current command | Suggest next |
533
+ |-------------------------|-----------------------------------------------|
534
+ | /define-product | `/generate-prd {product-definition-file}` |
535
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
536
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
537
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
538
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
539
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
540
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
541
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
542
+ | /generate-code | `/generate-tests {UC-ID}` |
543
+ | /generate-tests | `/run-tests {UC-ID}` |
544
+ | /run-tests (passing) | `/review-code {UC-ID}` |
545
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
546
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
547
+ | /smoke-test | Create PR and link to ticket |
548
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
549
+ | /fix-bug | Create PR and link to ticket |
550
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
551
+
552
+ Format the footer as:
553
+ ```
554
+ ---
555
+ Status : {badge}
556
+ {Output Artifacts block}
557
+ Next : {suggested command with example arguments}
558
+ ```
559
+
560
+
561
+ ---
562
+
563
+ ## /smoke-test — Test Live API Endpoints
564
+
565
+ Use when the service is **already running** to verify endpoints work correctly.
566
+ Different from `/run-tests` (which runs unit/integration tests without a live server).
567
+
568
+ ### Phase 1 — Find Service URL
569
+
570
+ # Context Loader — Load All Project Context
571
+
572
+ Execute these steps in order. Store everything in memory for the duration of the command session.
573
+
574
+ **Priority guide (anti-lost-in-middle):**
575
+ - Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
576
+ - Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
577
+ - Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
578
+ - Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
579
+ - Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
580
+
581
+ ---
582
+
583
+ ## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
584
+
585
+ Read `.agent/project-context.yaml`. Extract and store:
586
+
587
+ **Tech Stack:**
588
+ - `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
589
+ - `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
590
+ - `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
591
+ - `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
592
+ - `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
593
+ - `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
594
+
595
+ **Conventions:**
596
+ - `conventions.build_command` → how to compile/build
597
+ - `conventions.test_command` → how to run tests
598
+ - `conventions.service_run` → how to start the service
599
+ - `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
600
+
601
+ **Domains:**
602
+ - `domains` → list of active business domains
603
+
604
+ **Paths (if present):**
605
+ - `paths.specs_dir` → BDD specs root
606
+ - `paths.prd_dir` → PRD documents root
607
+ - `paths.refinement_dir` → findings/review output dir
608
+ - `paths.product_definitions_dir` → product definitions root
609
+ - `paths.domain_knowledge_dir` → domain knowledge root
610
+ - `paths.business_dictionary` → path to business-dictionary.md
611
+ - `paths.core_entities` → path to core-entities.md
612
+ - `paths.tech_docs_dir` → technical documentation root
613
+ - `paths.trace_dir` → trace state directory
614
+
615
+ If `paths` section is absent, use these defaults:
616
+ - `specs_dir` = `specs/bdd`
617
+ - `prd_dir` = `specs/prd`
618
+ - `refinement_dir` = `.agent/review`
619
+ - `product_definitions_dir` = `specs/product-definition`
620
+ - `domain_knowledge_dir` = `specs/domain-knowledge`
621
+ - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
622
+ - `core_entities` = `specs/domain-knowledge/core-entities.md`
623
+ - `tech_docs_dir` = `tech-docs`
624
+ - `trace_dir` = `.trace`
625
+
626
+ If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
627
+
628
+ ---
629
+
630
+ ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
631
+
632
+ If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
633
+ Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
634
+ If the file does not exist → skip silently.
635
+
636
+ ---
637
+
638
+ ## Step 3 — [CRITICAL] Load CLAUDE.md
639
+
640
+ *This is the highest-priority context — it defines HOW to write code and documents for this project.*
641
+
642
+ Read `CLAUDE.md`. Extract and store:
643
+
644
+ - **§1 Project Overview** → project name, language, framework, build/test commands, domains
645
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
646
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
647
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
648
+ - **§7 Git Conventions** → branch naming pattern, commit message format
649
+
650
+ If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
651
+
652
+ ---
653
+
654
+ ## Step 4 — [SAFETY] Load Data Protection Rules
655
+
656
+ Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
657
+
658
+ Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
659
+
660
+ If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
661
+
662
+ ---
663
+
664
+ ## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
665
+
666
+ Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
667
+
668
+ If it exists, read it and extract:
669
+ - **Canonical Terms** → complete list of approved terms and their definitions
670
+ - **Banned Terms** → complete list of banned terms and their canonical replacements
671
+ - **Status / Enum Registry** → allowed enum values per entity
672
+
673
+ Store the banned terms list for **active enforcement** throughout the command session:
674
+ - When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
675
+ - Replace banned terms with their canonical equivalents automatically
676
+
677
+ If the file does not exist → skip silently. Do not warn or block.
678
+
679
+ ---
680
+
681
+ ## Step 6 — [DOMAIN] Load Core Entities (conditional)
682
+
683
+ Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
684
+ Default path: `specs/domain-knowledge/core-entities.md`.
685
+
686
+ If it exists, read it and store:
687
+ - **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
688
+ - **Field name registry** → canonical field names to use in generated code and documents
689
+ - **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
690
+
691
+ **How to use this catalog:**
692
+ - When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
693
+ - When generating PRD/BDD: reference entity names from this catalog for consistency
694
+ - When generating tech-docs: use this catalog as the source-of-truth for entity definitions
695
+
696
+ If the file does not exist → skip silently.
697
+
698
+ ---
699
+
700
+ ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
701
+
702
+ After loading all context, synthesize and output a compact summary block.
703
+ This recap ensures the most critical facts are stated at the END of context loading
704
+ (recency effect — freshest in working memory when the task begins).
705
+
706
+ Output exactly this block:
707
+ ```
708
+ [CTX LOADED]
709
+ Stack : {language} / {framework} / {database}
710
+ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
711
+ Ticket : {ticket_prefix}-
712
+ Dict : {loaded — N canonical terms, M banned terms | missing}
713
+ Entities : {loaded — EntityA, EntityB, EntityC | missing}
714
+ Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
715
+ ```
716
+
717
+ If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
718
+
719
+ ---
720
+
721
+ ## Context Load Complete
722
+
723
+ After completing all steps, you have loaded:
724
+ - Project identity, tech stack, module conventions
725
+ - Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
726
+ - Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
727
+ - Data protection rules (sensitive file patterns to never access)
728
+ - Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
729
+ - Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
730
+ - All configured paths
731
+
732
+ Proceed to the next step of the calling command.
733
+
734
+
735
+ Read `conventions.service_run` from the loaded project context to find port.
736
+ Default: `http://localhost:8080`
737
+
738
+ Check if service is running:
739
+ ```bash
740
+ curl -s http://localhost:{port}/health
741
+ # or /actuator/health for Spring Boot
742
+ ```
743
+
744
+ If not running: "Service is not running. Start it with: `{RUN_COMMAND}` from your project root."
745
+
746
+ ### Phase 2 — Identify Endpoints
747
+
748
+ From UC-ID → find Controller with `@trace.implements={UC-ID}`:
749
+ - List: method, path, required auth/role
750
+
751
+ ### Phase 3 — Get Auth Token (if needed)
752
+
753
+ If endpoints require auth, ask:
754
+ ```
755
+ This endpoint requires authentication. Options:
756
+ 1. Paste your Bearer token (from Postman / browser DevTools / test login)
757
+ 2. Use a test/dev token from your local config
758
+ 3. Skip auth — only test public endpoints
759
+ ```
760
+
761
+ ### Phase 4 — Run Smoke Test
762
+
763
+ ```bash
764
+ # GET
765
+ curl -s -X GET "http://localhost:{port}/v1/{resource}?page=0&size=5" \
766
+ -H "Authorization: Bearer {token}" | {JSON_FORMATTER}
767
+
768
+ # POST
769
+ curl -s -X POST "http://localhost:{port}/v1/{resource}" \
770
+ -H "Authorization: Bearer {token}" \
771
+ -H "Content-Type: application/json" \
772
+ -d '{"field1": "test_value"}'
773
+ ```
774
+
775
+ ### Phase 5 — Interpret Results
776
+
777
+ | Result | Meaning |
778
+ |--------|---------|
779
+ | 200/201 + correct data | ✅ OK |
780
+ | 200 + wrong data | ⚠️ Logic bug → use `/debug` |
781
+ | 400 | Request body wrong → check required fields |
782
+ | 401 | Token expired or wrong realm |
783
+ | 403 | Wrong role → check auth config |
784
+ | 500 + stacktrace | Server error → paste into `/debug` |
785
+ | Connection refused | Service not running or wrong port |
786
+
787
+ If errors in logs:
788
+ ```bash
789
+ tail -n 100 {LOG_FILE_PATH}
790
+ ```
791
+
792
+ ### Output
793
+
794
+ ```
795
+ /smoke-test Report — {UC-ID}
796
+ Tested at: {datetime}
797
+ Base URL: http://localhost:{port}
798
+
799
+ ## Endpoints Tested
800
+ | Method | Path | Status | Result |
801
+ |--------|------|--------|--------|
802
+ | GET | /v1/{resource} | 200 ✅ | 5 records returned |
803
+ | POST | /v1/{resource} | 201 ✅ | Created id=42 |
804
+
805
+ ## Issues Found
806
+ {describe any failures}
807
+ ```
808
+
809
+ # Report Footer — Standard Command Output Format
810
+
811
+ Every command report must end with this standard footer section.
812
+
813
+ ## Status Badge
814
+
815
+ Choose one based on outcome:
816
+ - `✅ Complete` — all steps succeeded, no issues found
817
+ - `❌ Failed` — command could not complete due to a blocking error
818
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
819
+
820
+ ## Output Artifacts
821
+
822
+ List every file created or modified by this command:
823
+ ```
824
+ Output Artifacts:
825
+ {created|updated} {file-path} ({brief description})
826
+ {created|updated} {file-path} ({brief description})
827
+ ```
828
+
829
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
830
+
831
+ ## Next Command Suggestion
832
+
833
+ Suggest the logical next command based on workflow phase:
834
+
835
+ | Current command | Suggest next |
836
+ |-------------------------|-----------------------------------------------|
837
+ | /define-product | `/generate-prd {product-definition-file}` |
838
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
839
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
840
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
841
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
842
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
843
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
844
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
845
+ | /generate-code | `/generate-tests {UC-ID}` |
846
+ | /generate-tests | `/run-tests {UC-ID}` |
847
+ | /run-tests (passing) | `/review-code {UC-ID}` |
848
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
849
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
850
+ | /smoke-test | Create PR and link to ticket |
851
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
852
+ | /fix-bug | Create PR and link to ticket |
853
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
854
+
855
+ Format the footer as:
856
+ ```
857
+ ---
858
+ Status : {badge}
859
+ {Output Artifacts block}
860
+ Next : {suggested command with example arguments}
861
+ ```
862
+