forgecraft-mcp 1.2.0 → 1.3.2
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/README.md +525 -525
- package/dist/cli/help.js +44 -44
- package/dist/registry/renderer-skeletons.js +92 -92
- package/dist/shared/gs-score-logger.js +6 -6
- package/dist/tools/add-module.js +123 -123
- package/dist/tools/advice-registry.js +18 -18
- package/dist/tools/check-cascade-report.js +64 -64
- package/dist/tools/configure-mcp.d.ts +3 -0
- package/dist/tools/configure-mcp.d.ts.map +1 -1
- package/dist/tools/configure-mcp.js +10 -0
- package/dist/tools/configure-mcp.js.map +1 -1
- package/dist/tools/forgecraft-dispatch.d.ts.map +1 -1
- package/dist/tools/forgecraft-dispatch.js +3 -0
- package/dist/tools/forgecraft-dispatch.js.map +1 -1
- package/dist/tools/forgecraft-schema-params.d.ts +9 -0
- package/dist/tools/forgecraft-schema-params.d.ts.map +1 -1
- package/dist/tools/forgecraft-schema-params.js +21 -0
- package/dist/tools/forgecraft-schema-params.js.map +1 -1
- package/dist/tools/forgecraft-schema.d.ts +9 -0
- package/dist/tools/forgecraft-schema.d.ts.map +1 -1
- package/dist/tools/refresh-output.js +14 -14
- package/dist/tools/scaffold-spec-stubs.js +115 -115
- package/dist/tools/scaffold-templates.js +62 -62
- package/dist/tools/setup-artifact-writers.d.ts +30 -0
- package/dist/tools/setup-artifact-writers.d.ts.map +1 -1
- package/dist/tools/setup-artifact-writers.js +120 -8
- package/dist/tools/setup-artifact-writers.js.map +1 -1
- package/dist/tools/setup-phase1.d.ts +3 -0
- package/dist/tools/setup-phase1.d.ts.map +1 -1
- package/dist/tools/setup-phase1.js +79 -35
- package/dist/tools/setup-phase1.js.map +1 -1
- package/dist/tools/setup-phase2.d.ts +2 -0
- package/dist/tools/setup-phase2.d.ts.map +1 -1
- package/dist/tools/setup-phase2.js +10 -1
- package/dist/tools/setup-phase2.js.map +1 -1
- package/dist/tools/setup-project.d.ts +18 -0
- package/dist/tools/setup-project.d.ts.map +1 -1
- package/dist/tools/setup-project.js +77 -1
- package/dist/tools/setup-project.js.map +1 -1
- package/dist/tools/spec-parser-tags.d.ts +9 -0
- package/dist/tools/spec-parser-tags.d.ts.map +1 -1
- package/dist/tools/spec-parser-tags.js +92 -0
- package/dist/tools/spec-parser-tags.js.map +1 -1
- package/package.json +89 -86
- package/templates/analytics/instructions.yaml +37 -37
- package/templates/analytics/mcp-servers.yaml +11 -11
- package/templates/analytics/structure.yaml +25 -25
- package/templates/api/instructions.yaml +231 -231
- package/templates/api/mcp-servers.yaml +22 -13
- package/templates/api/nfr.yaml +23 -23
- package/templates/api/review.yaml +103 -103
- package/templates/api/structure.yaml +34 -34
- package/templates/api/verification.yaml +132 -132
- package/templates/cli/instructions.yaml +31 -31
- package/templates/cli/mcp-servers.yaml +11 -11
- package/templates/cli/review.yaml +53 -53
- package/templates/cli/structure.yaml +16 -16
- package/templates/data-lineage/instructions.yaml +28 -28
- package/templates/data-lineage/mcp-servers.yaml +22 -22
- package/templates/data-pipeline/instructions.yaml +84 -84
- package/templates/data-pipeline/mcp-servers.yaml +13 -13
- package/templates/data-pipeline/nfr.yaml +39 -39
- package/templates/data-pipeline/structure.yaml +23 -23
- package/templates/fintech/hooks.yaml +55 -55
- package/templates/fintech/instructions.yaml +112 -112
- package/templates/fintech/mcp-servers.yaml +13 -13
- package/templates/fintech/nfr.yaml +46 -46
- package/templates/fintech/playbook.yaml +210 -210
- package/templates/fintech/verification.yaml +239 -239
- package/templates/game/instructions.yaml +289 -289
- package/templates/game/mcp-servers.yaml +38 -38
- package/templates/game/nfr.yaml +64 -64
- package/templates/game/playbook.yaml +214 -214
- package/templates/game/review.yaml +97 -97
- package/templates/game/structure.yaml +67 -67
- package/templates/game/verification.yaml +174 -174
- package/templates/healthcare/instructions.yaml +42 -42
- package/templates/healthcare/mcp-servers.yaml +13 -13
- package/templates/healthcare/nfr.yaml +47 -47
- package/templates/hipaa/instructions.yaml +41 -41
- package/templates/hipaa/mcp-servers.yaml +13 -13
- package/templates/infra/instructions.yaml +104 -104
- package/templates/infra/mcp-servers.yaml +20 -20
- package/templates/infra/nfr.yaml +46 -46
- package/templates/infra/review.yaml +65 -65
- package/templates/infra/structure.yaml +25 -25
- package/templates/library/instructions.yaml +36 -36
- package/templates/library/mcp-servers.yaml +20 -20
- package/templates/library/review.yaml +56 -56
- package/templates/library/structure.yaml +19 -19
- package/templates/medallion-architecture/instructions.yaml +41 -41
- package/templates/medallion-architecture/mcp-servers.yaml +22 -22
- package/templates/ml/instructions.yaml +85 -85
- package/templates/ml/mcp-servers.yaml +11 -11
- package/templates/ml/nfr.yaml +39 -39
- package/templates/ml/structure.yaml +25 -25
- package/templates/ml/verification.yaml +156 -156
- package/templates/mobile/instructions.yaml +44 -44
- package/templates/mobile/mcp-servers.yaml +11 -11
- package/templates/mobile/nfr.yaml +49 -49
- package/templates/mobile/structure.yaml +27 -27
- package/templates/mobile/verification.yaml +121 -121
- package/templates/observability-xray/instructions.yaml +40 -40
- package/templates/observability-xray/mcp-servers.yaml +15 -15
- package/templates/realtime/instructions.yaml +42 -42
- package/templates/realtime/mcp-servers.yaml +13 -13
- package/templates/soc2/instructions.yaml +41 -41
- package/templates/soc2/mcp-servers.yaml +24 -24
- package/templates/social/instructions.yaml +43 -43
- package/templates/social/mcp-servers.yaml +24 -24
- package/templates/state-machine/instructions.yaml +42 -42
- package/templates/state-machine/mcp-servers.yaml +11 -11
- package/templates/tools-registry.yaml +164 -164
- package/templates/universal/hooks.yaml +531 -531
- package/templates/universal/instructions.yaml +1692 -1692
- package/templates/universal/mcp-servers.yaml +50 -50
- package/templates/universal/nfr.yaml +197 -197
- package/templates/universal/reference.yaml +326 -326
- package/templates/universal/review.yaml +204 -204
- package/templates/universal/skills.yaml +262 -262
- package/templates/universal/structure.yaml +67 -67
- package/templates/universal/verification.yaml +416 -416
- package/templates/web-react/hooks.yaml +44 -44
- package/templates/web-react/instructions.yaml +207 -207
- package/templates/web-react/mcp-servers.yaml +20 -20
- package/templates/web-react/nfr.yaml +27 -27
- package/templates/web-react/review.yaml +94 -94
- package/templates/web-react/structure.yaml +46 -46
- package/templates/web-react/verification.yaml +126 -126
- package/templates/web-static/instructions.yaml +115 -115
- package/templates/web-static/mcp-servers.yaml +20 -20
- package/templates/web3/instructions.yaml +44 -44
- package/templates/web3/mcp-servers.yaml +11 -11
- package/templates/web3/verification.yaml +159 -159
- package/templates/zero-trust/instructions.yaml +41 -41
- package/templates/zero-trust/mcp-servers.yaml +15 -15
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
tag: UNIVERSAL
|
|
2
|
-
section: skills
|
|
3
|
-
skills:
|
|
4
|
-
- id: code-review
|
|
5
|
-
name: Code Review
|
|
6
|
-
filename: code-review.md
|
|
7
|
-
description: "Structured code review with checklist and severity ratings"
|
|
8
|
-
tier: core
|
|
9
|
-
content: |
|
|
10
|
-
Review the code changes in this project. For each file changed:
|
|
11
|
-
|
|
12
|
-
1. **Read** the file and understand the context
|
|
13
|
-
2. **Check** against these criteria:
|
|
14
|
-
- Correctness: Does the logic do what it claims?
|
|
15
|
-
- Security: Any injection, auth bypass, or data leak risks?
|
|
16
|
-
- Performance: Any N+1 queries, unbounded loops, or memory leaks?
|
|
17
|
-
- Readability: Are names intention-revealing? Is complexity justified?
|
|
18
|
-
- Tests: Are edge cases covered? Can tests fail?
|
|
19
|
-
|
|
20
|
-
3. **Output** findings in this format:
|
|
21
|
-
- **File**: path/to/file
|
|
22
|
-
- **Line**: number
|
|
23
|
-
- **Severity**: CRITICAL | IMPORTANT | SUGGESTION
|
|
24
|
-
- **Issue**: description
|
|
25
|
-
- **Fix**: recommended change
|
|
26
|
-
|
|
27
|
-
If $ARGUMENTS is provided, focus the review on those specific files or concerns.
|
|
28
|
-
Otherwise, review all staged or recently changed files (use `git diff --name-only`).
|
|
29
|
-
|
|
30
|
-
- id: run-tests
|
|
31
|
-
name: Run Tests
|
|
32
|
-
filename: run-tests.md
|
|
33
|
-
description: "Run test suite and analyze failures"
|
|
34
|
-
tier: core
|
|
35
|
-
content: |
|
|
36
|
-
Run the project's test suite and analyze the results.
|
|
37
|
-
|
|
38
|
-
Steps:
|
|
39
|
-
{{#if language_is_typescript}}
|
|
40
|
-
1. Run `npm test` or `npx vitest run`
|
|
41
|
-
2. If tests fail, read the failing test files and the source code they test
|
|
42
|
-
3. Identify root cause — is it a test bug or a source bug?
|
|
43
|
-
4. Propose a fix with explanation
|
|
44
|
-
{{/if}}
|
|
45
|
-
{{#if language_is_python}}
|
|
46
|
-
1. Run `pytest -v` or `python -m pytest`
|
|
47
|
-
2. If tests fail, read the failing test files and the source code they test
|
|
48
|
-
3. Identify root cause — is it a test bug or a source bug?
|
|
49
|
-
4. Propose a fix with explanation
|
|
50
|
-
{{/if}}
|
|
51
|
-
|
|
52
|
-
If $ARGUMENTS is provided, run only matching tests (e.g., a specific file or pattern).
|
|
53
|
-
|
|
54
|
-
Always report:
|
|
55
|
-
- Total tests: passed / failed / skipped
|
|
56
|
-
- Coverage summary if available
|
|
57
|
-
- Any flaky test patterns detected
|
|
58
|
-
|
|
59
|
-
- id: debug-error
|
|
60
|
-
name: Debug Error
|
|
61
|
-
filename: debug-error.md
|
|
62
|
-
description: "Investigate and fix an error from logs or stack trace"
|
|
63
|
-
tier: recommended
|
|
64
|
-
content: |
|
|
65
|
-
Debug the following error. $ARGUMENTS should contain the error message or stack trace.
|
|
66
|
-
|
|
67
|
-
Investigation steps:
|
|
68
|
-
1. Parse the error message and stack trace
|
|
69
|
-
2. Identify the source file and line number
|
|
70
|
-
3. Read the relevant source code
|
|
71
|
-
4. Trace the data flow backward to find the root cause
|
|
72
|
-
5. Check for similar patterns elsewhere in the codebase
|
|
73
|
-
6. Propose a fix with:
|
|
74
|
-
- **Root cause**: why this happened
|
|
75
|
-
- **Fix**: the code change
|
|
76
|
-
- **Prevention**: how to prevent recurrence (test, type guard, validation)
|
|
77
|
-
|
|
78
|
-
Do NOT guess. Read the actual code before proposing solutions.
|
|
79
|
-
|
|
80
|
-
- id: refactor-file
|
|
81
|
-
name: Refactor File
|
|
82
|
-
filename: refactor-file.md
|
|
83
|
-
description: "Refactor a file following SOLID principles and project conventions"
|
|
84
|
-
tier: recommended
|
|
85
|
-
content: |
|
|
86
|
-
Refactor the file specified in $ARGUMENTS following project conventions.
|
|
87
|
-
|
|
88
|
-
Analysis steps:
|
|
89
|
-
1. Read the file completely
|
|
90
|
-
2. Check against SOLID principles:
|
|
91
|
-
- **S**: Does each function/class have one responsibility?
|
|
92
|
-
- **O**: Can behavior be extended without modifying existing code?
|
|
93
|
-
- **L**: Are subtypes substitutable?
|
|
94
|
-
- **I**: Are interfaces focused?
|
|
95
|
-
- **D**: Are dependencies injected?
|
|
96
|
-
3. Check project conventions:
|
|
97
|
-
- Max function length: 50 lines
|
|
98
|
-
- Max file length: 300 lines
|
|
99
|
-
- Max parameters: 5 (use parameter object if more)
|
|
100
|
-
- Intention-revealing names, no abbreviations
|
|
101
|
-
4. Propose changes grouped by priority:
|
|
102
|
-
- MUST: Violations of project standards
|
|
103
|
-
- SHOULD: Improvements to readability/maintainability
|
|
104
|
-
- COULD: Optional enhancements
|
|
105
|
-
|
|
106
|
-
Make changes incrementally. Run tests after each change to verify nothing breaks.
|
|
107
|
-
|
|
108
|
-
- id: tdd-workflow
|
|
109
|
-
name: TDD Workflow
|
|
110
|
-
filename: tdd-workflow.md
|
|
111
|
-
description: "Phase-gated TDD cycle: RED → GREEN → REFACTOR with mandatory output at each gate"
|
|
112
|
-
tier: core
|
|
113
|
-
content: |
|
|
114
|
-
Implement the behavior described in $ARGUMENTS using strict TDD. Follow this exact
|
|
115
|
-
sequence. Do not collapse phases. Each gate requires actual test runner output.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## PHASE 1 — Define and RED
|
|
120
|
-
|
|
121
|
-
1. **State the behavior** (one sentence, active voice):
|
|
122
|
-
> "When [precondition], [actor] [action], and [postcondition]."
|
|
123
|
-
If you cannot state this precisely, stop. Ask for clarification before writing anything.
|
|
124
|
-
|
|
125
|
-
2. **Write the test** — one test, one behavior. Name it as a specification:
|
|
126
|
-
`it('returns empty cart when last item is removed', ...)`
|
|
127
|
-
Write against the public interface, not implementation internals.
|
|
128
|
-
|
|
129
|
-
3. **Run the test now. Paste the full failure output below.**
|
|
130
|
-
```
|
|
131
|
-
[PASTE FAILURE OUTPUT HERE]
|
|
132
|
-
```
|
|
133
|
-
- If the test PASSES: the test is wrong. It is testing something that already exists
|
|
134
|
-
or is vacuously true. Do not proceed. Rewrite the test.
|
|
135
|
-
- If the test errors (import failure, missing module): fix the import, run again,
|
|
136
|
-
confirm the error is now a test assertion failure, not a setup failure.
|
|
137
|
-
- If the test fails with the expected assertion: proceed to Phase 2.
|
|
138
|
-
|
|
139
|
-
4. **Commit the failing test:**
|
|
140
|
-
```
|
|
141
|
-
git add tests/...
|
|
142
|
-
git commit -m "test(scope): [RED] [behavior description]"
|
|
143
|
-
```
|
|
144
|
-
The `[RED]` marker in the commit message is the machine-readable signal that this
|
|
145
|
-
commit represents a known-failing test. Do not commit `src/` files in this commit.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## PHASE 2 — GREEN (minimum implementation)
|
|
150
|
-
|
|
151
|
-
5. **Write the minimum code** to make the test pass.
|
|
152
|
-
- Minimum means: no code that is not required by the current red test.
|
|
153
|
-
- Do not generalize, do not anticipate the next feature.
|
|
154
|
-
- If you write more than ~20 lines to make one test pass, the test is too coarse.
|
|
155
|
-
Split it: write a smaller test, make that pass first.
|
|
156
|
-
|
|
157
|
-
6. **Run the full test suite now. Paste the summary output.**
|
|
158
|
-
```
|
|
159
|
-
[PASTE TEST OUTPUT HERE]
|
|
160
|
-
```
|
|
161
|
-
- If new test fails: the implementation introduced a regression. Fix before committing.
|
|
162
|
-
- If the target test still fails: the implementation is wrong. Do not commit.
|
|
163
|
-
- If all tests pass: proceed to commit.
|
|
164
|
-
|
|
165
|
-
7. **Commit the implementation:**
|
|
166
|
-
```
|
|
167
|
-
git add src/...
|
|
168
|
-
git commit -m "feat(scope): [behavior description]"
|
|
169
|
-
```
|
|
170
|
-
This commit should contain only `src/` (or equivalent) changes. No test changes.
|
|
171
|
-
If you need to modify the test to make it pass, that is a test bug — fix the test
|
|
172
|
-
in a separate commit first with an explanation of why the test was wrong.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## PHASE 3 — REFACTOR
|
|
177
|
-
|
|
178
|
-
8. **Inspect the implementation** for structure, not correctness:
|
|
179
|
-
- Does this function have one responsibility?
|
|
180
|
-
- Is there any duplication with existing code in `shared/`?
|
|
181
|
-
- Is the naming consistent with the layer-scoped vocabulary in the constitution?
|
|
182
|
-
- Is the complexity justified or can it be expressed more simply?
|
|
183
|
-
|
|
184
|
-
9. **Refactor one thing at a time. Run tests after each change.**
|
|
185
|
-
A refactor that breaks a test is not a refactor — it is a behavior change.
|
|
186
|
-
Revert it and find a correct structural change.
|
|
187
|
-
|
|
188
|
-
10. **Commit each refactor separately:**
|
|
189
|
-
```
|
|
190
|
-
git commit -m "refactor(scope): [what changed and why]"
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## Repeat for next behavior
|
|
196
|
-
|
|
197
|
-
Return to Phase 1 with the next behavior. The commit log for a complete feature
|
|
198
|
-
will read as an alternating sequence: test → feat → refactor → test → feat → ...
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## Failure modes to call out explicitly
|
|
203
|
-
|
|
204
|
-
If you find yourself in any of these states, stop and flag it:
|
|
205
|
-
- **"I'll write the test after, the implementation is straightforward"** — this is the
|
|
206
|
-
most common collapse. The implementation is never so straightforward that the test
|
|
207
|
-
adds no information. Write the test first.
|
|
208
|
-
- **"The test passes already"** — the behavior already existed, or the test is wrong.
|
|
209
|
-
Investigate before proceeding.
|
|
210
|
-
- **"I need to change the test to make it pass"** — this is acceptable only if the
|
|
211
|
-
test was incorrectly specified. Commit the test fix with explanation first.
|
|
212
|
-
- **Multiple behaviors failing at once** — you wrote too much implementation at once
|
|
213
|
-
in Phase 2. Revert to the minimum, pass the test, then add the next behavior in a
|
|
214
|
-
new RED cycle.
|
|
215
|
-
|
|
216
|
-
- id: static-analysis-duplication
|
|
217
|
-
name: Check Code Duplication
|
|
218
|
-
filename: static-analysis-duplication.md
|
|
219
|
-
description: "Detect copy-paste duplication in source files. Duplicated lines must be < 5% (min 50 tokens per clone)."
|
|
220
|
-
tier: recommended
|
|
221
|
-
tags: [UNIVERSAL, CLI, API]
|
|
222
|
-
content: |
|
|
223
|
-
Run a copy-paste duplication detector on the source directory.
|
|
224
|
-
Use the tool appropriate for your language (see project-gates.yaml: no-code-duplication).
|
|
225
|
-
|
|
226
|
-
Pass condition: Duplicated lines < 5% of total source lines (min-tokens: 50).
|
|
227
|
-
If above threshold, extract duplicated logic to a shared utility before committing.
|
|
228
|
-
|
|
229
|
-
Evidence: AX experiment — treatment-v6 achieved 2.50% with explicit DRY gate;
|
|
230
|
-
treatment-v3 reached 7.99% without it.
|
|
231
|
-
|
|
232
|
-
- id: static-analysis-circular-deps
|
|
233
|
-
name: Check Circular Dependencies
|
|
234
|
-
filename: static-analysis-circular-deps.md
|
|
235
|
-
description: "Detect circular import chains in the source directory. Zero tolerance."
|
|
236
|
-
tier: recommended
|
|
237
|
-
tags: [UNIVERSAL, CLI, API]
|
|
238
|
-
content: |
|
|
239
|
-
Run a dependency graph analyzer on the source directory.
|
|
240
|
-
Use the tool appropriate for your language (see project-gates.yaml: no-circular-dependencies).
|
|
241
|
-
Some languages (Go, Rust) reject circular imports at compile time natively.
|
|
242
|
-
|
|
243
|
-
Pass condition: Zero circular dependencies detected.
|
|
244
|
-
If cycles are found, extract a shared abstraction or invert the dependency direction.
|
|
245
|
-
|
|
246
|
-
- id: static-analysis-mutation
|
|
247
|
-
name: Run Mutation Tests (Stryker)
|
|
248
|
-
filename: static-analysis-mutation.md
|
|
249
|
-
description: "Run Stryker mutation testing. MSI must be >= 65% overall, >= 70% on changed code."
|
|
250
|
-
tier: recommended
|
|
251
|
-
tags: [UNIVERSAL, CLI, API]
|
|
252
|
-
content: |
|
|
253
|
-
Run Stryker on the changed module to verify test assertions actually catch bugs.
|
|
254
|
-
|
|
255
|
-
```
|
|
256
|
-
npx stryker run
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
Pass condition: Mutation Score Indicator (MSI) >= 65% overall, >= 70% on new/changed code.
|
|
260
|
-
Surviving mutants = missing assertions. Add targeted assertions before proceeding.
|
|
261
|
-
|
|
262
|
-
Run after writing each test batch, not only pre-release.
|
|
1
|
+
tag: UNIVERSAL
|
|
2
|
+
section: skills
|
|
3
|
+
skills:
|
|
4
|
+
- id: code-review
|
|
5
|
+
name: Code Review
|
|
6
|
+
filename: code-review.md
|
|
7
|
+
description: "Structured code review with checklist and severity ratings"
|
|
8
|
+
tier: core
|
|
9
|
+
content: |
|
|
10
|
+
Review the code changes in this project. For each file changed:
|
|
11
|
+
|
|
12
|
+
1. **Read** the file and understand the context
|
|
13
|
+
2. **Check** against these criteria:
|
|
14
|
+
- Correctness: Does the logic do what it claims?
|
|
15
|
+
- Security: Any injection, auth bypass, or data leak risks?
|
|
16
|
+
- Performance: Any N+1 queries, unbounded loops, or memory leaks?
|
|
17
|
+
- Readability: Are names intention-revealing? Is complexity justified?
|
|
18
|
+
- Tests: Are edge cases covered? Can tests fail?
|
|
19
|
+
|
|
20
|
+
3. **Output** findings in this format:
|
|
21
|
+
- **File**: path/to/file
|
|
22
|
+
- **Line**: number
|
|
23
|
+
- **Severity**: CRITICAL | IMPORTANT | SUGGESTION
|
|
24
|
+
- **Issue**: description
|
|
25
|
+
- **Fix**: recommended change
|
|
26
|
+
|
|
27
|
+
If $ARGUMENTS is provided, focus the review on those specific files or concerns.
|
|
28
|
+
Otherwise, review all staged or recently changed files (use `git diff --name-only`).
|
|
29
|
+
|
|
30
|
+
- id: run-tests
|
|
31
|
+
name: Run Tests
|
|
32
|
+
filename: run-tests.md
|
|
33
|
+
description: "Run test suite and analyze failures"
|
|
34
|
+
tier: core
|
|
35
|
+
content: |
|
|
36
|
+
Run the project's test suite and analyze the results.
|
|
37
|
+
|
|
38
|
+
Steps:
|
|
39
|
+
{{#if language_is_typescript}}
|
|
40
|
+
1. Run `npm test` or `npx vitest run`
|
|
41
|
+
2. If tests fail, read the failing test files and the source code they test
|
|
42
|
+
3. Identify root cause — is it a test bug or a source bug?
|
|
43
|
+
4. Propose a fix with explanation
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if language_is_python}}
|
|
46
|
+
1. Run `pytest -v` or `python -m pytest`
|
|
47
|
+
2. If tests fail, read the failing test files and the source code they test
|
|
48
|
+
3. Identify root cause — is it a test bug or a source bug?
|
|
49
|
+
4. Propose a fix with explanation
|
|
50
|
+
{{/if}}
|
|
51
|
+
|
|
52
|
+
If $ARGUMENTS is provided, run only matching tests (e.g., a specific file or pattern).
|
|
53
|
+
|
|
54
|
+
Always report:
|
|
55
|
+
- Total tests: passed / failed / skipped
|
|
56
|
+
- Coverage summary if available
|
|
57
|
+
- Any flaky test patterns detected
|
|
58
|
+
|
|
59
|
+
- id: debug-error
|
|
60
|
+
name: Debug Error
|
|
61
|
+
filename: debug-error.md
|
|
62
|
+
description: "Investigate and fix an error from logs or stack trace"
|
|
63
|
+
tier: recommended
|
|
64
|
+
content: |
|
|
65
|
+
Debug the following error. $ARGUMENTS should contain the error message or stack trace.
|
|
66
|
+
|
|
67
|
+
Investigation steps:
|
|
68
|
+
1. Parse the error message and stack trace
|
|
69
|
+
2. Identify the source file and line number
|
|
70
|
+
3. Read the relevant source code
|
|
71
|
+
4. Trace the data flow backward to find the root cause
|
|
72
|
+
5. Check for similar patterns elsewhere in the codebase
|
|
73
|
+
6. Propose a fix with:
|
|
74
|
+
- **Root cause**: why this happened
|
|
75
|
+
- **Fix**: the code change
|
|
76
|
+
- **Prevention**: how to prevent recurrence (test, type guard, validation)
|
|
77
|
+
|
|
78
|
+
Do NOT guess. Read the actual code before proposing solutions.
|
|
79
|
+
|
|
80
|
+
- id: refactor-file
|
|
81
|
+
name: Refactor File
|
|
82
|
+
filename: refactor-file.md
|
|
83
|
+
description: "Refactor a file following SOLID principles and project conventions"
|
|
84
|
+
tier: recommended
|
|
85
|
+
content: |
|
|
86
|
+
Refactor the file specified in $ARGUMENTS following project conventions.
|
|
87
|
+
|
|
88
|
+
Analysis steps:
|
|
89
|
+
1. Read the file completely
|
|
90
|
+
2. Check against SOLID principles:
|
|
91
|
+
- **S**: Does each function/class have one responsibility?
|
|
92
|
+
- **O**: Can behavior be extended without modifying existing code?
|
|
93
|
+
- **L**: Are subtypes substitutable?
|
|
94
|
+
- **I**: Are interfaces focused?
|
|
95
|
+
- **D**: Are dependencies injected?
|
|
96
|
+
3. Check project conventions:
|
|
97
|
+
- Max function length: 50 lines
|
|
98
|
+
- Max file length: 300 lines
|
|
99
|
+
- Max parameters: 5 (use parameter object if more)
|
|
100
|
+
- Intention-revealing names, no abbreviations
|
|
101
|
+
4. Propose changes grouped by priority:
|
|
102
|
+
- MUST: Violations of project standards
|
|
103
|
+
- SHOULD: Improvements to readability/maintainability
|
|
104
|
+
- COULD: Optional enhancements
|
|
105
|
+
|
|
106
|
+
Make changes incrementally. Run tests after each change to verify nothing breaks.
|
|
107
|
+
|
|
108
|
+
- id: tdd-workflow
|
|
109
|
+
name: TDD Workflow
|
|
110
|
+
filename: tdd-workflow.md
|
|
111
|
+
description: "Phase-gated TDD cycle: RED → GREEN → REFACTOR with mandatory output at each gate"
|
|
112
|
+
tier: core
|
|
113
|
+
content: |
|
|
114
|
+
Implement the behavior described in $ARGUMENTS using strict TDD. Follow this exact
|
|
115
|
+
sequence. Do not collapse phases. Each gate requires actual test runner output.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## PHASE 1 — Define and RED
|
|
120
|
+
|
|
121
|
+
1. **State the behavior** (one sentence, active voice):
|
|
122
|
+
> "When [precondition], [actor] [action], and [postcondition]."
|
|
123
|
+
If you cannot state this precisely, stop. Ask for clarification before writing anything.
|
|
124
|
+
|
|
125
|
+
2. **Write the test** — one test, one behavior. Name it as a specification:
|
|
126
|
+
`it('returns empty cart when last item is removed', ...)`
|
|
127
|
+
Write against the public interface, not implementation internals.
|
|
128
|
+
|
|
129
|
+
3. **Run the test now. Paste the full failure output below.**
|
|
130
|
+
```
|
|
131
|
+
[PASTE FAILURE OUTPUT HERE]
|
|
132
|
+
```
|
|
133
|
+
- If the test PASSES: the test is wrong. It is testing something that already exists
|
|
134
|
+
or is vacuously true. Do not proceed. Rewrite the test.
|
|
135
|
+
- If the test errors (import failure, missing module): fix the import, run again,
|
|
136
|
+
confirm the error is now a test assertion failure, not a setup failure.
|
|
137
|
+
- If the test fails with the expected assertion: proceed to Phase 2.
|
|
138
|
+
|
|
139
|
+
4. **Commit the failing test:**
|
|
140
|
+
```
|
|
141
|
+
git add tests/...
|
|
142
|
+
git commit -m "test(scope): [RED] [behavior description]"
|
|
143
|
+
```
|
|
144
|
+
The `[RED]` marker in the commit message is the machine-readable signal that this
|
|
145
|
+
commit represents a known-failing test. Do not commit `src/` files in this commit.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## PHASE 2 — GREEN (minimum implementation)
|
|
150
|
+
|
|
151
|
+
5. **Write the minimum code** to make the test pass.
|
|
152
|
+
- Minimum means: no code that is not required by the current red test.
|
|
153
|
+
- Do not generalize, do not anticipate the next feature.
|
|
154
|
+
- If you write more than ~20 lines to make one test pass, the test is too coarse.
|
|
155
|
+
Split it: write a smaller test, make that pass first.
|
|
156
|
+
|
|
157
|
+
6. **Run the full test suite now. Paste the summary output.**
|
|
158
|
+
```
|
|
159
|
+
[PASTE TEST OUTPUT HERE]
|
|
160
|
+
```
|
|
161
|
+
- If new test fails: the implementation introduced a regression. Fix before committing.
|
|
162
|
+
- If the target test still fails: the implementation is wrong. Do not commit.
|
|
163
|
+
- If all tests pass: proceed to commit.
|
|
164
|
+
|
|
165
|
+
7. **Commit the implementation:**
|
|
166
|
+
```
|
|
167
|
+
git add src/...
|
|
168
|
+
git commit -m "feat(scope): [behavior description]"
|
|
169
|
+
```
|
|
170
|
+
This commit should contain only `src/` (or equivalent) changes. No test changes.
|
|
171
|
+
If you need to modify the test to make it pass, that is a test bug — fix the test
|
|
172
|
+
in a separate commit first with an explanation of why the test was wrong.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## PHASE 3 — REFACTOR
|
|
177
|
+
|
|
178
|
+
8. **Inspect the implementation** for structure, not correctness:
|
|
179
|
+
- Does this function have one responsibility?
|
|
180
|
+
- Is there any duplication with existing code in `shared/`?
|
|
181
|
+
- Is the naming consistent with the layer-scoped vocabulary in the constitution?
|
|
182
|
+
- Is the complexity justified or can it be expressed more simply?
|
|
183
|
+
|
|
184
|
+
9. **Refactor one thing at a time. Run tests after each change.**
|
|
185
|
+
A refactor that breaks a test is not a refactor — it is a behavior change.
|
|
186
|
+
Revert it and find a correct structural change.
|
|
187
|
+
|
|
188
|
+
10. **Commit each refactor separately:**
|
|
189
|
+
```
|
|
190
|
+
git commit -m "refactor(scope): [what changed and why]"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Repeat for next behavior
|
|
196
|
+
|
|
197
|
+
Return to Phase 1 with the next behavior. The commit log for a complete feature
|
|
198
|
+
will read as an alternating sequence: test → feat → refactor → test → feat → ...
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Failure modes to call out explicitly
|
|
203
|
+
|
|
204
|
+
If you find yourself in any of these states, stop and flag it:
|
|
205
|
+
- **"I'll write the test after, the implementation is straightforward"** — this is the
|
|
206
|
+
most common collapse. The implementation is never so straightforward that the test
|
|
207
|
+
adds no information. Write the test first.
|
|
208
|
+
- **"The test passes already"** — the behavior already existed, or the test is wrong.
|
|
209
|
+
Investigate before proceeding.
|
|
210
|
+
- **"I need to change the test to make it pass"** — this is acceptable only if the
|
|
211
|
+
test was incorrectly specified. Commit the test fix with explanation first.
|
|
212
|
+
- **Multiple behaviors failing at once** — you wrote too much implementation at once
|
|
213
|
+
in Phase 2. Revert to the minimum, pass the test, then add the next behavior in a
|
|
214
|
+
new RED cycle.
|
|
215
|
+
|
|
216
|
+
- id: static-analysis-duplication
|
|
217
|
+
name: Check Code Duplication
|
|
218
|
+
filename: static-analysis-duplication.md
|
|
219
|
+
description: "Detect copy-paste duplication in source files. Duplicated lines must be < 5% (min 50 tokens per clone)."
|
|
220
|
+
tier: recommended
|
|
221
|
+
tags: [UNIVERSAL, CLI, API]
|
|
222
|
+
content: |
|
|
223
|
+
Run a copy-paste duplication detector on the source directory.
|
|
224
|
+
Use the tool appropriate for your language (see project-gates.yaml: no-code-duplication).
|
|
225
|
+
|
|
226
|
+
Pass condition: Duplicated lines < 5% of total source lines (min-tokens: 50).
|
|
227
|
+
If above threshold, extract duplicated logic to a shared utility before committing.
|
|
228
|
+
|
|
229
|
+
Evidence: AX experiment — treatment-v6 achieved 2.50% with explicit DRY gate;
|
|
230
|
+
treatment-v3 reached 7.99% without it.
|
|
231
|
+
|
|
232
|
+
- id: static-analysis-circular-deps
|
|
233
|
+
name: Check Circular Dependencies
|
|
234
|
+
filename: static-analysis-circular-deps.md
|
|
235
|
+
description: "Detect circular import chains in the source directory. Zero tolerance."
|
|
236
|
+
tier: recommended
|
|
237
|
+
tags: [UNIVERSAL, CLI, API]
|
|
238
|
+
content: |
|
|
239
|
+
Run a dependency graph analyzer on the source directory.
|
|
240
|
+
Use the tool appropriate for your language (see project-gates.yaml: no-circular-dependencies).
|
|
241
|
+
Some languages (Go, Rust) reject circular imports at compile time natively.
|
|
242
|
+
|
|
243
|
+
Pass condition: Zero circular dependencies detected.
|
|
244
|
+
If cycles are found, extract a shared abstraction or invert the dependency direction.
|
|
245
|
+
|
|
246
|
+
- id: static-analysis-mutation
|
|
247
|
+
name: Run Mutation Tests (Stryker)
|
|
248
|
+
filename: static-analysis-mutation.md
|
|
249
|
+
description: "Run Stryker mutation testing. MSI must be >= 65% overall, >= 70% on changed code."
|
|
250
|
+
tier: recommended
|
|
251
|
+
tags: [UNIVERSAL, CLI, API]
|
|
252
|
+
content: |
|
|
253
|
+
Run Stryker on the changed module to verify test assertions actually catch bugs.
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
npx stryker run
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Pass condition: Mutation Score Indicator (MSI) >= 65% overall, >= 70% on new/changed code.
|
|
260
|
+
Surviving mutants = missing assertions. Add targeted assertions before proceeding.
|
|
261
|
+
|
|
262
|
+
Run after writing each test batch, not only pre-release.
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
tag: UNIVERSAL
|
|
2
|
-
section: structure
|
|
3
|
-
language: both
|
|
4
|
-
entries:
|
|
5
|
-
- path: CLAUDE.md
|
|
6
|
-
type: file
|
|
7
|
-
description: "CC persistent instruction set"
|
|
8
|
-
- path: Status.md
|
|
9
|
-
type: file
|
|
10
|
-
description: "Session bridge — updated every session"
|
|
11
|
-
- path: .env.example
|
|
12
|
-
type: file
|
|
13
|
-
description: "All required env vars documented"
|
|
14
|
-
- path: .claude/hooks
|
|
15
|
-
type: directory
|
|
16
|
-
description: "Git quality gate scripts"
|
|
17
|
-
- path: docs
|
|
18
|
-
type: directory
|
|
19
|
-
description: "PRD, Tech Spec, ADRs"
|
|
20
|
-
- path: docs/PRD.md
|
|
21
|
-
type: file
|
|
22
|
-
description: "Product requirements document"
|
|
23
|
-
- path: DEVELOPMENT_PROMPTS.md
|
|
24
|
-
type: file
|
|
25
|
-
description: "Bound roadmap — session-scoped prompts with spec refs, preconditions, scope, acceptance criteria, and commit message. One entry per roadmap item. Procedural Memory."
|
|
26
|
-
- path: docs/TechSpec.md
|
|
27
|
-
type: file
|
|
28
|
-
description: "Technical specification"
|
|
29
|
-
- path: docs/adr
|
|
30
|
-
type: directory
|
|
31
|
-
description: "Architecture Decision Records"
|
|
32
|
-
- path: scripts
|
|
33
|
-
type: directory
|
|
34
|
-
description: "Project utility scripts"
|
|
35
|
-
- path: src
|
|
36
|
-
type: directory
|
|
37
|
-
description: "Application source code"
|
|
38
|
-
- path: src/shared/config
|
|
39
|
-
type: directory
|
|
40
|
-
description: "Env validation, fail-fast on startup"
|
|
41
|
-
- path: src/shared/exceptions
|
|
42
|
-
type: directory
|
|
43
|
-
description: "Base exception hierarchy"
|
|
44
|
-
- path: src/shared/logging
|
|
45
|
-
type: directory
|
|
46
|
-
description: "Structured logging setup"
|
|
47
|
-
- path: tests
|
|
48
|
-
type: directory
|
|
49
|
-
description: "Test suites"
|
|
50
|
-
- path: tests/unit
|
|
51
|
-
type: directory
|
|
52
|
-
description: "Unit tests"
|
|
53
|
-
- path: tests/integration
|
|
54
|
-
type: directory
|
|
55
|
-
description: "Integration tests"
|
|
56
|
-
- path: docs/adr
|
|
57
|
-
type: directory
|
|
58
|
-
description: "Architecture Decision Records — ADR-NNNN-short-title.md format"
|
|
59
|
-
- path: docs/diagrams
|
|
60
|
-
type: directory
|
|
61
|
-
description: "C4, sequence, state machine, and flow diagrams (PlantUML, Mermaid)"
|
|
62
|
-
- path: docs/use-cases
|
|
63
|
-
type: directory
|
|
64
|
-
description: "Precise use cases: actor, precondition, trigger, main flow, postcondition, acceptance criteria"
|
|
65
|
-
- path: specs
|
|
66
|
-
type: directory
|
|
67
|
-
description: "Platform-independent behavioral specs, session prompts, and generative asset acceptance criteria"
|
|
1
|
+
tag: UNIVERSAL
|
|
2
|
+
section: structure
|
|
3
|
+
language: both
|
|
4
|
+
entries:
|
|
5
|
+
- path: CLAUDE.md
|
|
6
|
+
type: file
|
|
7
|
+
description: "CC persistent instruction set"
|
|
8
|
+
- path: Status.md
|
|
9
|
+
type: file
|
|
10
|
+
description: "Session bridge — updated every session"
|
|
11
|
+
- path: .env.example
|
|
12
|
+
type: file
|
|
13
|
+
description: "All required env vars documented"
|
|
14
|
+
- path: .claude/hooks
|
|
15
|
+
type: directory
|
|
16
|
+
description: "Git quality gate scripts"
|
|
17
|
+
- path: docs
|
|
18
|
+
type: directory
|
|
19
|
+
description: "PRD, Tech Spec, ADRs"
|
|
20
|
+
- path: docs/PRD.md
|
|
21
|
+
type: file
|
|
22
|
+
description: "Product requirements document"
|
|
23
|
+
- path: DEVELOPMENT_PROMPTS.md
|
|
24
|
+
type: file
|
|
25
|
+
description: "Bound roadmap — session-scoped prompts with spec refs, preconditions, scope, acceptance criteria, and commit message. One entry per roadmap item. Procedural Memory."
|
|
26
|
+
- path: docs/TechSpec.md
|
|
27
|
+
type: file
|
|
28
|
+
description: "Technical specification"
|
|
29
|
+
- path: docs/adr
|
|
30
|
+
type: directory
|
|
31
|
+
description: "Architecture Decision Records"
|
|
32
|
+
- path: scripts
|
|
33
|
+
type: directory
|
|
34
|
+
description: "Project utility scripts"
|
|
35
|
+
- path: src
|
|
36
|
+
type: directory
|
|
37
|
+
description: "Application source code"
|
|
38
|
+
- path: src/shared/config
|
|
39
|
+
type: directory
|
|
40
|
+
description: "Env validation, fail-fast on startup"
|
|
41
|
+
- path: src/shared/exceptions
|
|
42
|
+
type: directory
|
|
43
|
+
description: "Base exception hierarchy"
|
|
44
|
+
- path: src/shared/logging
|
|
45
|
+
type: directory
|
|
46
|
+
description: "Structured logging setup"
|
|
47
|
+
- path: tests
|
|
48
|
+
type: directory
|
|
49
|
+
description: "Test suites"
|
|
50
|
+
- path: tests/unit
|
|
51
|
+
type: directory
|
|
52
|
+
description: "Unit tests"
|
|
53
|
+
- path: tests/integration
|
|
54
|
+
type: directory
|
|
55
|
+
description: "Integration tests"
|
|
56
|
+
- path: docs/adr
|
|
57
|
+
type: directory
|
|
58
|
+
description: "Architecture Decision Records — ADR-NNNN-short-title.md format"
|
|
59
|
+
- path: docs/diagrams
|
|
60
|
+
type: directory
|
|
61
|
+
description: "C4, sequence, state machine, and flow diagrams (PlantUML, Mermaid)"
|
|
62
|
+
- path: docs/use-cases
|
|
63
|
+
type: directory
|
|
64
|
+
description: "Precise use cases: actor, precondition, trigger, main flow, postcondition, acceptance criteria"
|
|
65
|
+
- path: specs
|
|
66
|
+
type: directory
|
|
67
|
+
description: "Platform-independent behavioral specs, session prompts, and generative asset acceptance criteria"
|