@anhth2/spec-driven-dev-plugin 0.8.0 → 0.9.1

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 (93) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/commands/debug.md +152 -0
  3. package/commands/debug.tmpl +16 -0
  4. package/commands/define-product.md +57 -0
  5. package/commands/fix-bug.md +153 -0
  6. package/commands/fix-bug.tmpl +17 -0
  7. package/commands/generate-bdd.md +277 -13
  8. package/commands/generate-bdd.tmpl +220 -13
  9. package/commands/generate-code.md +154 -2
  10. package/commands/generate-code.tmpl +97 -2
  11. package/commands/generate-design-spec.md +57 -0
  12. package/commands/generate-prd.md +114 -20
  13. package/commands/generate-prd.tmpl +57 -20
  14. package/commands/generate-spec-manifest.md +57 -0
  15. package/commands/generate-tech-docs.md +79 -1
  16. package/commands/generate-tech-docs.tmpl +22 -1
  17. package/commands/generate-tests.md +57 -0
  18. package/commands/learn.md +554 -0
  19. package/commands/learn.tmpl +63 -0
  20. package/commands/propose-scenario.md +521 -0
  21. package/commands/propose-scenario.tmpl +109 -0
  22. package/commands/refine-prd.md +66 -1
  23. package/commands/refine-prd.tmpl +9 -1
  24. package/commands/report-bug.md +543 -0
  25. package/commands/report-bug.tmpl +131 -0
  26. package/commands/review-code.md +153 -0
  27. package/commands/review-code.tmpl +17 -0
  28. package/commands/review-context.md +65 -0
  29. package/commands/review-context.tmpl +8 -0
  30. package/commands/review-tech-docs.md +146 -4
  31. package/commands/review-tech-docs.tmpl +89 -4
  32. package/commands/run-tests.md +82 -0
  33. package/commands/run-tests.tmpl +25 -0
  34. package/commands/setup-ai-first.md +15 -5
  35. package/commands/setup-ai-first.tmpl +10 -5
  36. package/commands/smoke-test.md +57 -0
  37. package/commands/sync.md +405 -0
  38. package/commands/sync.tmpl +345 -0
  39. package/commands/update-framework.md +211 -0
  40. package/commands/update-framework.tmpl +151 -0
  41. package/commands/validate-traces.md +115 -2
  42. package/commands/validate-traces.tmpl +58 -2
  43. package/core/FRAMEWORK_VERSION +1 -1
  44. package/core/commands/debug.md +152 -0
  45. package/core/commands/define-product.md +57 -0
  46. package/core/commands/fix-bug.md +153 -0
  47. package/core/commands/generate-bdd.md +277 -13
  48. package/core/commands/generate-code.md +154 -2
  49. package/core/commands/generate-design-spec.md +57 -0
  50. package/core/commands/generate-prd.md +114 -20
  51. package/core/commands/generate-spec-manifest.md +57 -0
  52. package/core/commands/generate-tech-docs.md +79 -1
  53. package/core/commands/generate-tests.md +57 -0
  54. package/core/commands/learn.md +554 -0
  55. package/core/commands/propose-scenario.md +521 -0
  56. package/core/commands/refine-prd.md +66 -1
  57. package/core/commands/report-bug.md +543 -0
  58. package/core/commands/review-code.md +153 -0
  59. package/core/commands/review-context.md +65 -0
  60. package/core/commands/review-tech-docs.md +146 -4
  61. package/core/commands/run-tests.md +82 -0
  62. package/core/commands/setup-ai-first.md +15 -5
  63. package/core/commands/smoke-test.md +57 -0
  64. package/core/commands/sync.md +405 -0
  65. package/core/commands/update-framework.md +211 -0
  66. package/core/commands/validate-traces.md +115 -2
  67. package/core/skills/code/SKILL.md +62 -0
  68. package/core/skills/debug/SKILL.md +67 -0
  69. package/core/skills/design-spec/SKILL.md +57 -0
  70. package/core/skills/discovery/SKILL.md +57 -0
  71. package/core/skills/prd/SKILL.md +10 -0
  72. package/core/skills/setup-ai-first/SKILL.md +5 -0
  73. package/core/skills/spec/SKILL.md +10 -0
  74. package/core/skills/test/SKILL.md +119 -0
  75. package/core/steps/capture-lesson.md +79 -0
  76. package/core/steps/context-loader.md +52 -0
  77. package/core/steps/report-footer.md +5 -0
  78. package/core/templates/prd.template.md +35 -20
  79. package/core/templates/project-context.yaml +11 -0
  80. package/package.json +9 -2
  81. package/skills/code/SKILL.md +62 -0
  82. package/skills/debug/SKILL.md +67 -0
  83. package/skills/design-spec/SKILL.md +57 -0
  84. package/skills/discovery/SKILL.md +57 -0
  85. package/skills/prd/SKILL.md +10 -0
  86. package/skills/setup-ai-first/SKILL.md +5 -0
  87. package/skills/spec/SKILL.md +10 -0
  88. package/skills/test/SKILL.md +119 -0
  89. package/steps/capture-lesson.md +79 -0
  90. package/steps/context-loader.md +52 -0
  91. package/steps/report-footer.md +5 -0
  92. package/templates/prd.template.md +35 -20
  93. package/templates/project-context.yaml +11 -0
