@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,221 @@
1
+ # /review-tech-docs — Review Technical Design Document
2
+
3
+ **READ-ONLY analysis mode — writes a findings file, does NOT modify the target.**
4
+ **Use `--resume` to apply accepted findings.**
5
+
6
+ ## Gate
7
+ {{include:steps/gate.md}}
8
+
9
+ *Note: For this command, the target in Step 1 is a tech-design `.md` file in `{paths.tech_docs_dir}/{domain}/`.
10
+ If `$ARGUMENTS` contains `--resume` → skip to Resume Mode below.*
11
+
12
+ ## Context
13
+ {{include:steps/context-loader.md}}
14
+
15
+ ---
16
+
17
+ ## Load Review Materials
18
+
19
+ After loading base context, read the following in order:
20
+
21
+ 1. **Target tech-doc** — read fully. Extract from header:
22
+ - `@trace.id` → UC-ID
23
+ - `@trace.domain` → domain
24
+ - `@trace.prd` → source PRD ticket ID
25
+ - `@trace.status` → current status (draft / in-review / approved)
26
+
27
+ 2. **Source feature file** — load `{paths.specs_dir}/{domain}/{UC-ID}*.feature` if exists.
28
+
29
+ 3. **Other tech-docs in same domain** — list and load all `.md` files in
30
+ `{paths.tech_docs_dir}/{domain}/` excluding the target. Used for conflict checking (T4).
31
+
32
+ 4. **Architecture reference** — re-confirm CLAUDE.md §2: layer order, architectural rules.
33
+
34
+ 5. **Core entities** — already loaded in context (Step 6 of context-loader).
35
+
36
+ Derive findings filename:
37
+ `{paths.refinement_dir}/{uc-id}-tech-review-findings.yaml`
38
+
39
+ ---
40
+
41
+ ## Review Dimensions
42
+
43
+ ### T1 — Architecture Alignment *(always CRITICAL if violated)*
44
+
45
+ Cross-reference the proposed design against CLAUDE.md §2 rules:
46
+
47
+ | Violation type | Severity |
48
+ |----------------|----------|
49
+ | Controller calls Repository directly (layer skip) | Critical |
50
+ | Business logic in Controller or DTO | Critical |
51
+ | Forbidden pattern from §3 | Critical |
52
+ | Dependency going upstream (Service → Controller DTO) | Critical |
53
+ | Transaction annotation on wrong layer | Major |
54
+ | Missing separation (no Facade when arch requires it) | Major |
55
+
56
+ For each finding:
57
+ ```
58
+ Component: {class or method name}
59
+ Violates: "{rule text}" (CLAUDE.md §2)
60
+ Fix: {which layer/component should own this instead}
61
+ ```
62
+ → **Not auto-fixable.** Human must decide structural fix. Note required in Review Board.
63
+
64
+ ### T2 — Entity Consistency
65
+
66
+ Using the loaded core-entities catalog:
67
+
68
+ | Issue | Severity | Auto-fixable? |
69
+ |-------|----------|---------------|
70
+ | Entity mentioned not in core-entities.md | Major | No — human confirms if DTO or domain entity |
71
+ | Field name differs from core-entities.md | Major | Yes — rename to canonical |
72
+ | Relationship described differently | Major | No — human decides |
73
+ | New entity introduced but not in core-entities.md | Minor | No — add to core-entities first |
74
+
75
+ ### T3 — BDD Traceability
76
+
77
+ Cross-reference against the source `.feature` file:
78
+
79
+ | Issue | Severity | Auto-fixable? |
80
+ |-------|----------|---------------|
81
+ | Tech-doc proposes behavior not in any BDD scenario | Major | No — create scenario first |
82
+ | Tech-doc contradicts a BDD scenario | Critical | No — resolve conflict first |
83
+ | UC scenario has no corresponding design decision | Minor | Yes — add missing design note |
84
+
85
+ ### T4 — Domain Conflict Check
86
+
87
+ Compare against other tech-docs in `{paths.tech_docs_dir}/{domain}/`:
88
+
89
+ | Issue | Severity | Auto-fixable? |
90
+ |-------|----------|---------------|
91
+ | Same endpoint defined with different request/response | Critical | No — human resolves |
92
+ | Same service method with different behavior | Critical | No — human resolves |
93
+ | Entity status transitions differ between docs | Critical | No — human resolves |
94
+ | Overlapping responsibility (both docs claim ownership of same logic) | Major | No — human resolves |
95
+
96
+ ### T5 — Internal Consistency
97
+
98
+ Within the tech-doc itself:
99
+
100
+ | Check | Severity | Auto-fixable? |
101
+ |-------|----------|---------------|
102
+ | Sequence diagram shows different flow than written description | Major | No |
103
+ | API spec return type differs from code sketch | Major | Yes — align one to the other |
104
+ | Section references a component/concept never defined later | Minor | Yes — add definition |
105
+ | Assumption stated but no design addresses it | Minor | Yes — add note or remove assumption |
106
+
107
+ ### T6 — Structural Completeness
108
+
109
+ Check all standard sections are present and non-empty:
110
+
111
+ | Section | Missing severity |
112
+ |---------|-----------------|
113
+ | Header (`@trace.id`, `@trace.prd`, `@trace.domain`, `@trace.status`) | Major |
114
+ | Overview / Context | Major |
115
+ | Architecture Decision with rationale | Major |
116
+ | Component Diagram or Layer Description | Major |
117
+ | Sequence Diagram or Flow Steps | Major |
118
+ | API Contract (if HTTP-facing) | Major |
119
+ | Data Model Changes (if entity changes) | Major |
120
+ | Error Handling Strategy | Major |
121
+ | Open Questions / Assumptions | Minor |
122
+
123
+ → All T6 missing-section findings are **auto-fixable**: AI adds skeleton section with prompts.
124
+
125
+ ---
126
+
127
+ ## Write Findings File
128
+
129
+ After running all checks, write findings to `{paths.refinement_dir}/{uc-id}-tech-review-findings.yaml`:
130
+
131
+ ```yaml
132
+ source_file: "{absolute path to tech-doc}"
133
+ uc_id: "{UC-ID}"
134
+ domain: "{domain}"
135
+ generated_at: "{ISO datetime}"
136
+ review_type: "tech-design"
137
+ status: "pending_review"
138
+
139
+ findings:
140
+ - id: "F001"
141
+ check_id: "T1" # T1–T6
142
+ severity: "critical" # critical | major | minor
143
+ section: "{section heading or component name where issue was found}"
144
+ finding: "{clear description of the violation or gap}"
145
+ suggestion: "{specific fix — AI applies this in --resume if accepted}"
146
+ auto_fixable: false # true = AI can apply; false = human must write decision in note
147
+ status: "pending" # pending | accepted | modified | rejected | deferred
148
+
149
+ summary:
150
+ total_findings: {N}
151
+ by_severity: { critical: {N}, major: {N}, minor: {N} }
152
+ auto_fixable: {N}
153
+ requires_human_decision: {N}
154
+ recommendation: "APPROVED | NEEDS_REVISION | BLOCKED"
155
+ ```
156
+
157
+ ## Report
158
+
159
+ {{include:steps/report-footer.md}}
160
+
161
+ ```
162
+ /review-tech-docs Complete — {target file}
163
+ UC: {UC-ID} | Domain: {domain}
164
+ Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
165
+ Auto-fixable: {N} | Needs human decision: {N}
166
+
167
+ Findings file: {paths.refinement_dir}/{uc-id}-tech-review-findings.yaml
168
+ Next: Open in Review Board → Accept/Modify/Reject each finding
169
+ Then run: /review-tech-docs --resume {tech-design-file}
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Resume Mode — Apply Accepted Findings
175
+
176
+ *Triggered when `$ARGUMENTS` contains `--resume`.*
177
+ *Example: `/review-tech-docs --resume tech-docs/payment/PAY-UC1-tech-design.md`*
178
+
179
+ ### Phase 1 — Read accepted findings
180
+
181
+ 1. Derive findings file from target: `{paths.refinement_dir}/{uc-id}-tech-review-findings.yaml`
182
+ 2. Read the file. Collect findings where `status: "accepted"` or `status: "modified"`.
183
+ 3. If none → report "No accepted findings. File unchanged." and stop.
184
+
185
+ ### Phase 2 — Apply fixes
186
+
187
+ Apply in order: critical → major → minor.
188
+
189
+ | check_id | What to do |
190
+ |----------|-----------|
191
+ | T1 (Architecture) | Apply the structural fix from finding note — move logic to correct layer, update component description |
192
+ | T2 (Field name) | Rename field to canonical name from core-entities.md throughout the document |
193
+ | T3 (Missing design note) | Add design decision note for the uncovered scenario |
194
+ | T5 (Internal inconsistency) | Align the conflicting sections to the decision stated in the note |
195
+ | T6 (Missing section) | Add skeleton section with placeholder prompts for the tech lead to fill |
196
+
197
+ **T1, T2, T4 findings with `auto_fixable: false`:** require a human-written resolution in the
198
+ Review Board "Modify" note. Apply exactly what the note says. Do not invent the fix.
199
+
200
+ ### Phase 3 — Update header + Report
201
+
202
+ 1. Increment `@trace.revision` in the tech-doc header by 1.
203
+ 2. Update `@trace.status` to `draft` (reset — must be re-approved after changes).
204
+
205
+ ```
206
+ /review-tech-docs --resume Applied — {target file}
207
+ UC: {UC-ID}
208
+
209
+ Applied : {N} findings ({critical} critical, {major} major, {minor} minor)
210
+ Skipped : {N} rejected/deferred
211
+
212
+ Changes:
213
+ - {change 1}
214
+ - {change 2}
215
+
216
+ Revision : {old} → {new}
217
+ Status : reset to draft (re-approval required)
218
+
219
+ Re-run /review-tech-docs {file} to confirm 0 remaining critical findings.
220
+ Next: /generate-code {feature-file}
221
+ ```
@@ -0,0 +1,343 @@
1
+ # /run-tests — Run Tests & Report Results
2
+
3
+ ## Gate
4
+ # Gate — Universal Entry Procedure
5
+
6
+ Every command must execute this gate before proceeding with its specific logic.
7
+
8
+ ## Step 0 — Sub-Agent Mode Check
9
+
10
+ Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
11
+
12
+ 1. Attempt to parse `$ARGUMENTS` as JSON.
13
+ 2. If it parses successfully **and** contains `"_agent_mode": true`:
14
+ - **Skip Steps 1, 2, and 3 of this Gate entirely.**
15
+ - Set target file = `payload.target_file`
16
+ - Set loaded context = `payload.context` (do NOT run context-loader.md)
17
+ - Set UC scope = `payload.uc_id` (process only this UC)
18
+ - Set line range = `payload.uc_section` (read only that PRD section)
19
+ - Proceed directly to the command-specific logic.
20
+ 3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
21
+
22
+ ## Step 0-B — Model Check
23
+
24
+ *Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
25
+
26
+ Complex generation and review commands require strong reasoning.
27
+ Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
28
+
29
+ Display and wait for response:
30
+
31
+ ```
32
+ ⚙️ MODEL CHECK
33
+ ──────────────────────────────────────────────────────────────────
34
+ Recommended : claude-opus-4-5 (or claude-opus-4)
35
+ Why needed : Spec analysis, architecture review, code generation
36
+ require deep reasoning. Smaller models miss edge cases.
37
+
38
+ To switch in Claude Code:
39
+ • Settings → Model → select "claude-opus"
40
+ • or: /model → choose claude-opus
41
+
42
+ Running on claude-opus?
43
+ Y — yes, on claude-opus → proceed
44
+ S — skip check (I accept lower quality risk with current model)
45
+ ──────────────────────────────────────────────────────────────────
46
+ ```
47
+
48
+ - "Y" → proceed to Step 1.
49
+ - "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
50
+ - "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
51
+
52
+ ## Step 1 — Resolve Target File
53
+
54
+ 1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
55
+ 2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
56
+ 3. If `$ARGUMENTS` is empty or no match found:
57
+ - List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
58
+ - Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
59
+ - Wait for user selection before continuing.
60
+
61
+ ## Step 2 — Execute Context Loader
62
+
63
+ Load all project context by following the procedure in `steps/context-loader.md`.
64
+ Store all loaded context in memory for use throughout this command session.
65
+
66
+ ## Step 3 — CHECKPOINT
67
+
68
+ After completing Steps 1 and 2, display a summary and wait for confirmation:
69
+
70
+ ```
71
+ CHECKPOINT
72
+ -----------
73
+ Target : {resolved file path}
74
+ Project : {project.name from project-context.yaml}
75
+ Tech stack : {language} / {framework}
76
+ Module : {module if set, else "not configured"}
77
+ Domains : {comma-separated domain list}
78
+
79
+ Proceed? (Y/N)
80
+ ```
81
+
82
+ Wait for explicit "Y" or "N" from the user before continuing.
83
+ - "Y" → proceed to the command-specific steps below.
84
+ - "N" → stop and ask what the user wants to change.
85
+
86
+
87
+ *Note: For this command, the target in Step 1 is a UC-ID or service name from `$ARGUMENTS`. Context loading provides `conventions.test_command`.*
88
+
89
+ ## Context
90
+ # Context Loader — Load All Project Context
91
+
92
+ Execute these steps in order. Store everything in memory for the duration of the command session.
93
+
94
+ **Priority guide (anti-lost-in-middle):**
95
+ - Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
96
+ - Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
97
+ - Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
98
+ - Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
99
+ - Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
100
+
101
+ ---
102
+
103
+ ## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
104
+
105
+ Read `.agent/project-context.yaml`. Extract and store:
106
+
107
+ **Tech Stack:**
108
+ - `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
109
+ - `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
110
+ - `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
111
+ - `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
112
+ - `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
113
+ - `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
114
+
115
+ **Conventions:**
116
+ - `conventions.build_command` → how to compile/build
117
+ - `conventions.test_command` → how to run tests
118
+ - `conventions.service_run` → how to start the service
119
+ - `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
120
+
121
+ **Domains:**
122
+ - `domains` → list of active business domains
123
+
124
+ **Paths (if present):**
125
+ - `paths.specs_dir` → BDD specs root
126
+ - `paths.prd_dir` → PRD documents root
127
+ - `paths.refinement_dir` → findings/review output dir
128
+ - `paths.product_definitions_dir` → product definitions root
129
+ - `paths.domain_knowledge_dir` → domain knowledge root
130
+ - `paths.business_dictionary` → path to business-dictionary.md
131
+ - `paths.core_entities` → path to core-entities.md
132
+ - `paths.tech_docs_dir` → technical documentation root
133
+ - `paths.trace_dir` → trace state directory
134
+
135
+ If `paths` section is absent, use these defaults:
136
+ - `specs_dir` = `specs/bdd`
137
+ - `prd_dir` = `specs/prd`
138
+ - `refinement_dir` = `.agent/review`
139
+ - `product_definitions_dir` = `specs/product-definition`
140
+ - `domain_knowledge_dir` = `specs/domain-knowledge`
141
+ - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
142
+ - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
+ - `tech_docs_dir` = `tech-docs`
144
+ - `trace_dir` = `.trace`
145
+
146
+ If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
+
148
+ ---
149
+
150
+ ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
+
152
+ If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
153
+ Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
154
+ If the file does not exist → skip silently.
155
+
156
+ ---
157
+
158
+ ## Step 3 — [CRITICAL] Load CLAUDE.md
159
+
160
+ *This is the highest-priority context — it defines HOW to write code and documents for this project.*
161
+
162
+ Read `CLAUDE.md`. Extract and store:
163
+
164
+ - **§1 Project Overview** → project name, language, framework, build/test commands, domains
165
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
166
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
167
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
168
+ - **§7 Git Conventions** → branch naming pattern, commit message format
169
+
170
+ If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
171
+
172
+ ---
173
+
174
+ ## Step 4 — [SAFETY] Load Data Protection Rules
175
+
176
+ Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
177
+
178
+ Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
179
+
180
+ If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
181
+
182
+ ---
183
+
184
+ ## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
185
+
186
+ Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
187
+
188
+ If it exists, read it and extract:
189
+ - **Canonical Terms** → complete list of approved terms and their definitions
190
+ - **Banned Terms** → complete list of banned terms and their canonical replacements
191
+ - **Status / Enum Registry** → allowed enum values per entity
192
+
193
+ Store the banned terms list for **active enforcement** throughout the command session:
194
+ - When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
195
+ - Replace banned terms with their canonical equivalents automatically
196
+
197
+ If the file does not exist → skip silently. Do not warn or block.
198
+
199
+ ---
200
+
201
+ ## Step 6 — [DOMAIN] Load Core Entities (conditional)
202
+
203
+ Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
204
+ Default path: `specs/domain-knowledge/core-entities.md`.
205
+
206
+ If it exists, read it and store:
207
+ - **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
208
+ - **Field name registry** → canonical field names to use in generated code and documents
209
+ - **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
210
+
211
+ **How to use this catalog:**
212
+ - When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
213
+ - When generating PRD/BDD: reference entity names from this catalog for consistency
214
+ - When generating tech-docs: use this catalog as the source-of-truth for entity definitions
215
+
216
+ If the file does not exist → skip silently.
217
+
218
+ ---
219
+
220
+ ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
221
+
222
+ After loading all context, synthesize and output a compact summary block.
223
+ This recap ensures the most critical facts are stated at the END of context loading
224
+ (recency effect — freshest in working memory when the task begins).
225
+
226
+ Output exactly this block:
227
+ ```
228
+ [CTX LOADED]
229
+ Stack : {language} / {framework} / {database}
230
+ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
231
+ Ticket : {ticket_prefix}-
232
+ Dict : {loaded — N canonical terms, M banned terms | missing}
233
+ Entities : {loaded — EntityA, EntityB, EntityC | missing}
234
+ Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
235
+ ```
236
+
237
+ If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
238
+
239
+ ---
240
+
241
+ ## Context Load Complete
242
+
243
+ After completing all steps, you have loaded:
244
+ - Project identity, tech stack, module conventions
245
+ - Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
246
+ - Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
247
+ - Data protection rules (sensitive file patterns to never access)
248
+ - Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
249
+ - Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
250
+ - All configured paths
251
+
252
+ Proceed to the next step of the calling command.
253
+
254
+
255
+ ---
256
+
257
+ ## Run
258
+ ```bash
259
+ {conventions.test_command} # all tests in module
260
+ {conventions.test_command} --class {ClassName} # specific class (faster)
261
+ {conventions.test_command} --pattern "*{Resource}*" # by pattern
262
+ ```
263
+
264
+ ## Analyze Failures
265
+
266
+ | Error Pattern | Common Cause | Suggested Fix |
267
+ |---|---|---|
268
+ | NullPointerException | Missing mock setup | Check `given(...)` for null dependency |
269
+ | Bean not found | Missing mock declaration | Add mock for missing dependency |
270
+ | Expected 200, got 403 | Missing auth setup | Add auth user/role to test context |
271
+ | Expected 200, got 400 | Request body fails validation | Check required fields in DTO |
272
+ | LazyInitializationException | Lazy collection outside transaction | Add `@Transactional` or eager fetch |
273
+ | Mapper not found | Code generator not run | Run compile step before tests |
274
+
275
+ ## Output
276
+
277
+ # Report Footer — Standard Command Output Format
278
+
279
+ Every command report must end with this standard footer section.
280
+
281
+ ## Status Badge
282
+
283
+ Choose one based on outcome:
284
+ - `✅ Complete` — all steps succeeded, no issues found
285
+ - `❌ Failed` — command could not complete due to a blocking error
286
+ - `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
287
+
288
+ ## Output Artifacts
289
+
290
+ List every file created or modified by this command:
291
+ ```
292
+ Output Artifacts:
293
+ {created|updated} {file-path} ({brief description})
294
+ {created|updated} {file-path} ({brief description})
295
+ ```
296
+
297
+ If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
298
+
299
+ ## Next Command Suggestion
300
+
301
+ Suggest the logical next command based on workflow phase:
302
+
303
+ | Current command | Suggest next |
304
+ |-------------------------|-----------------------------------------------|
305
+ | /define-product | `/generate-prd {product-definition-file}` |
306
+ | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
307
+ | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
308
+ | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
309
+ | /generate-bdd | `/review-context {feature-file}` to verify coverage |
310
+ | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
311
+ | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
312
+ | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
313
+ | /generate-code | `/generate-tests {UC-ID}` |
314
+ | /generate-tests | `/run-tests {UC-ID}` |
315
+ | /run-tests (passing) | `/review-code {UC-ID}` |
316
+ | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
317
+ | /review-code | `/smoke-test {UC-ID}` or create PR |
318
+ | /smoke-test | Create PR and link to ticket |
319
+ | /validate-traces | `/generate-code {UC-ID}` for gaps |
320
+ | /fix-bug | Create PR and link to ticket |
321
+ | /debug | `/fix-bug {ticket-id}` if fix needed |
322
+
323
+ Format the footer as:
324
+ ```
325
+ ---
326
+ Status : {badge}
327
+ {Output Artifacts block}
328
+ Next : {suggested command with example arguments}
329
+ ```
330
+
331
+
332
+ ```
333
+ /run-tests Report — {service}
334
+ ✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K} | Duration: {X}s
335
+
336
+ ## Failed Tests
337
+ | Test | Error | Root Cause |
338
+ |------|-------|-----------|
339
+
340
+ ## Recommendations
341
+ {specific fix per failure}
342
+ Next: /fix-bug if real bug, or correct test if wrong expectation.
343
+ ```
@@ -0,0 +1,46 @@
1
+ # /run-tests — Run Tests & Report Results
2
+
3
+ ## Gate
4
+ {{include:steps/gate.md}}
5
+
6
+ *Note: For this command, the target in Step 1 is a UC-ID or service name from `$ARGUMENTS`. Context loading provides `conventions.test_command`.*
7
+
8
+ ## Context
9
+ {{include:steps/context-loader.md}}
10
+
11
+ ---
12
+
13
+ ## Run
14
+ ```bash
15
+ {conventions.test_command} # all tests in module
16
+ {conventions.test_command} --class {ClassName} # specific class (faster)
17
+ {conventions.test_command} --pattern "*{Resource}*" # by pattern
18
+ ```
19
+
20
+ ## Analyze Failures
21
+
22
+ | Error Pattern | Common Cause | Suggested Fix |
23
+ |---|---|---|
24
+ | NullPointerException | Missing mock setup | Check `given(...)` for null dependency |
25
+ | Bean not found | Missing mock declaration | Add mock for missing dependency |
26
+ | Expected 200, got 403 | Missing auth setup | Add auth user/role to test context |
27
+ | Expected 200, got 400 | Request body fails validation | Check required fields in DTO |
28
+ | LazyInitializationException | Lazy collection outside transaction | Add `@Transactional` or eager fetch |
29
+ | Mapper not found | Code generator not run | Run compile step before tests |
30
+
31
+ ## Output
32
+
33
+ {{include:steps/report-footer.md}}
34
+
35
+ ```
36
+ /run-tests Report — {service}
37
+ ✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K} | Duration: {X}s
38
+
39
+ ## Failed Tests
40
+ | Test | Error | Root Cause |
41
+ |------|-------|-----------|
42
+
43
+ ## Recommendations
44
+ {specific fix per failure}
45
+ Next: /fix-bug if real bug, or correct test if wrong expectation.
46
+ ```