create-shhs 1.0.0 → 1.1.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/INSTALLATION-GUIDE.md +424 -0
- package/README.md +16 -8
- package/UPDATE-GUIDE.md +500 -0
- package/bin/install.js +20 -0
- package/bin/update.js +396 -0
- package/package.json +8 -6
- package/template/.ai/.shhs-version +1 -0
- package/template/.ai/agents/architecture-reviewer.md +92 -0
- package/template/.ai/agents/fitness-enforcer.md +408 -0
- package/template/.ai/agents/knowledge-curator.md +242 -0
- package/template/.ai/architecture/governance/.gitkeep +7 -0
- package/template/.ai/architecture/governance/fitness/README.md +410 -0
- package/template/.ai/architecture/governance/fitness/config.json +48 -0
- package/template/.ai/architecture/governance/fitness/exemptions.json +20 -0
- package/template/.ai/architecture/governance/fitness/rules.json +102 -0
- package/template/.ai/governance/constitution.md +260 -0
- package/template/.ai/governance/definition-of-done.md +481 -0
- package/template/.ai/knowledge/knowledge-base.md +210 -0
- package/template/.ai/reports/fitness-results.json +201 -0
- package/template/.ai/skills/context7/skill.md +458 -0
- package/template/.ai/skills/playwright/skill.md +565 -0
- package/template/.ai/skills/tdd/skill.md +416 -0
- package/template/CLAUDE.md +51 -13
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft-07/schema",
|
|
3
|
+
"description": "Fitness Enforcer results format",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"timestamp": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "date-time",
|
|
9
|
+
"description": "ISO 8601 timestamp of enforcement run"
|
|
10
|
+
},
|
|
11
|
+
"commit": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Git commit SHA being validated"
|
|
14
|
+
},
|
|
15
|
+
"mode": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"enum": ["DETECT", "PREVENT"],
|
|
18
|
+
"description": "Enforcement mode"
|
|
19
|
+
},
|
|
20
|
+
"status": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["PASS", "FAIL"],
|
|
23
|
+
"description": "Overall status (FAIL if any BLOCK violations in PREVENT mode)"
|
|
24
|
+
},
|
|
25
|
+
"violations": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"description": "List of fitness rule violations",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"rule_id": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Unique rule identifier"
|
|
34
|
+
},
|
|
35
|
+
"severity": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["WARN", "BLOCK"],
|
|
38
|
+
"description": "Violation severity"
|
|
39
|
+
},
|
|
40
|
+
"file": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Relative path to violating file"
|
|
43
|
+
},
|
|
44
|
+
"line": {
|
|
45
|
+
"type": "integer",
|
|
46
|
+
"description": "Line number of violation (if applicable)"
|
|
47
|
+
},
|
|
48
|
+
"measured_value": {
|
|
49
|
+
"description": "Actual measured value (type varies by rule)",
|
|
50
|
+
"oneOf": [
|
|
51
|
+
{ "type": "string" },
|
|
52
|
+
{ "type": "number" }
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"threshold": {
|
|
56
|
+
"type": "number",
|
|
57
|
+
"description": "Threshold defined in rule"
|
|
58
|
+
},
|
|
59
|
+
"remedy": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "How to fix the violation"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["rule_id", "severity", "file", "measured_value", "threshold", "remedy"]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"metrics": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"description": "Aggregate metrics from this run",
|
|
70
|
+
"properties": {
|
|
71
|
+
"total_violations": {
|
|
72
|
+
"type": "integer",
|
|
73
|
+
"description": "Total number of violations"
|
|
74
|
+
},
|
|
75
|
+
"block_violations": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"description": "Number of BLOCK-severity violations"
|
|
78
|
+
},
|
|
79
|
+
"warn_violations": {
|
|
80
|
+
"type": "integer",
|
|
81
|
+
"description": "Number of WARN-severity violations"
|
|
82
|
+
},
|
|
83
|
+
"files_scanned": {
|
|
84
|
+
"type": "integer",
|
|
85
|
+
"description": "Total files analyzed"
|
|
86
|
+
},
|
|
87
|
+
"rules_evaluated": {
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"description": "Total fitness rules checked"
|
|
90
|
+
},
|
|
91
|
+
"dependency_graph_complexity": {
|
|
92
|
+
"type": "number",
|
|
93
|
+
"description": "Complexity score of module dependency graph"
|
|
94
|
+
},
|
|
95
|
+
"average_module_coupling": {
|
|
96
|
+
"type": "number",
|
|
97
|
+
"description": "Average coupling score per module"
|
|
98
|
+
},
|
|
99
|
+
"domain_boundary_leaks": {
|
|
100
|
+
"type": "integer",
|
|
101
|
+
"description": "Count of cross-domain coupling violations"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"required": ["total_violations", "block_violations", "warn_violations"]
|
|
105
|
+
},
|
|
106
|
+
"trend": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"description": "Comparison with previous run",
|
|
109
|
+
"properties": {
|
|
110
|
+
"previous_timestamp": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"format": "date-time"
|
|
113
|
+
},
|
|
114
|
+
"previous_commit": {
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"block_violations_delta": {
|
|
118
|
+
"type": "integer",
|
|
119
|
+
"description": "Change in BLOCK violations (negative = improvement)"
|
|
120
|
+
},
|
|
121
|
+
"warn_violations_delta": {
|
|
122
|
+
"type": "integer",
|
|
123
|
+
"description": "Change in WARN violations (negative = improvement)"
|
|
124
|
+
},
|
|
125
|
+
"trend_direction": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"enum": ["IMPROVING", "DEGRADING", "STABLE"],
|
|
128
|
+
"description": "Overall architectural health trend"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"exemptions_applied": {
|
|
133
|
+
"type": "array",
|
|
134
|
+
"description": "List of exemptions that suppressed violations",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"rule_id": {
|
|
139
|
+
"type": "string"
|
|
140
|
+
},
|
|
141
|
+
"file": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"expires": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"format": "date"
|
|
147
|
+
},
|
|
148
|
+
"adr": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"description": "ADR justifying exemption"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"required": ["timestamp", "mode", "status", "violations", "metrics"],
|
|
157
|
+
"example": {
|
|
158
|
+
"timestamp": "2026-02-24T10:30:00Z",
|
|
159
|
+
"commit": "abc123def456",
|
|
160
|
+
"mode": "PREVENT",
|
|
161
|
+
"status": "FAIL",
|
|
162
|
+
"violations": [
|
|
163
|
+
{
|
|
164
|
+
"rule_id": "cross-domain-db-access",
|
|
165
|
+
"severity": "BLOCK",
|
|
166
|
+
"file": "src/domain-billing/services/invoice.service.ts",
|
|
167
|
+
"line": 42,
|
|
168
|
+
"measured_value": "import { PrismaClient } from '@prisma/client'; prisma.user_orders.findMany()",
|
|
169
|
+
"threshold": 0,
|
|
170
|
+
"remedy": "Use UserService.getOrdersByUser() from domain-user public API instead of direct database access"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"rule_id": "max-module-dependencies",
|
|
174
|
+
"severity": "WARN",
|
|
175
|
+
"file": "src/utils/god-module.ts",
|
|
176
|
+
"line": null,
|
|
177
|
+
"measured_value": 14,
|
|
178
|
+
"threshold": 10,
|
|
179
|
+
"remedy": "Split into smaller modules: extract email utilities to email-utils.ts, date utilities to date-utils.ts"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"metrics": {
|
|
183
|
+
"total_violations": 2,
|
|
184
|
+
"block_violations": 1,
|
|
185
|
+
"warn_violations": 1,
|
|
186
|
+
"files_scanned": 47,
|
|
187
|
+
"rules_evaluated": 8,
|
|
188
|
+
"dependency_graph_complexity": 127,
|
|
189
|
+
"average_module_coupling": 3.2,
|
|
190
|
+
"domain_boundary_leaks": 1
|
|
191
|
+
},
|
|
192
|
+
"trend": {
|
|
193
|
+
"previous_timestamp": "2026-02-20T14:15:00Z",
|
|
194
|
+
"previous_commit": "xyz789abc012",
|
|
195
|
+
"block_violations_delta": 1,
|
|
196
|
+
"warn_violations_delta": -2,
|
|
197
|
+
"trend_direction": "DEGRADING"
|
|
198
|
+
},
|
|
199
|
+
"exemptions_applied": []
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# Skill: Context7 Documentation Query
|
|
2
|
+
|
|
3
|
+
**ID:** `context7`
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Status:** MANDATORY before architectural decisions
|
|
6
|
+
**Authority:** Constitution Article IV (Knowledge Curator)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## When to Apply
|
|
11
|
+
|
|
12
|
+
This skill is MANDATORY when:
|
|
13
|
+
|
|
14
|
+
- Proposing a new architectural pattern
|
|
15
|
+
- Adding a new library dependency
|
|
16
|
+
- Making claims about framework capabilities
|
|
17
|
+
- Resolving technical feasibility questions
|
|
18
|
+
- Validating assumptions during ADR creation
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## What Is Context7?
|
|
23
|
+
|
|
24
|
+
Context7 is a live documentation query service that provides:
|
|
25
|
+
- Current library documentation
|
|
26
|
+
- API signatures and behavior
|
|
27
|
+
- Version-specific constraints
|
|
28
|
+
- Code examples from official sources
|
|
29
|
+
|
|
30
|
+
It prevents architectural decisions based on outdated or incorrect assumptions.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Workflow
|
|
35
|
+
|
|
36
|
+
### Step 1: Identify Technical Claim
|
|
37
|
+
|
|
38
|
+
Before querying Context7, clearly state the assumption you need to validate.
|
|
39
|
+
|
|
40
|
+
**Examples:**
|
|
41
|
+
- "React Server Components can use `useState` hook"
|
|
42
|
+
- "Playwright can test WebSocket connections"
|
|
43
|
+
- "Next.js App Router supports middleware for all routes"
|
|
44
|
+
- "PostgreSQL JSON columns support path queries with `->>`"
|
|
45
|
+
|
|
46
|
+
### Step 2: Formulate Query
|
|
47
|
+
|
|
48
|
+
Structure your query as:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Library: [name + version if known]
|
|
52
|
+
Question: [specific capability]
|
|
53
|
+
Context: [what you're trying to build]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Example:**
|
|
57
|
+
```
|
|
58
|
+
Library: React 18
|
|
59
|
+
Question: Can Server Components use useState hook?
|
|
60
|
+
Context: Building a form component that needs to be rendered on the server
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Step 3: Execute Context7 Query
|
|
64
|
+
|
|
65
|
+
Use the MCP tool to query Context7:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Via MCP tool (exact syntax depends on MCP integration)
|
|
69
|
+
const result = await mcp.context7.query({
|
|
70
|
+
library: 'react',
|
|
71
|
+
version: '18',
|
|
72
|
+
query: 'Can Server Components use useState hook?'
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Step 4: Extract Evidence
|
|
77
|
+
|
|
78
|
+
From the response, extract:
|
|
79
|
+
|
|
80
|
+
1. **Direct Quote:** Exact text from documentation
|
|
81
|
+
2. **Source URL:** Link to official docs
|
|
82
|
+
3. **Verdict:** Does documentation support or contradict the claim?
|
|
83
|
+
4. **Constraints:** Any limitations or caveats mentioned
|
|
84
|
+
|
|
85
|
+
**Example Response Processing:**
|
|
86
|
+
```
|
|
87
|
+
Query: Can React Server Components use useState?
|
|
88
|
+
|
|
89
|
+
Evidence Found:
|
|
90
|
+
- Source: https://react.dev/reference/rsc/server-components
|
|
91
|
+
- Quote: "Server Components run only on the server and cannot use hooks like useState or useEffect."
|
|
92
|
+
- Verdict: ❌ CLAIM REJECTED
|
|
93
|
+
- Constraint: State management must be done in Client Components
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Step 5: Document Findings
|
|
97
|
+
|
|
98
|
+
Update `.ai/knowledge/knowledge-base.md` with findings.
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
### React Server Components
|
|
102
|
+
|
|
103
|
+
**Version:** 18.x
|
|
104
|
+
**Last Validated:** 2026-02-24
|
|
105
|
+
|
|
106
|
+
#### Hard Constraints
|
|
107
|
+
|
|
108
|
+
| Constraint | Evidence | Impact |
|
|
109
|
+
|------------|----------|--------|
|
|
110
|
+
| Cannot use `useState` or `useEffect` | [React Docs](https://react.dev/reference/rsc/server-components) — "Server Components run only on the server and cannot use hooks" | Interactive UI must use Client Components |
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Query Patterns
|
|
116
|
+
|
|
117
|
+
### Pattern 1: Feature Existence
|
|
118
|
+
|
|
119
|
+
**Question:** "Does [library] support [feature]?"
|
|
120
|
+
|
|
121
|
+
**Example:**
|
|
122
|
+
```
|
|
123
|
+
Library: Playwright 1.40
|
|
124
|
+
Question: Does Playwright support testing WebSocket connections?
|
|
125
|
+
Context: Need to test real-time chat feature
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Expected Evidence:**
|
|
129
|
+
- API documentation showing WebSocket test methods
|
|
130
|
+
- Code examples
|
|
131
|
+
- Or absence of such features
|
|
132
|
+
|
|
133
|
+
### Pattern 2: Behavior Validation
|
|
134
|
+
|
|
135
|
+
**Question:** "How does [library] handle [scenario]?"
|
|
136
|
+
|
|
137
|
+
**Example:**
|
|
138
|
+
```
|
|
139
|
+
Library: Next.js 14
|
|
140
|
+
Question: How does Next.js handle revalidation in App Router?
|
|
141
|
+
Context: Need to invalidate cached product pages after updates
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Expected Evidence:**
|
|
145
|
+
- Official documentation on `revalidatePath()` and `revalidateTag()`
|
|
146
|
+
- Constraints on when revalidation occurs
|
|
147
|
+
- Edge cases
|
|
148
|
+
|
|
149
|
+
### Pattern 3: Version Compatibility
|
|
150
|
+
|
|
151
|
+
**Question:** "Does [feature] work in [version]?"
|
|
152
|
+
|
|
153
|
+
**Example:**
|
|
154
|
+
```
|
|
155
|
+
Library: Next.js
|
|
156
|
+
Question: Are Server Actions available in Next.js 13.4?
|
|
157
|
+
Context: Project uses Next.js 13.4, proposal requires Server Actions
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Expected Evidence:**
|
|
161
|
+
- Changelog or docs indicating version requirements
|
|
162
|
+
- Clear answer: YES with version X.Y.Z or later
|
|
163
|
+
|
|
164
|
+
### Pattern 4: Anti-Pattern Detection
|
|
165
|
+
|
|
166
|
+
**Question:** "Is [approach] recommended by [library]?"
|
|
167
|
+
|
|
168
|
+
**Example:**
|
|
169
|
+
```
|
|
170
|
+
Library: React
|
|
171
|
+
Question: Is it recommended to fetch data in useEffect for SSR?
|
|
172
|
+
Context: Proposal suggests fetching user data in useEffect on dashboard
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Expected Evidence:**
|
|
176
|
+
- Official guidance discouraging this pattern
|
|
177
|
+
- Recommended alternative (e.g., Server Components, getServerSideProps)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Evidence Quality Criteria
|
|
182
|
+
|
|
183
|
+
### High-Quality Evidence
|
|
184
|
+
|
|
185
|
+
✅ **Official documentation**
|
|
186
|
+
- react.dev, nextjs.org, playwright.dev
|
|
187
|
+
- Published by library maintainers
|
|
188
|
+
|
|
189
|
+
✅ **Version-specific**
|
|
190
|
+
- Clearly states which version the information applies to
|
|
191
|
+
- Includes version compatibility notes
|
|
192
|
+
|
|
193
|
+
✅ **Direct quotes**
|
|
194
|
+
- Exact text from docs, not paraphrased
|
|
195
|
+
- Includes link to source
|
|
196
|
+
|
|
197
|
+
✅ **Code examples**
|
|
198
|
+
- Runnable code from official docs
|
|
199
|
+
- Demonstrates stated behavior
|
|
200
|
+
|
|
201
|
+
### Low-Quality Evidence
|
|
202
|
+
|
|
203
|
+
❌ **Blog posts or Stack Overflow**
|
|
204
|
+
- Not official sources
|
|
205
|
+
- May be outdated
|
|
206
|
+
|
|
207
|
+
❌ **Vague statements**
|
|
208
|
+
- "It should work"
|
|
209
|
+
- "I think this is possible"
|
|
210
|
+
|
|
211
|
+
❌ **Undated documentation**
|
|
212
|
+
- Can't determine if it's current
|
|
213
|
+
|
|
214
|
+
❌ **Inferred behavior**
|
|
215
|
+
- "Since feature X exists, Y should also work"
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Integration with SHHS Pipeline
|
|
220
|
+
|
|
221
|
+
### Pipeline Position
|
|
222
|
+
|
|
223
|
+
Context7 queries occur BEFORE architectural decisions.
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
Feature request received
|
|
227
|
+
↓
|
|
228
|
+
Knowledge Curator queries Context7 ← YOU ARE HERE
|
|
229
|
+
↓
|
|
230
|
+
├─→ Evidence SUPPORTS claim → Root Architect creates ADR
|
|
231
|
+
└─→ Evidence REJECTS claim → Return to stakeholder
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Validation Report Format
|
|
235
|
+
|
|
236
|
+
After querying Context7, Knowledge Curator produces:
|
|
237
|
+
|
|
238
|
+
```markdown
|
|
239
|
+
# Knowledge Validation Report
|
|
240
|
+
|
|
241
|
+
**Proposal:** Add real-time notifications using Server Components
|
|
242
|
+
**Date:** 2026-02-24
|
|
243
|
+
**Status:** REJECTED
|
|
244
|
+
|
|
245
|
+
## Technical Claims Validated
|
|
246
|
+
|
|
247
|
+
### Claim 1: React Server Components can maintain WebSocket connections
|
|
248
|
+
|
|
249
|
+
- **Status:** ❌ INVALID
|
|
250
|
+
- **Source:** https://react.dev/reference/rsc/server-components
|
|
251
|
+
- **Evidence:** "Server Components run only on the server and cannot maintain client-side connections like WebSockets."
|
|
252
|
+
- **Constraint:** Real-time features require Client Components
|
|
253
|
+
|
|
254
|
+
## Recommendation
|
|
255
|
+
|
|
256
|
+
REJECT proposal. Server Components cannot handle real-time connections.
|
|
257
|
+
|
|
258
|
+
**Alternative:** Use Client Components with `useEffect` to establish WebSocket connection.
|
|
259
|
+
|
|
260
|
+
## Knowledge Base Updates
|
|
261
|
+
|
|
262
|
+
- [x] Updated `.ai/knowledge/knowledge-base.md` with React Server Component constraints
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Common Queries and Answers
|
|
268
|
+
|
|
269
|
+
### Query: React Server Components and Hooks
|
|
270
|
+
|
|
271
|
+
**Question:** Can Server Components use hooks?
|
|
272
|
+
|
|
273
|
+
**Answer:**
|
|
274
|
+
- `useState`, `useEffect`, `useContext`: ❌ NO
|
|
275
|
+
- Custom hooks that don't use state: ✅ YES (if they're pure functions)
|
|
276
|
+
- **Source:** https://react.dev/reference/rsc/server-components
|
|
277
|
+
|
|
278
|
+
### Query: Next.js Middleware Scope
|
|
279
|
+
|
|
280
|
+
**Question:** Does Next.js middleware run on all routes?
|
|
281
|
+
|
|
282
|
+
**Answer:**
|
|
283
|
+
- Middleware runs on ALL routes by default
|
|
284
|
+
- Can be scoped with `matcher` config
|
|
285
|
+
- **Source:** https://nextjs.org/docs/app/building-your-application/routing/middleware
|
|
286
|
+
|
|
287
|
+
### Query: Playwright WebSocket Testing
|
|
288
|
+
|
|
289
|
+
**Question:** Can Playwright test WebSocket connections?
|
|
290
|
+
|
|
291
|
+
**Answer:**
|
|
292
|
+
- ✅ YES via `page.on('websocket')`
|
|
293
|
+
- Can intercept and mock WebSocket messages
|
|
294
|
+
- **Source:** https://playwright.dev/docs/api/class-websocket
|
|
295
|
+
|
|
296
|
+
### Query: PostgreSQL JSON Operators
|
|
297
|
+
|
|
298
|
+
**Question:** Does PostgreSQL support JSON path queries?
|
|
299
|
+
|
|
300
|
+
**Answer:**
|
|
301
|
+
- ✅ YES via `->` (returns JSON) and `->>` (returns text)
|
|
302
|
+
- Available since PostgreSQL 9.3
|
|
303
|
+
- **Source:** https://www.postgresql.org/docs/current/functions-json.html
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Updating Knowledge Base
|
|
308
|
+
|
|
309
|
+
After each Context7 query, update `.ai/knowledge/knowledge-base.md`.
|
|
310
|
+
|
|
311
|
+
### Update Template
|
|
312
|
+
|
|
313
|
+
```markdown
|
|
314
|
+
### [Library Name]
|
|
315
|
+
|
|
316
|
+
**Version:** [X.Y.Z]
|
|
317
|
+
**Last Validated:** [YYYY-MM-DD]
|
|
318
|
+
|
|
319
|
+
#### Hard Constraints
|
|
320
|
+
|
|
321
|
+
| Constraint | Evidence | Impact |
|
|
322
|
+
|------------|----------|--------|
|
|
323
|
+
| [What doesn't work] | [Docs URL + quote] | [Architectural implication] |
|
|
324
|
+
|
|
325
|
+
#### Recommended Patterns
|
|
326
|
+
|
|
327
|
+
- **Pattern:** [Name]
|
|
328
|
+
- **Use Case:** [When to apply]
|
|
329
|
+
- **Source:** [Docs URL]
|
|
330
|
+
|
|
331
|
+
#### Anti-Patterns
|
|
332
|
+
|
|
333
|
+
- **Anti-Pattern:** [Name]
|
|
334
|
+
- **Symptom:** [What developers try]
|
|
335
|
+
- **Why It Fails:** [Technical reason from docs]
|
|
336
|
+
- **Correct Approach:** [Alternative]
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Validation Criteria
|
|
342
|
+
|
|
343
|
+
Before approving an architectural decision:
|
|
344
|
+
|
|
345
|
+
- [ ] All technical claims queried via Context7
|
|
346
|
+
- [ ] Evidence extracted (quote + URL)
|
|
347
|
+
- [ ] Findings documented in knowledge base
|
|
348
|
+
- [ ] No contradictions between docs and proposal
|
|
349
|
+
- [ ] Version compatibility verified
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Common Mistakes
|
|
354
|
+
|
|
355
|
+
### Mistake 1: Trusting Assumptions Without Verification
|
|
356
|
+
|
|
357
|
+
❌ **Wrong:**
|
|
358
|
+
```
|
|
359
|
+
Architect: "Let's use Server Components for the dashboard. They can handle state."
|
|
360
|
+
Knowledge Curator: [doesn't check] "Sounds good."
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
✅ **Correct:**
|
|
364
|
+
```
|
|
365
|
+
Architect: "Let's use Server Components for the dashboard. They can handle state."
|
|
366
|
+
Knowledge Curator: "Let me verify that via Context7..."
|
|
367
|
+
[Queries Context7, finds Server Components can't use useState]
|
|
368
|
+
Knowledge Curator: "REJECTED. Server Components cannot use state hooks."
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Mistake 2: Using Outdated Documentation
|
|
372
|
+
|
|
373
|
+
❌ **Wrong:**
|
|
374
|
+
```
|
|
375
|
+
Knowledge Curator: "According to this 2019 blog post, Next.js doesn't support middleware."
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
✅ **Correct:**
|
|
379
|
+
```
|
|
380
|
+
Knowledge Curator queries Context7 for current Next.js docs
|
|
381
|
+
Context7 returns: "Middleware is supported since Next.js 12.0"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Mistake 3: Not Documenting Findings
|
|
385
|
+
|
|
386
|
+
❌ **Wrong:**
|
|
387
|
+
```
|
|
388
|
+
Knowledge Curator queries Context7, gets answer, verbally tells Architect
|
|
389
|
+
[6 months later, same question arises, must re-query]
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
✅ **Correct:**
|
|
393
|
+
```
|
|
394
|
+
Knowledge Curator queries Context7
|
|
395
|
+
Updates `.ai/knowledge/knowledge-base.md` with findings
|
|
396
|
+
[6 months later, constraint is already documented]
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## MCP Tool Usage
|
|
402
|
+
|
|
403
|
+
If Context7 is integrated via MCP (Model Context Protocol):
|
|
404
|
+
|
|
405
|
+
### Resolve Library ID
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
// First, resolve library name to Context7 ID
|
|
409
|
+
const libraries = await mcp.context7.resolveLibraryId({
|
|
410
|
+
libraryName: 'react',
|
|
411
|
+
query: 'React Server Components hooks'
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// Returns:
|
|
415
|
+
// [{ libraryId: '/facebook/react', version: '18.2.0', ... }]
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Query Documentation
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
const docs = await mcp.context7.queryDocs({
|
|
422
|
+
libraryId: '/facebook/react',
|
|
423
|
+
query: 'Can Server Components use useState hook?'
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// Returns:
|
|
427
|
+
// { answer: '...', sources: [...], codeExamples: [...] }
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Extract Evidence
|
|
431
|
+
|
|
432
|
+
From the response:
|
|
433
|
+
1. Read `answer` field
|
|
434
|
+
2. Extract quotes from `sources`
|
|
435
|
+
3. Review `codeExamples` for practical demonstrations
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Exemptions
|
|
440
|
+
|
|
441
|
+
NONE. Constitution Article IV mandates Knowledge Curator validation before architectural decisions.
|
|
442
|
+
|
|
443
|
+
If Context7 is unavailable:
|
|
444
|
+
1. Manually query official documentation
|
|
445
|
+
2. Document source URL and quote
|
|
446
|
+
3. Treat as temporary — revalidate when Context7 is available
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## References
|
|
451
|
+
|
|
452
|
+
- Constitution Article IV (Knowledge Curator mandate)
|
|
453
|
+
- `.ai/agents/knowledge-curator.md` (agent definition)
|
|
454
|
+
- `.ai/knowledge/knowledge-base.md` (knowledge cache)
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
**END OF CONTEXT7 SKILL**
|