@@ -0,0 +1,79 @@
1
+ # Capture Lesson — Record a Recurring Mistake as a Guardrail
2
+
3
+ Reusable procedure to persist a "lesson" so the AI does not repeat a mistake in this project.
4
+ Used by `/learn` (manual) and offered by `/review-code`, `/fix-bug`, `/debug` (auto).
5
+
6
+ > **Project memory, not model training.** A lesson is plain text injected into context at the
7
+ > start of every command (context-loader Step 6.7). Functionally this stops the repeat — the AI
8
+ > sees the guardrail before it generates. No model weights change.
9
+
10
+ ## L1 — Resolve the lessons file
11
+
12
+ Resolve `lessons_path` in this order:
13
+ 1. `paths.lessons_file` from loaded context (may be service-overridden in umbrella mode, Step 1.6)
14
+ 2. Default `specs/domain-knowledge/lessons-learned.md` (single-service)
15
+ 3. In umbrella/service mode (when `service_root` is set) default `{service_root}/.agent/project-lessons.md`
16
+
17
+ ## L2 — Build the lesson
18
+
19
+ Gather these fields — from `$ARGUMENTS` (for `/learn`) or from the calling command's findings
20
+ (for `/review-code`, `/fix-bug`, `/debug`):
21
+
22
+ | Field | Meaning |
23
+ |-------|---------|
24
+ | `category` | one of: `code-gen` \| `bdd` \| `tech-docs` \| `tests` \| `prd` \| `general` |
25
+ | `title` | short phrase naming the mistake |
26
+ | `mistake` | concretely, what the AI did wrong |
27
+ | `rule` | imperative correction — "Always …" / "Never …" — testable, not vague |
28
+ | `scope` | where it applies: a domain, a file glob (e.g. `*Controller.*`), or `all` |
29
+ | `source` | how captured: `/learn` \| `/review-code {UC-ID}` \| `/fix-bug {TICKET}` \| `/debug` |
30
+
31
+ If `rule` is vague (e.g. "be careful"), rewrite it into a concrete, checkable instruction before saving.
32
+
33
+ ## L3 — De-duplicate
34
+
35
+ Read existing lessons in `lessons_path`. If one already covers the same mistake:
36
+ - **Refine** that entry (tighten the Rule, widen/narrow Scope, bump Date, append the new Source) — do NOT add a duplicate.
37
+
38
+ Otherwise assign the next id `L-{NNN}` = (highest existing number + 1), zero-padded to 3 digits.
39
+
40
+ ## L4 — Write
41
+
42
+ If `lessons_path` does not exist, create it with this header first:
43
+
44
+ ```markdown
45
+ # Project Lessons — Learned Guardrails
46
+
47
+ > Mistakes the AI must NOT repeat in this project. Loaded by context-loader at the start of
48
+ > every command and treated as hard constraints (same priority as CLAUDE.md coding standards).
49
+ > Add with /learn, or accept the prompt during /review-code, /fix-bug, /debug.
50
+ > Commit this file so the whole team shares the guardrails.
51
+
52
+ | Category | Applies to |
53
+ |----------|-----------|
54
+ | code-gen | /generate-code output |
55
+ | bdd | /generate-bdd output |
56
+ | tech-docs | /generate-tech-docs output |
57
+ | tests | /generate-tests output |
58
+ | prd | /generate-prd, /refine-prd output |
59
+ | general | every command |
60
+
61
+ ---
62
+ ```
63
+
64
+ Insert the new lesson directly under the `---` separator (**newest first**), in this exact shape:
65
+
66
+ ```markdown
67
+ ### L-{NNN} — [{category}] {title}
68
+ - **Date**: {today YYYY-MM-DD}
69
+ - **Scope**: {scope}
70
+ - **Mistake**: {mistake}
71
+ - **Rule**: {rule}
72
+ - **Source**: {source}
73
+
74
+ ```
75
+
76
+ ## L5 — Confirm
77
+
78
+ Print: `📝 Lesson {id} recorded → {lessons_path} ([{category}] {title})`
79
+ Then remind: `Commit {lessons_path} so the team shares this guardrail.`
@@ -89,6 +89,37 @@ If `services` section is present:
89
89
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
90
90
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
91
91
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
92
+ - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
93
+ - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
94
+
95
+ > **Why under `spec_source`:** tester feedback (`/report-bug`, `/propose-scenario`) must land in the **shared spec repo** so PO/Dev see it when they `/sync`. In single-service mode (no `spec_source`), these default to `feedback/bug-reports` and `feedback/bdd-proposals` at repo root — still shared, same repo.
96
+
97
+ ---
98
+
99
+ ## Step 1.6 — [SERVICE CONVENTIONS] Load service-specific conventions (umbrella mode)
100
+
101
+ *Skip this step entirely if `active_service` is `"unresolved"` or context is single-service mode.*
102
+
103
+ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-service/`):
104
+
105
+ **1. Locate service config** — try in priority order:
106
+ - `{active_service}/.agent/project-context.yaml`
107
+ - `{active_service}/project-context.yaml`
108
+
109
+ **2. If found, override with service-specific values:**
110
+
111
+ | Variable | Source |
112
+ |----------|--------|
113
+ | `conventions.test_command` | service's `conventions.test_command` |
114
+ | `conventions.build_command` | service's `conventions.build_command` |
115
+ | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` — default: `{active_service}/.trace` |
116
+ | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
117
+
118
+ **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
119
+ - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
120
+ - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
121
+
122
+ **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
92
123
 
