@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.
- package/ARCHITECTURE.md +243 -0
- package/bin/build.js +230 -0
- package/bin/index.js +311 -0
- package/commands/debug.md +374 -0
- package/commands/debug.tmpl +77 -0
- package/commands/define-product.md +451 -0
- package/commands/define-product.tmpl +154 -0
- package/commands/fix-bug.md +379 -0
- package/commands/fix-bug.tmpl +82 -0
- package/commands/generate-bdd.md +591 -0
- package/commands/generate-bdd.tmpl +294 -0
- package/commands/generate-code.md +395 -0
- package/commands/generate-code.tmpl +98 -0
- package/commands/generate-prd.md +488 -0
- package/commands/generate-prd.tmpl +191 -0
- package/commands/generate-tech-docs.md +362 -0
- package/commands/generate-tech-docs.tmpl +65 -0
- package/commands/generate-tests.md +377 -0
- package/commands/generate-tests.tmpl +80 -0
- package/commands/refine-prd.md +408 -0
- package/commands/refine-prd.tmpl +111 -0
- package/commands/review-code.md +354 -0
- package/commands/review-code.tmpl +57 -0
- package/commands/review-context.md +646 -0
- package/commands/review-context.tmpl +349 -0
- package/commands/review-tech-docs.md +518 -0
- package/commands/review-tech-docs.tmpl +221 -0
- package/commands/run-tests.md +343 -0
- package/commands/run-tests.tmpl +46 -0
- package/commands/setup-ai-first.md +278 -0
- package/commands/setup-ai-first.tmpl +197 -0
- package/commands/smoke-test.md +366 -0
- package/commands/smoke-test.tmpl +69 -0
- package/commands/validate-traces.md +529 -0
- package/commands/validate-traces.tmpl +232 -0
- package/core/FRAMEWORK_VERSION +1 -0
- package/core/commands/debug.md +374 -0
- package/core/commands/define-product.md +451 -0
- package/core/commands/fix-bug.md +379 -0
- package/core/commands/generate-bdd.md +591 -0
- package/core/commands/generate-code.md +395 -0
- package/core/commands/generate-prd.md +488 -0
- package/core/commands/generate-tech-docs.md +362 -0
- package/core/commands/generate-tests.md +377 -0
- package/core/commands/refine-prd.md +408 -0
- package/core/commands/review-code.md +354 -0
- package/core/commands/review-context.md +646 -0
- package/core/commands/review-tech-docs.md +518 -0
- package/core/commands/run-tests.md +343 -0
- package/core/commands/setup-ai-first.md +278 -0
- package/core/commands/smoke-test.md +366 -0
- package/core/commands/validate-traces.md +529 -0
- package/core/hooks/data-guard.js +141 -0
- package/core/hooks/settings.json +18 -0
- package/core/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/core/modules/angular/module.yaml +6 -0
- package/core/modules/angular/stack-profile.yaml +38 -0
- package/core/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/core/modules/context-engineering/module.yaml +9 -0
- package/core/modules/context-engineering/stack-profile.yaml +61 -0
- package/core/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/core/modules/dotnet/module.yaml +6 -0
- package/core/modules/dotnet/stack-profile.yaml +50 -0
- package/core/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/core/modules/golang/module.yaml +6 -0
- package/core/modules/golang/stack-profile.yaml +40 -0
- package/core/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/core/modules/java-spring/module.yaml +15 -0
- package/core/modules/java-spring/stack-profile.yaml +28 -0
- package/core/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/core/modules/nextjs/module.yaml +14 -0
- package/core/modules/nextjs/stack-profile.yaml +74 -0
- package/core/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/core/modules/php-laravel/module.yaml +15 -0
- package/core/modules/php-laravel/stack-profile.yaml +56 -0
- package/core/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/core/modules/react/module.yaml +14 -0
- package/core/modules/react/stack-profile.yaml +63 -0
- package/core/rules/data-protection.md +80 -0
- package/core/rules/workflow.md +44 -0
- package/core/skills/code/SKILL.md +526 -0
- package/core/skills/debug/SKILL.md +584 -0
- package/core/skills/discovery/SKILL.md +363 -0
- package/core/skills/prd/SKILL.md +456 -0
- package/core/skills/setup-ai-first/SKILL.md +160 -0
- package/core/skills/spec/SKILL.md +361 -0
- package/core/skills/test/SKILL.md +862 -0
- package/core/steps/context-loader.md +163 -0
- package/core/steps/gate.md +81 -0
- package/core/steps/report-footer.md +53 -0
- package/core/steps/spawn-agent.md +123 -0
- package/core/templates/architecture.template.md +113 -0
- package/core/templates/feature.template +259 -0
- package/core/templates/platform-guide.template.md +145 -0
- package/core/templates/prd.template.md +312 -0
- package/core/templates/product-definition.template.md +168 -0
- package/core/templates/project-context.yaml +78 -0
- package/hooks/data-guard.js +141 -0
- package/hooks/settings.json +18 -0
- package/modules/angular/architecture-snippets/component-patterns.md +187 -0
- package/modules/angular/module.yaml +6 -0
- package/modules/angular/stack-profile.yaml +38 -0
- package/modules/context-engineering/architecture-snippets/context-design.md +119 -0
- package/modules/context-engineering/module.yaml +9 -0
- package/modules/context-engineering/stack-profile.yaml +61 -0
- package/modules/dotnet/architecture-snippets/clean-arch.md +160 -0
- package/modules/dotnet/module.yaml +6 -0
- package/modules/dotnet/stack-profile.yaml +50 -0
- package/modules/golang/architecture-snippets/domain-layout.md +283 -0
- package/modules/golang/module.yaml +6 -0
- package/modules/golang/stack-profile.yaml +40 -0
- package/modules/java-spring/architecture-snippets/layered-arch.md +201 -0
- package/modules/java-spring/module.yaml +15 -0
- package/modules/java-spring/stack-profile.yaml +28 -0
- package/modules/nextjs/architecture-snippets/app-router-patterns.md +269 -0
- package/modules/nextjs/module.yaml +14 -0
- package/modules/nextjs/stack-profile.yaml +74 -0
- package/modules/php-laravel/architecture-snippets/service-repository.md +302 -0
- package/modules/php-laravel/module.yaml +15 -0
- package/modules/php-laravel/stack-profile.yaml +56 -0
- package/modules/react/architecture-snippets/hooks-query-patterns.md +254 -0
- package/modules/react/module.yaml +14 -0
- package/modules/react/stack-profile.yaml +63 -0
- package/package.json +42 -0
- package/rules/data-protection.md +80 -0
- package/rules/workflow.md +44 -0
- package/scripts/init.sh +49 -0
- package/scripts/upgrade.sh +94 -0
- package/skills/code/SKILL.md +526 -0
- package/skills/code/SKILL.tmpl +176 -0
- package/skills/debug/SKILL.md +584 -0
- package/skills/debug/SKILL.tmpl +262 -0
- package/skills/discovery/SKILL.md +363 -0
- package/skills/discovery/SKILL.tmpl +147 -0
- package/skills/prd/SKILL.md +456 -0
- package/skills/prd/SKILL.tmpl +188 -0
- package/skills/setup-ai-first/SKILL.md +160 -0
- package/skills/setup-ai-first/SKILL.tmpl +107 -0
- package/skills/spec/SKILL.md +361 -0
- package/skills/spec/SKILL.tmpl +174 -0
- package/skills/test/SKILL.md +862 -0
- package/skills/test/SKILL.tmpl +296 -0
- package/steps/context-loader.md +163 -0
- package/steps/gate.md +81 -0
- package/steps/report-footer.md +53 -0
- package/steps/spawn-agent.md +123 -0
- package/templates/architecture.template.md +113 -0
- package/templates/feature.template +259 -0
- package/templates/platform-guide.template.md +145 -0
- package/templates/prd.template.md +312 -0
- package/templates/product-definition.template.md +168 -0
- package/templates/project-context.yaml +78 -0
|
@@ -0,0 +1,296 @@
|
|
|
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
|
+
{{include:steps/gate.md}}
|
|
17
|
+
|
|
18
|
+
Also read:
|
|
19
|
+
- `.feature` file to understand expected behaviors
|
|
20
|
+
- Find files to test: Controllers with `@trace.implements={UC-ID}`, Service implementations, Facade implementations (if applicable)
|
|
21
|
+
|
|
22
|
+
### CHECKPOINT — Test Plan
|
|
23
|
+
|
|
24
|
+
Before generating, present plan:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Test Plan — {UC-ID}:
|
|
28
|
+
|
|
29
|
+
Unit Tests ({unit test framework}):
|
|
30
|
+
- {ServiceName}ServiceImplTest
|
|
31
|
+
• {method}: {scenario} → {expected result}
|
|
32
|
+
- {FacadeName}FacadeImplTest (if applicable)
|
|
33
|
+
• {method}: {scenario} → {expected result}
|
|
34
|
+
|
|
35
|
+
Integration Tests:
|
|
36
|
+
- {ControllerName}ControllerTest
|
|
37
|
+
• {endpoint}: {scenario} → HTTP {status}
|
|
38
|
+
|
|
39
|
+
Total: {N} test classes, ~{M} test cases
|
|
40
|
+
Proceed? (Y/N)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Wait for confirmation.
|
|
44
|
+
|
|
45
|
+
### Generate
|
|
46
|
+
|
|
47
|
+
#### Unit Test Template
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
// @trace.verifies={UC-ID}
|
|
51
|
+
// @trace.test_type=unit
|
|
52
|
+
[Test class using your project's test framework]
|
|
53
|
+
|
|
54
|
+
class {Resource}ServiceImplTest {
|
|
55
|
+
|
|
56
|
+
// Mock dependencies
|
|
57
|
+
|
|
58
|
+
@Test
|
|
59
|
+
// "Should {expected outcome} when {condition}"
|
|
60
|
+
void methodName_whenValid_shouldReturnExpected() {
|
|
61
|
+
// Given — set up mocks and inputs
|
|
62
|
+
// When — call the method under test
|
|
63
|
+
// Then — assert results and verify interactions
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Test
|
|
67
|
+
// "Should throw {Exception} when {resource} not found"
|
|
68
|
+
void methodName_whenNotFound_shouldThrowException() {
|
|
69
|
+
// Given — mock returns empty/null
|
|
70
|
+
// When & Then — assert exception is thrown
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Integration Test Template (Controller/HTTP layer)
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
// @trace.verifies={UC-ID}
|
|
79
|
+
// @trace.test_type=integration
|
|
80
|
+
[Integration test class for HTTP layer]
|
|
81
|
+
|
|
82
|
+
class {Resource}ControllerTest {
|
|
83
|
+
|
|
84
|
+
// Inject MockMvc or HTTP test client
|
|
85
|
+
// MockBean/stub the Facade/Service
|
|
86
|
+
|
|
87
|
+
@Test
|
|
88
|
+
// "GET /v1/{resource} - should return 200 with data"
|
|
89
|
+
void filter_shouldReturn200() {
|
|
90
|
+
// Given — stub facade/service
|
|
91
|
+
// When — perform HTTP GET
|
|
92
|
+
// Then — assert status 200 and response body
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Test
|
|
96
|
+
// "POST /v1/{resource} - should return 201 when valid"
|
|
97
|
+
void create_shouldReturn201() {
|
|
98
|
+
// Given — stub facade/service
|
|
99
|
+
// When — perform HTTP POST with valid body
|
|
100
|
+
// Then — assert status 201
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Test
|
|
104
|
+
// "POST /v1/{resource} - should return 400 when invalid"
|
|
105
|
+
void create_shouldReturn400WhenInvalid() {
|
|
106
|
+
// Given — no stub needed
|
|
107
|
+
// When — perform HTTP POST with missing required fields
|
|
108
|
+
// Then — assert status 400
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### File Placement
|
|
114
|
+
|
|
115
|
+
Follow project test structure from CLAUDE.md. Typical:
|
|
116
|
+
```
|
|
117
|
+
src/test/{language}/{package}/
|
|
118
|
+
├── service/impl/{Resource}ServiceImplTest.{ext}
|
|
119
|
+
├── facade/impl/{Resource}FacadeImplTest.{ext} (if applicable)
|
|
120
|
+
└── controller/{Resource}ControllerTest.{ext}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Self-Review Checklist
|
|
124
|
+
|
|
125
|
+
- [ ] `@trace.verifies` tag on every test class
|
|
126
|
+
- [ ] Every scenario in .feature has at least one test
|
|
127
|
+
- [ ] Mock only the correct layer (no repo mocks in controller tests)
|
|
128
|
+
- [ ] Test names follow `methodName_whenCondition_shouldOutcome` pattern
|
|
129
|
+
- [ ] No debug print statements in tests
|
|
130
|
+
|
|
131
|
+
### Output
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
/generate-tests Complete — {UC-ID}:
|
|
135
|
+
✅ service/{Service}Test.{ext} ({M} tests)
|
|
136
|
+
✅ facade/{Facade}Test.{ext} ({M} tests)
|
|
137
|
+
✅ controller/{Controller}Test.{ext} ({M} tests)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
{{include:steps/report-footer.md}}
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## /run-tests — Run Tests & Report Results
|
|
145
|
+
|
|
146
|
+
### Gate
|
|
147
|
+
|
|
148
|
+
{{include:steps/context-loader.md}}
|
|
149
|
+
|
|
150
|
+
Identify service/module from argument (UC-ID or service name).
|
|
151
|
+
Read `conventions.test_command` from the loaded project context.
|
|
152
|
+
|
|
153
|
+
### Run
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Run all tests in module
|
|
157
|
+
{TEST_COMMAND}
|
|
158
|
+
|
|
159
|
+
# Run specific test class (faster)
|
|
160
|
+
{TEST_COMMAND_FOR_CLASS}
|
|
161
|
+
|
|
162
|
+
# Run by pattern
|
|
163
|
+
{TEST_COMMAND_BY_PATTERN}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Analyze Results
|
|
167
|
+
|
|
168
|
+
#### When tests PASS
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
✅ Tests passed
|
|
172
|
+
- Total: {N}
|
|
173
|
+
- Passed: {N}
|
|
174
|
+
- Duration: {X}s
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### When tests FAIL — Debug Mode
|
|
178
|
+
|
|
179
|
+
Read stack trace and analyze:
|
|
180
|
+
|
|
181
|
+
| Error Pattern | Common Cause | Suggested Fix |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| NullPointerException in test | Missing mock setup | Check `given(...)` setup for null dependency |
|
|
184
|
+
| Bean/dependency not found | Missing mock/stub declaration | Add mock for missing dependency |
|
|
185
|
+
| Expected 200 but got 403 | Missing auth setup in test | Add auth user/role to test context |
|
|
186
|
+
| Expected 200 but got 400 | Request body fails validation | Check required fields in request DTO |
|
|
187
|
+
| LazyInitializationException | Lazy collection accessed outside transaction | Add `@Transactional` on test or use eager fetch |
|
|
188
|
+
| Mapper/mapper implementation not found | Code generator (e.g. MapStruct) not run | Run compile step before tests |
|
|
189
|
+
|
|
190
|
+
### Output
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
/run-tests Report — {service}
|
|
194
|
+
Run at: {datetime}
|
|
195
|
+
|
|
196
|
+
## Summary
|
|
197
|
+
✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K}
|
|
198
|
+
Duration: {X}s
|
|
199
|
+
|
|
200
|
+
## Failed Tests
|
|
201
|
+
| Test | Error | Root Cause |
|
|
202
|
+
|------|-------|-----------|
|
|
203
|
+
| {TestClass}.{method} | {exception} | {analysis} |
|
|
204
|
+
|
|
205
|
+
## Recommendations
|
|
206
|
+
{specific fix for each failure}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
{{include:steps/report-footer.md}}
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## /smoke-test — Test Live API Endpoints
|
|
214
|
+
|
|
215
|
+
Use when the service is **already running** to verify endpoints work correctly.
|
|
216
|
+
Different from `/run-tests` (which runs unit/integration tests without a live server).
|
|
217
|
+
|
|
218
|
+
### Phase 1 — Find Service URL
|
|
219
|
+
|
|
220
|
+
{{include:steps/context-loader.md}}
|
|
221
|
+
|
|
222
|
+
Read `conventions.service_run` from the loaded project context to find port.
|
|
223
|
+
Default: `http://localhost:8080`
|
|
224
|
+
|
|
225
|
+
Check if service is running:
|
|
226
|
+
```bash
|
|
227
|
+
curl -s http://localhost:{port}/health
|
|
228
|
+
# or /actuator/health for Spring Boot
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
If not running: "Service is not running. Start it with: `{RUN_COMMAND}` from your project root."
|
|
232
|
+
|
|
233
|
+
### Phase 2 — Identify Endpoints
|
|
234
|
+
|
|
235
|
+
From UC-ID → find Controller with `@trace.implements={UC-ID}`:
|
|
236
|
+
- List: method, path, required auth/role
|
|
237
|
+
|
|
238
|
+
### Phase 3 — Get Auth Token (if needed)
|
|
239
|
+
|
|
240
|
+
If endpoints require auth, ask:
|
|
241
|
+
```
|
|
242
|
+
This endpoint requires authentication. Options:
|
|
243
|
+
1. Paste your Bearer token (from Postman / browser DevTools / test login)
|
|
244
|
+
2. Use a test/dev token from your local config
|
|
245
|
+
3. Skip auth — only test public endpoints
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Phase 4 — Run Smoke Test
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# GET
|
|
252
|
+
curl -s -X GET "http://localhost:{port}/v1/{resource}?page=0&size=5" \
|
|
253
|
+
-H "Authorization: Bearer {token}" | {JSON_FORMATTER}
|
|
254
|
+
|
|
255
|
+
# POST
|
|
256
|
+
curl -s -X POST "http://localhost:{port}/v1/{resource}" \
|
|
257
|
+
-H "Authorization: Bearer {token}" \
|
|
258
|
+
-H "Content-Type: application/json" \
|
|
259
|
+
-d '{"field1": "test_value"}'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Phase 5 — Interpret Results
|
|
263
|
+
|
|
264
|
+
| Result | Meaning |
|
|
265
|
+
|--------|---------|
|
|
266
|
+
| 200/201 + correct data | ✅ OK |
|
|
267
|
+
| 200 + wrong data | ⚠️ Logic bug → use `/debug` |
|
|
268
|
+
| 400 | Request body wrong → check required fields |
|
|
269
|
+
| 401 | Token expired or wrong realm |
|
|
270
|
+
| 403 | Wrong role → check auth config |
|
|
271
|
+
| 500 + stacktrace | Server error → paste into `/debug` |
|
|
272
|
+
| Connection refused | Service not running or wrong port |
|
|
273
|
+
|
|
274
|
+
If errors in logs:
|
|
275
|
+
```bash
|
|
276
|
+
tail -n 100 {LOG_FILE_PATH}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Output
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
/smoke-test Report — {UC-ID}
|
|
283
|
+
Tested at: {datetime}
|
|
284
|
+
Base URL: http://localhost:{port}
|
|
285
|
+
|
|
286
|
+
## Endpoints Tested
|
|
287
|
+
| Method | Path | Status | Result |
|
|
288
|
+
|--------|------|--------|--------|
|
|
289
|
+
| GET | /v1/{resource} | 200 ✅ | 5 records returned |
|
|
290
|
+
| POST | /v1/{resource} | 201 ✅ | Created id=42 |
|
|
291
|
+
|
|
292
|
+
## Issues Found
|
|
293
|
+
{describe any failures}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
{{include:steps/report-footer.md}}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Context Loader — Load All Project Context
|
|
2
|
+
|
|
3
|
+
Execute these steps in order. Store everything in memory for the duration of the command session.
|
|
4
|
+
|
|
5
|
+
**Priority guide (anti-lost-in-middle):**
|
|
6
|
+
- Steps 1–2 are PROJECT-CONFIG — loaded first, resolve all paths and metadata.
|
|
7
|
+
- Step 3 is CRITICAL — architecture + coding standards, the highest-priority facts for generation.
|
|
8
|
+
- Step 4 is SAFETY — data protection rules, enforced silently for the entire session.
|
|
9
|
+
- Steps 5–6 are DOMAIN KNOWLEDGE — terminology and entity definitions.
|
|
10
|
+
- Step 7 is the WORKING MEMORY RECAP — locks critical facts into the top of working memory.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Step 1 — [PROJECT-CONFIG] Load project-context.yaml
|
|
15
|
+
|
|
16
|
+
Read `.agent/project-context.yaml`. Extract and store:
|
|
17
|
+
|
|
18
|
+
**Tech Stack:**
|
|
19
|
+
- `tech_stack.language` → active language (e.g., Java 17, TypeScript, C#, Go)
|
|
20
|
+
- `tech_stack.framework` → active framework (e.g., Spring Boot 3.2, Angular 17, .NET 8)
|
|
21
|
+
- `tech_stack.build_tool` → build tool (e.g., Maven, npm, dotnet, go)
|
|
22
|
+
- `tech_stack.test_framework` → test framework (e.g., JUnit 5 + Mockito, Jest, xUnit)
|
|
23
|
+
- `tech_stack.database` → database (e.g., PostgreSQL, MySQL, MongoDB)
|
|
24
|
+
- `tech_stack.module` → active module profile (e.g., java-spring, angular, dotnet, golang, context-engineering)
|
|
25
|
+
|
|
26
|
+
**Conventions:**
|
|
27
|
+
- `conventions.build_command` → how to compile/build
|
|
28
|
+
- `conventions.test_command` → how to run tests
|
|
29
|
+
- `conventions.service_run` → how to start the service
|
|
30
|
+
- `conventions.ticket_prefix` → ticket ID prefix (e.g., PROJ, FEAT, UC)
|
|
31
|
+
|
|
32
|
+
**Domains:**
|
|
33
|
+
- `domains` → list of active business domains
|
|
34
|
+
|
|
35
|
+
**Paths (if present):**
|
|
36
|
+
- `paths.specs_dir` → BDD specs root
|
|
37
|
+
- `paths.prd_dir` → PRD documents root
|
|
38
|
+
- `paths.refinement_dir` → findings/review output dir
|
|
39
|
+
- `paths.product_definitions_dir` → product definitions root
|
|
40
|
+
- `paths.domain_knowledge_dir` → domain knowledge root
|
|
41
|
+
- `paths.business_dictionary` → path to business-dictionary.md
|
|
42
|
+
- `paths.core_entities` → path to core-entities.md
|
|
43
|
+
- `paths.tech_docs_dir` → technical documentation root
|
|
44
|
+
- `paths.trace_dir` → trace state directory
|
|
45
|
+
|
|
46
|
+
If `paths` section is absent, use these defaults:
|
|
47
|
+
- `specs_dir` = `specs/bdd`
|
|
48
|
+
- `prd_dir` = `specs/prd`
|
|
49
|
+
- `refinement_dir` = `.agent/review`
|
|
50
|
+
- `product_definitions_dir` = `specs/product-definition`
|
|
51
|
+
- `domain_knowledge_dir` = `specs/domain-knowledge`
|
|
52
|
+
- `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
|
|
53
|
+
- `core_entities` = `specs/domain-knowledge/core-entities.md`
|
|
54
|
+
- `tech_docs_dir` = `tech-docs`
|
|
55
|
+
- `trace_dir` = `.trace`
|
|
56
|
+
|
|
57
|
+
If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
|
|
62
|
+
|
|
63
|
+
If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
|
|
64
|
+
Merge framework-specific conventions (layer patterns, test patterns, naming rules) into the loaded context.
|
|
65
|
+
If the file does not exist → skip silently.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Step 3 — [CRITICAL] Load CLAUDE.md
|
|
70
|
+
|
|
71
|
+
*This is the highest-priority context — it defines HOW to write code and documents for this project.*
|
|
72
|
+
|
|
73
|
+
Read `CLAUDE.md`. Extract and store:
|
|
74
|
+
|
|
75
|
+
- **§1 Project Overview** → project name, language, framework, build/test commands, domains
|
|
76
|
+
- **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
|
|
77
|
+
- **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
|
|
78
|
+
- **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
|
|
79
|
+
- **§7 Git Conventions** → branch naming pattern, commit message format
|
|
80
|
+
|
|
81
|
+
If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Step 4 — [SAFETY] Load Data Protection Rules
|
|
86
|
+
|
|
87
|
+
Read `.agent/rules/data-protection.md` (or `rules/data-protection.md` from the framework installation).
|
|
88
|
+
|
|
89
|
+
Store the sensitive file patterns — you must **never** read, write, display, or reference content from files matching those patterns for the entire session.
|
|
90
|
+
|
|
91
|
+
If neither file exists → apply built-in defaults: never access `.env*`, `*.key`, `*.pem`, `*secret*`, `*password*`, `*credential*`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Step 5 — [DOMAIN] Load Business Dictionary (conditional)
|
|
96
|
+
|
|
97
|
+
Check if the business dictionary file exists (use `paths.business_dictionary` resolved in Step 1).
|
|
98
|
+
|
|
99
|
+
If it exists, read it and extract:
|
|
100
|
+
- **Canonical Terms** → complete list of approved terms and their definitions
|
|
101
|
+
- **Banned Terms** → complete list of banned terms and their canonical replacements
|
|
102
|
+
- **Status / Enum Registry** → allowed enum values per entity
|
|
103
|
+
|
|
104
|
+
Store the banned terms list for **active enforcement** throughout the command session:
|
|
105
|
+
- When generating any text (PRD, BDD, code comments, tech docs), verify no banned terms appear
|
|
106
|
+
- Replace banned terms with their canonical equivalents automatically
|
|
107
|
+
|
|
108
|
+
If the file does not exist → skip silently. Do not warn or block.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Step 6 — [DOMAIN] Load Core Entities (conditional)
|
|
113
|
+
|
|
114
|
+
Check if the core entities file exists at `paths.core_entities` (resolved in Step 1).
|
|
115
|
+
Default path: `specs/domain-knowledge/core-entities.md`.
|
|
116
|
+
|
|
117
|
+
If it exists, read it and store:
|
|
118
|
+
- **Entity catalog** → for each entity: its name, purpose, owner service, key fields (name + type), business invariants, and relationships
|
|
119
|
+
- **Field name registry** → canonical field names to use in generated code and documents
|
|
120
|
+
- **Relationship map** → how entities relate to each other (1:N, N:N, embedded, etc.)
|
|
121
|
+
|
|
122
|
+
**How to use this catalog:**
|
|
123
|
+
- When generating code: use the field names, types, and relationships defined here — do NOT infer from existing code
|
|
124
|
+
- When generating PRD/BDD: reference entity names from this catalog for consistency
|
|
125
|
+
- When generating tech-docs: use this catalog as the source-of-truth for entity definitions
|
|
126
|
+
|
|
127
|
+
If the file does not exist → skip silently.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
|
|
132
|
+
|
|
133
|
+
After loading all context, synthesize and output a compact summary block.
|
|
134
|
+
This recap ensures the most critical facts are stated at the END of context loading
|
|
135
|
+
(recency effect — freshest in working memory when the task begins).
|
|
136
|
+
|
|
137
|
+
Output exactly this block:
|
|
138
|
+
```
|
|
139
|
+
[CTX LOADED]
|
|
140
|
+
Stack : {language} / {framework} / {database}
|
|
141
|
+
Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
|
|
142
|
+
Ticket : {ticket_prefix}-
|
|
143
|
+
Dict : {loaded — N canonical terms, M banned terms | missing}
|
|
144
|
+
Entities : {loaded — EntityA, EntityB, EntityC | missing}
|
|
145
|
+
Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If any CRITICAL file is missing (CLAUDE.md), flag it clearly so the user can decide whether to proceed.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Context Load Complete
|
|
153
|
+
|
|
154
|
+
After completing all steps, you have loaded:
|
|
155
|
+
- Project identity, tech stack, module conventions
|
|
156
|
+
- Architecture rules and layer order ← **[CRITICAL — hold in working memory]**
|
|
157
|
+
- Coding standards and naming conventions ← **[CRITICAL — hold in working memory]**
|
|
158
|
+
- Data protection rules (sensitive file patterns to never access)
|
|
159
|
+
- Terminology rules with banned-term list ← **[DOMAIN — apply to every generated word]**
|
|
160
|
+
- Entity catalog (field names, types, invariants) ← **[DOMAIN — use for code generation]**
|
|
161
|
+
- All configured paths
|
|
162
|
+
|
|
163
|
+
Proceed to the next step of the calling command.
|
package/steps/gate.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Gate — Universal Entry Procedure
|
|
2
|
+
|
|
3
|
+
Every command must execute this gate before proceeding with its specific logic.
|
|
4
|
+
|
|
5
|
+
## Step 0 — Sub-Agent Mode Check
|
|
6
|
+
|
|
7
|
+
Before anything else, check if `$ARGUMENTS` is a JSON payload from an orchestrator:
|
|
8
|
+
|
|
9
|
+
1. Attempt to parse `$ARGUMENTS` as JSON.
|
|
10
|
+
2. If it parses successfully **and** contains `"_agent_mode": true`:
|
|
11
|
+
- **Skip Steps 1, 2, and 3 of this Gate entirely.**
|
|
12
|
+
- Set target file = `payload.target_file`
|
|
13
|
+
- Set loaded context = `payload.context` (do NOT run context-loader.md)
|
|
14
|
+
- Set UC scope = `payload.uc_id` (process only this UC)
|
|
15
|
+
- Set line range = `payload.uc_section` (read only that PRD section)
|
|
16
|
+
- Proceed directly to the command-specific logic.
|
|
17
|
+
3. If `$ARGUMENTS` is not JSON or `_agent_mode` is absent → continue to Step 1 (normal mode).
|
|
18
|
+
|
|
19
|
+
## Step 0-B — Model Check
|
|
20
|
+
|
|
21
|
+
*Skip this step if `_agent_mode: true` (sub-agent — orchestrator already validated).*
|
|
22
|
+
|
|
23
|
+
Complex generation and review commands require strong reasoning.
|
|
24
|
+
Using a smaller model risks missed edge cases, incomplete spec analysis, and architecture violations.
|
|
25
|
+
|
|
26
|
+
Display and wait for response:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
⚙️ MODEL CHECK
|
|
30
|
+
──────────────────────────────────────────────────────────────────
|
|
31
|
+
Recommended : claude-opus-4-5 (or claude-opus-4)
|
|
32
|
+
Why needed : Spec analysis, architecture review, code generation
|
|
33
|
+
require deep reasoning. Smaller models miss edge cases.
|
|
34
|
+
|
|
35
|
+
To switch in Claude Code:
|
|
36
|
+
• Settings → Model → select "claude-opus"
|
|
37
|
+
• or: /model → choose claude-opus
|
|
38
|
+
|
|
39
|
+
Running on claude-opus?
|
|
40
|
+
Y — yes, on claude-opus → proceed
|
|
41
|
+
S — skip check (I accept lower quality risk with current model)
|
|
42
|
+
──────────────────────────────────────────────────────────────────
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- "Y" → proceed to Step 1.
|
|
46
|
+
- "S" → proceed to Step 1 (user accepts risk, add ⚠️ to final report).
|
|
47
|
+
- "N" or anything else → **STOP.** Output: "Please switch to claude-opus, then re-run this command."
|
|
48
|
+
|
|
49
|
+
## Step 1 — Resolve Target File
|
|
50
|
+
|
|
51
|
+
1. If `$ARGUMENTS` is provided and points to an existing file → use it directly as the target.
|
|
52
|
+
2. If `$ARGUMENTS` is a UC-ID, ticket ID, or partial name → search for matching files in the relevant directory.
|
|
53
|
+
3. If `$ARGUMENTS` is empty or no match found:
|
|
54
|
+
- List files in the relevant directory for this command (e.g., `specs/prd/**/*.md` for PRD commands, `specs/bdd/**/*.feature` for BDD commands).
|
|
55
|
+
- Present the list to the user and ask: "Which file do you want to work with? (Enter number or filename)"
|
|
56
|
+
- Wait for user selection before continuing.
|
|
57
|
+
|
|
58
|
+
## Step 2 — Execute Context Loader
|
|
59
|
+
|
|
60
|
+
Load all project context by following the procedure in `steps/context-loader.md`.
|
|
61
|
+
Store all loaded context in memory for use throughout this command session.
|
|
62
|
+
|
|
63
|
+
## Step 3 — CHECKPOINT
|
|
64
|
+
|
|
65
|
+
After completing Steps 1 and 2, display a summary and wait for confirmation:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
CHECKPOINT
|
|
69
|
+
-----------
|
|
70
|
+
Target : {resolved file path}
|
|
71
|
+
Project : {project.name from project-context.yaml}
|
|
72
|
+
Tech stack : {language} / {framework}
|
|
73
|
+
Module : {module if set, else "not configured"}
|
|
74
|
+
Domains : {comma-separated domain list}
|
|
75
|
+
|
|
76
|
+
Proceed? (Y/N)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Wait for explicit "Y" or "N" from the user before continuing.
|
|
80
|
+
- "Y" → proceed to the command-specific steps below.
|
|
81
|
+
- "N" → stop and ask what the user wants to change.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Report Footer — Standard Command Output Format
|
|
2
|
+
|
|
3
|
+
Every command report must end with this standard footer section.
|
|
4
|
+
|
|
5
|
+
## Status Badge
|
|
6
|
+
|
|
7
|
+
Choose one based on outcome:
|
|
8
|
+
- `✅ Complete` — all steps succeeded, no issues found
|
|
9
|
+
- `❌ Failed` — command could not complete due to a blocking error
|
|
10
|
+
- `⚠️ Warnings` — completed with non-blocking issues that should be reviewed
|
|
11
|
+
|
|
12
|
+
## Output Artifacts
|
|
13
|
+
|
|
14
|
+
List every file created or modified by this command:
|
|
15
|
+
```
|
|
16
|
+
Output Artifacts:
|
|
17
|
+
{created|updated} {file-path} ({brief description})
|
|
18
|
+
{created|updated} {file-path} ({brief description})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
|
|
22
|
+
|
|
23
|
+
## Next Command Suggestion
|
|
24
|
+
|
|
25
|
+
Suggest the logical next command based on workflow phase:
|
|
26
|
+
|
|
27
|
+
| Current command | Suggest next |
|
|
28
|
+
|-------------------------|-----------------------------------------------|
|
|
29
|
+
| /define-product | `/generate-prd {product-definition-file}` |
|
|
30
|
+
| /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
|
|
31
|
+
| /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
|
|
32
|
+
| /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
|
|
33
|
+
| /generate-bdd | `/review-context {feature-file}` to verify coverage |
|
|
34
|
+
| /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
|
|
35
|
+
| /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
|
|
36
|
+
| /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
|
|
37
|
+
| /generate-code | `/generate-tests {UC-ID}` |
|
|
38
|
+
| /generate-tests | `/run-tests {UC-ID}` |
|
|
39
|
+
| /run-tests (passing) | `/review-code {UC-ID}` |
|
|
40
|
+
| /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
|
|
41
|
+
| /review-code | `/smoke-test {UC-ID}` or create PR |
|
|
42
|
+
| /smoke-test | Create PR and link to ticket |
|
|
43
|
+
| /validate-traces | `/generate-code {UC-ID}` for gaps |
|
|
44
|
+
| /fix-bug | Create PR and link to ticket |
|
|
45
|
+
| /debug | `/fix-bug {ticket-id}` if fix needed |
|
|
46
|
+
|
|
47
|
+
Format the footer as:
|
|
48
|
+
```
|
|
49
|
+
---
|
|
50
|
+
Status : {badge}
|
|
51
|
+
{Output Artifacts block}
|
|
52
|
+
Next : {suggested command with example arguments}
|
|
53
|
+
```
|