93
124
  ---
94
125
 
@@ -182,6 +213,25 @@ These two variables (`active_module`, `platform_type`) are the canonical source
182
213
 
183
214
  ---
184
215
 
216
+ ## Step 6.7 — [GUARDRAILS] Load Project Lessons (conditional)
217
+
218
+ *Accumulated mistakes the AI must not repeat in this project. These are added over time via `/learn`
219
+ or accepted during `/review-code`, `/fix-bug`, `/debug`.*
220
+
221
+ Resolve the lessons file path:
222
+ - Use `paths.lessons_file` if set (may be service-overridden in umbrella mode, Step 1.6)
223
+ - Else default `specs/domain-knowledge/lessons-learned.md`
224
+ - In umbrella/service mode (when `service_root` is set), if `paths.lessons_file` is unset, default to `{service_root}/.agent/project-lessons.md`
225
+
226
+ If the file exists, read it and store ALL lessons as **ACTIVE GUARDRAILS** for the session:
227
+ - Treat each lesson's **Rule** as a hard constraint — same priority as CLAUDE.md coding standards (Step 3).
228
+ - Before generating or modifying any artifact (PRD, BDD, tech-doc, code, test), check the output against every lesson whose `category` matches the current command AND whose `scope` matches the target (domain / file).
229
+ - If a generated output would violate a lesson → correct it **before** presenting, and note which lesson (`L-NNN`) was applied.
230
+
231
+ If the file does not exist → skip silently (no lessons captured yet).
232
+
233
+ ---
234
+
185
235
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
186
236
 
187
237
  After loading all context, synthesize and output a compact summary block.
@@ -197,7 +247,9 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
197
247
  Ticket : {ticket_prefix}-
198
248
  Dict : {loaded — N canonical terms, M banned terms | missing}
199
249
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
250
+ Lessons : {loaded — N guardrails | none yet}
200
251
  Service : {active_service} ({active_service_module}) | single-service
252
+ Svc Root : {service_root} — conventions + trace_dir loaded from service config | —
201
253
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
202
254
  ```
203
255
 
@@ -45,6 +45,11 @@ Suggest the logical next command based on workflow phase:
45
45
  | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
46
46
  | /fix-bug | Create PR and link to ticket |
47
47
  | /debug | `/fix-bug {ticket-id}` if fix needed |
48
+ | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
49
+ | /propose-scenario | Notify PO/Dev to review the proposal in `feedback/bdd-proposals/` |
50
+ | /learn | Continue working — lesson applies on next command |
51
+ | /sync | `/validate-traces` for full coverage; act on any `📥 tester feedback` surfaced |
52
+ | /update-framework | Review `git diff .agent/`, commit; `/sync` for project content |
48
53
 
49
54
  Format the footer as:
50
55
  ```
@@ -102,9 +102,9 @@
102
102
  - {Business value}→ Giá trị nghiệp vụ mang lại (lý do tại sao người dùng cần điều này)
103
103
  -->
104
104
 
105
- As a {User role}
106
- I want to {User goal}
107
- So that {Business value}
105
+ - **As a** {User role}
106
+ - **I want to** {User goal}
107
+ - **So that** {Business value}
108
108
 
109
109
  ## b. Phạm vi
110
110
 
@@ -119,7 +119,8 @@ So that {Business value}
119
119
  - Viết ngắn gọn, súc tích, đủ để người đọc hiểu mà không cần giải thích thêm.
120
120
  -->
121
121
 
122
- In Scope
122
+ **In Scope**
123
+
123
124
  - {Chức năng thuộc feature}
124
125
 
125
126
  ---
@@ -141,9 +142,9 @@ In Scope
141
142
  - Chi tiết kỹ thuật hoặc logic xử lý nội bộ → thuộc Business Rule / Business Logic.
142
143
  -->
143
144
 
144
- AC1: {Điều kiện chấp nhận}
145
- AC2: {Điều kiện chấp nhận}
146
- AC3: {Điều kiện chấp nhận}
145
+ - **AC1:** {Điều kiện chấp nhận}
146
+ - **AC2:** {Điều kiện chấp nhận}
147
+ - **AC3:** {Điều kiện chấp nhận}
147
148
 
148
149
  ---
149
150
 
@@ -183,15 +184,24 @@ AC3: {Điều kiện chấp nhận}
183
184
  -->
184
185
 
185
186
  #### {TICKET_ID}-UC1: {Tên Use Case}
186
- Actor: {Người dùng thực hiện}
187
- Description: {Mô tả ngắn gọn kịch bản nghiệp vụ}
188
- Pre-condition: {Điều kiện cần trước khi Use Case bắt đầu}
189
- Post-condition: {Kết quả sau khi Use Case hoàn thành}
190
187
 
191
- Business Rule
192
- | ID | Business Rule | Business Logic |
193
- |----|---------------|----------------|
194
- | {TICKET_ID}-UC1-BR1 | | - Logic 1<br/>- Logic 2<br/>- Logic 3 |
188
+ - **Actor:** {Người dùng thực hiện}
189
+ - **Description:** {Mô tả ngắn gọn kịch bản nghiệp vụ}
190
+ - **Pre-condition:** {Điều kiện cần trước khi Use Case bắt đầu}
191
+ - **Post-condition:** {Kết quả sau khi Use Case hoàn thành}
192
+
193
+ **Business Rule**
194
+
195
+ | ID | Business Rule |
196
+ |----|---------------|
197
+ | {TICKET_ID}-UC1-BR1 | |
198
+
199
+ **Business Logic**
200
+
201
+ **{TICKET_ID}-UC1-BR1:**
202
+ - Logic 1
203
+ - Logic 2
204
+ - Logic 3
195
205
 
196
206
  ---
197
207
 
@@ -246,11 +256,16 @@ flowchart TD
246
256
 
247
257
  **Screen N: {Tên màn hình}**
248
258
 
249
- | Thành phần | Chi tiết |
250
- | -------------- | -------- |
251
- | **Screen** | {Tên màn hình} |
252
- | **Components** | - {Component 1} <br>- {Component 2} <br>- {Component 3} |
253
- | **Actions** | - {Hành động 1} → {Kết quả} <br>- {Hành động 2} → {Kết quả} |
259
+ **Screen:** {Tên màn hình}
260
+
261
+ **Components:**
262
+ - {Component 1}
263
+ - {Component 2}
264
+ - {Component 3}
265
+
266
+ **Actions:**
267
+ - {Hành động 1} → {Kết quả}
268
+ - {Hành động 2} → {Kết quả}
254
269
 
255
270
  <!-- Figma Design: {Link Figma — xóa dòng này nếu không có URL} -->
256
271
 
@@ -45,6 +45,11 @@ paths:
45
45
  business_dictionary: "specs/domain-knowledge/business-dictionary.md"
46
46
  core_entities: "specs/domain-knowledge/core-entities.md"
47
47
 
48
+ # Project Lessons (guardrails accumulated via /learn — loaded by context-loader Step 6.7)
49
+ # Single-service default below. In umbrella/service mode, set this in each service's
50
+ # .agent/project-context.yaml to ".agent/project-lessons.md" (resolved per service_root).
51
+ lessons_file: "specs/domain-knowledge/lessons-learned.md"
52
+
48
53
  # Tech Docs
49
54
  tech_docs_dir: "tech-docs"
50
55
 
@@ -54,6 +59,12 @@ paths:
54
59
  # Trace
55
60
  trace_dir: ".trace"
56
61
 
62
+ # Tester feedback (written by /report-bug and /propose-scenario).
63
+ # These live in the SHARED spec repo so PO/Dev see them on their next /sync.
64
+ # In umbrella mode, context-loader auto-resolves them under {spec_source}/feedback/.
65
+ bug_reports_dir: "feedback/bug-reports"
66
+ bdd_proposals_dir: "feedback/bdd-proposals"
67
+
57
68
  tech_stack:
58
69
  language: "{{LANGUAGE}}" # e.g., Java 17 / TypeScript / C# / Go
59
70
  framework: "{{FRAMEWORK}}" # e.g., Spring Boot 3.2 / Angular 17 / .NET 8