opencode-metis 0.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.
Files changed (156) hide show
  1. package/README.md +140 -0
  2. package/dist/cli.cjs +63 -0
  3. package/dist/mcp-server.cjs +51 -0
  4. package/dist/plugin.cjs +4 -0
  5. package/dist/worker.cjs +224 -0
  6. package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
  7. package/opencode/agent/the-analyst/market-research.md +77 -0
  8. package/opencode/agent/the-analyst/project-coordination.md +81 -0
  9. package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
  10. package/opencode/agent/the-architect/compatibility-review.md +138 -0
  11. package/opencode/agent/the-architect/complexity-review.md +137 -0
  12. package/opencode/agent/the-architect/quality-review.md +67 -0
  13. package/opencode/agent/the-architect/security-review.md +127 -0
  14. package/opencode/agent/the-architect/system-architecture.md +119 -0
  15. package/opencode/agent/the-architect/system-documentation.md +83 -0
  16. package/opencode/agent/the-architect/technology-research.md +85 -0
  17. package/opencode/agent/the-chief.md +79 -0
  18. package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
  19. package/opencode/agent/the-designer/design-foundation.md +74 -0
  20. package/opencode/agent/the-designer/interaction-architecture.md +75 -0
  21. package/opencode/agent/the-designer/user-research.md +70 -0
  22. package/opencode/agent/the-meta-agent.md +155 -0
  23. package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
  24. package/opencode/agent/the-platform-engineer/containerization.md +106 -0
  25. package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
  26. package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
  27. package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
  28. package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
  29. package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
  30. package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
  31. package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
  32. package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
  33. package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
  34. package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
  35. package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
  36. package/opencode/agent/the-software-engineer/api-development.md +78 -0
  37. package/opencode/agent/the-software-engineer/component-development.md +79 -0
  38. package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
  39. package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
  40. package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
  41. package/opencode/command/analyze.md +149 -0
  42. package/opencode/command/constitution.md +178 -0
  43. package/opencode/command/debug.md +194 -0
  44. package/opencode/command/document.md +178 -0
  45. package/opencode/command/implement.md +225 -0
  46. package/opencode/command/refactor.md +207 -0
  47. package/opencode/command/review.md +229 -0
  48. package/opencode/command/simplify.md +267 -0
  49. package/opencode/command/specify.md +191 -0
  50. package/opencode/command/validate.md +224 -0
  51. package/opencode/skill/accessibility-design/SKILL.md +566 -0
  52. package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
  53. package/opencode/skill/agent-coordination/SKILL.md +224 -0
  54. package/opencode/skill/api-contract-design/SKILL.md +550 -0
  55. package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
  56. package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
  57. package/opencode/skill/architecture-design/SKILL.md +160 -0
  58. package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
  59. package/opencode/skill/architecture-design/template.md +749 -0
  60. package/opencode/skill/architecture-design/validation.md +99 -0
  61. package/opencode/skill/architecture-selection/SKILL.md +522 -0
  62. package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
  63. package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
  64. package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
  65. package/opencode/skill/code-quality-review/SKILL.md +337 -0
  66. package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
  67. package/opencode/skill/code-quality-review/reference.md +322 -0
  68. package/opencode/skill/code-review/SKILL.md +363 -0
  69. package/opencode/skill/code-review/reference.md +450 -0
  70. package/opencode/skill/codebase-analysis/SKILL.md +139 -0
  71. package/opencode/skill/codebase-navigation/SKILL.md +227 -0
  72. package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
  73. package/opencode/skill/coding-conventions/SKILL.md +178 -0
  74. package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
  75. package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
  76. package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
  77. package/opencode/skill/constitution-validation/SKILL.md +315 -0
  78. package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
  79. package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
  80. package/opencode/skill/constitution-validation/template.md +115 -0
  81. package/opencode/skill/context-preservation/SKILL.md +445 -0
  82. package/opencode/skill/data-modeling/SKILL.md +385 -0
  83. package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
  84. package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
  85. package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
  86. package/opencode/skill/documentation-extraction/SKILL.md +259 -0
  87. package/opencode/skill/documentation-sync/SKILL.md +431 -0
  88. package/opencode/skill/domain-driven-design/SKILL.md +509 -0
  89. package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
  90. package/opencode/skill/domain-driven-design/reference.md +465 -0
  91. package/opencode/skill/drift-detection/SKILL.md +383 -0
  92. package/opencode/skill/drift-detection/reference.md +340 -0
  93. package/opencode/skill/error-recovery/SKILL.md +162 -0
  94. package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
  95. package/opencode/skill/feature-prioritization/SKILL.md +419 -0
  96. package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
  97. package/opencode/skill/feature-prioritization/reference.md +256 -0
  98. package/opencode/skill/git-workflow/SKILL.md +453 -0
  99. package/opencode/skill/implementation-planning/SKILL.md +215 -0
  100. package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
  101. package/opencode/skill/implementation-planning/template.md +220 -0
  102. package/opencode/skill/implementation-planning/validation.md +88 -0
  103. package/opencode/skill/implementation-verification/SKILL.md +272 -0
  104. package/opencode/skill/knowledge-capture/SKILL.md +265 -0
  105. package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
  106. package/opencode/skill/knowledge-capture/reference.md +444 -0
  107. package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
  108. package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
  109. package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
  110. package/opencode/skill/observability-design/SKILL.md +291 -0
  111. package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
  112. package/opencode/skill/pattern-detection/SKILL.md +171 -0
  113. package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
  114. package/opencode/skill/performance-analysis/SKILL.md +266 -0
  115. package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
  116. package/opencode/skill/requirements-analysis/SKILL.md +139 -0
  117. package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
  118. package/opencode/skill/requirements-analysis/template.md +177 -0
  119. package/opencode/skill/requirements-analysis/validation.md +69 -0
  120. package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
  121. package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
  122. package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
  123. package/opencode/skill/safe-refactoring/SKILL.md +312 -0
  124. package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
  125. package/opencode/skill/security-assessment/SKILL.md +421 -0
  126. package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
  127. package/opencode/skill/specification-management/SKILL.md +143 -0
  128. package/opencode/skill/specification-management/readme-template.md +32 -0
  129. package/opencode/skill/specification-management/reference.md +115 -0
  130. package/opencode/skill/specification-management/spec.py +229 -0
  131. package/opencode/skill/specification-validation/SKILL.md +397 -0
  132. package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
  133. package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
  134. package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
  135. package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
  136. package/opencode/skill/task-delegation/SKILL.md +607 -0
  137. package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
  138. package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
  139. package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
  140. package/opencode/skill/task-delegation/reference.md +825 -0
  141. package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
  142. package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
  143. package/opencode/skill/technical-writing/SKILL.md +190 -0
  144. package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
  145. package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
  146. package/opencode/skill/test-design/SKILL.md +464 -0
  147. package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
  148. package/opencode/skill/testing/SKILL.md +213 -0
  149. package/opencode/skill/testing/examples/test-pyramid.md +724 -0
  150. package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
  151. package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
  152. package/opencode/skill/user-research/SKILL.md +508 -0
  153. package/opencode/skill/user-research/examples/interview-questions.md +265 -0
  154. package/opencode/skill/user-research/examples/personas.md +267 -0
  155. package/opencode/skill/vibe-security/SKILL.md +654 -0
  156. package/package.json +45 -0
@@ -0,0 +1,315 @@
1
+ ---
2
+ name: constitution-validation
3
+ description: "Create and validate project constitutions through discovery-based rule generation with L1/L2/L3 enforcement levels"
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ category: analysis
8
+ version: "1.0"
9
+ ---
10
+
11
+ # Constitution Validation
12
+
13
+ Roleplay as a constitution specialist that creates and validates project governance rules through codebase pattern discovery.
14
+
15
+ ConstitutionValidation {
16
+ Activation {
17
+ Creating new project constitution
18
+ Updating existing constitution rules
19
+ Validating code against constitution
20
+ Generating compliance reports
21
+ Discovering codebase patterns for rules
22
+ }
23
+
24
+ Constraints {
25
+ 1. Every rule must have a discovered codebase pattern behind it -- never write rules without evidence
26
+ 2. Explore first: Use glob, grep, read to understand the project
27
+ 3. Discover patterns: What frameworks? What conventions? What architecture?
28
+ 4. Generate rules: Based on what you actually found
29
+ 5. Validate with user: Present discovered patterns before finalizing
30
+ }
31
+
32
+ LevelSystem {
33
+ | Level | Name | Blocking | Autofix | Use Case |
34
+ |-------|------|----------|---------|----------|
35
+ | **L1** | Must | Yes | AI auto-corrects | Critical rules -- security, correctness, architecture |
36
+ | **L2** | Should | Yes | No (needs human judgment) | Important rules requiring manual attention |
37
+ | **L3** | May | No | No | Advisory/optional -- style preferences, suggestions |
38
+
39
+ LevelBehavior {
40
+ | Level | Validation | Implementation | AI Behavior |
41
+ |-------|------------|----------------|-------------|
42
+ | L1 | Fails check, blocks | Blocks phase completion | Automatically fixes before proceeding |
43
+ | L2 | Fails check, blocks | Blocks phase completion | Reports violation, requires human action |
44
+ | L3 | Reports only | Does not block | Optional improvement, can be ignored |
45
+ }
46
+ }
47
+
48
+ ReferenceMaterials {
49
+ Load when needed (progressive disclosure):
50
+
51
+ | File | When to Load |
52
+ |------|--------------|
53
+ | [template.md](template.md) | When creating new constitution -- provides structure with `[NEEDS DISCOVERY]` markers |
54
+ | [examples/CONSTITUTION.md](examples/CONSTITUTION.md) | When user wants to see example constitution |
55
+ | [reference/rule-patterns.md](reference/rule-patterns.md) | For rule schema, scope examples, troubleshooting |
56
+ }
57
+
58
+ RuleSchema {
59
+ Each rule in the constitution uses this YAML structure:
60
+
61
+ ```yaml
62
+ level: L1 | L2 | L3
63
+ pattern: "regex pattern" # OR
64
+ check: "semantic description for LLM interpretation"
65
+ scope: "glob pattern for files to check"
66
+ exclude: "glob patterns to skip (comma-separated)"
67
+ message: "Human-readable violation message"
68
+ ```
69
+
70
+ | Field | Required | Type | Description |
71
+ |-------|----------|------|-------------|
72
+ | `level` | Required | L1 / L2 / L3 | Determines blocking and autofix behavior |
73
+ | `pattern` | One of | Regex | Pattern to match violations in source code |
74
+ | `check` | One of | String | Semantic description for LLM interpretation |
75
+ | `scope` | Required | Glob | File patterns to check (supports `**`) |
76
+ | `exclude` | Optional | Glob | File patterns to skip (comma-separated) |
77
+ | `message` | Required | String | Human-readable violation message |
78
+ }
79
+
80
+ FocusAreaMapping {
81
+ When focus areas are specified, select relevant discovery perspectives. First match wins.
82
+
83
+ | IF input matches | THEN discover |
84
+ |------------------|---------------|
85
+ | "security" | Security perspective only |
86
+ | "testing" | Testing perspective only |
87
+ | "architecture" | Architecture perspective only |
88
+ | "code quality" | Code Quality perspective only |
89
+ | Framework-specific (React, Next.js, etc.) | Relevant subset based on framework patterns |
90
+ | Empty or "all" | All perspectives |
91
+ }
92
+
93
+ DiscoveryPerspectives {
94
+ Launch parallel agents for comprehensive pattern analysis:
95
+
96
+ | Perspective | Intent | What to Discover |
97
+ |-------------|--------|------------------|
98
+ | **Security** | Identify security patterns and risks | Authentication methods, secret handling, input validation, injection prevention, CORS |
99
+ | **Architecture** | Understand structural patterns | Layer structure, module boundaries, API patterns, data flow, dependencies |
100
+ | **Code Quality** | Find coding conventions | Naming conventions, import patterns, error handling, logging, code organization |
101
+ | **Testing** | Discover test practices | Test framework, file patterns, coverage requirements, mocking approaches |
102
+
103
+ DiscoveryTaskTemplate {
104
+ ```
105
+ Discover [PERSPECTIVE] patterns for constitution rules:
106
+
107
+ CONTEXT:
108
+ - Project root: [path]
109
+ - Tech stack: [detected frameworks, languages]
110
+ - Existing configs: [.eslintrc, tsconfig, etc.]
111
+
112
+ FOCUS: [What this perspective discovers -- from table above]
113
+
114
+ OUTPUT: Findings formatted as:
115
+ **[Category]**
116
+ Pattern: [What was discovered]
117
+ Evidence: `file:line` references
118
+ Proposed Rule: [L1/L2/L3] [Rule statement]
119
+ ```
120
+ }
121
+ }
122
+
123
+ CreateOrUpdateDecision {
124
+ Check for existing constitution at project root. First match wins.
125
+
126
+ | IF state is | THEN route to |
127
+ |-------------|---------------|
128
+ | No CONSTITUTION.md exists | Create New Constitution |
129
+ | CONSTITUTION.md exists | Update Existing Constitution |
130
+ }
131
+
132
+ CreatingNewConstitution {
133
+ 1. Read template from [template.md](template.md)
134
+ 2. Template provides structure with `[NEEDS DISCOVERY]` markers to resolve
135
+ 3. Launch ALL applicable discovery perspectives in parallel
136
+ 4. Synthesize discoveries:
137
+ - Collect all findings from discovery agents
138
+ - Deduplicate overlapping patterns
139
+ - Classify rules by level (L1: security critical, auto-fixable; L2: important, needs judgment; L3: advisory)
140
+ - Group by category for presentation
141
+ 5. Present discovered rules, ask user via question: Approve rules or Modify
142
+ }
143
+
144
+ UpdatingExistingConstitution {
145
+ 1. Read current CONSTITUTION.md
146
+ 2. Parse existing rules and categories
147
+ 3. See [reference/rule-patterns.md](reference/rule-patterns.md) for rule schema and patterns
148
+ 4. Present options via question:
149
+ - Add new rules (to existing or new category)
150
+ - Modify existing rules
151
+ - Remove rules
152
+ - View current constitution
153
+ }
154
+
155
+ RuleGenerationGuidelines {
156
+ L1Rules {
157
+ Generate for patterns that are:
158
+ - Security critical (secrets, injection, auth)
159
+ - Clearly fixable with deterministic changes
160
+ - Objectively wrong (not style preference)
161
+ }
162
+
163
+ L2Rules {
164
+ Generate for patterns that are:
165
+ - Architecturally important
166
+ - Require human judgment to fix
167
+ - May have valid exceptions
168
+ }
169
+
170
+ L3Rules {
171
+ Generate for patterns that are:
172
+ - Style preferences
173
+ - Best practices that vary by context
174
+ - Suggestions, not requirements
175
+ }
176
+ }
177
+
178
+ ValidationMode {
179
+ When validating (not creating), skip discovery and:
180
+
181
+ 1. Parse existing constitution rules
182
+ 2. Apply scopes to find matching files
183
+ 3. Execute checks (Pattern or Check rules)
184
+ 4. Generate compliance report
185
+
186
+ RuleParsing {
187
+ ```pseudocode
188
+ FUNCTION: parse_constitution(markdown_content)
189
+ rules = []
190
+ current_category = null
191
+
192
+ FOR EACH section in markdown:
193
+ IF section.header.level == 2:
194
+ current_category = section.header.text
195
+ ELSE IF section.header.level == 3:
196
+ yaml_block = extract_yaml_code_block(section.content)
197
+ IF yaml_block:
198
+ rule = {
199
+ id: generate_rule_id(current_category, index),
200
+ name: section.header.text,
201
+ category: current_category,
202
+ level: yaml_block.level,
203
+ pattern: yaml_block.pattern,
204
+ check: yaml_block.check,
205
+ scope: yaml_block.scope,
206
+ exclude: yaml_block.exclude,
207
+ message: yaml_block.message,
208
+ }
209
+ IF rule.pattern OR rule.check:
210
+ rule.blocking = (rule.level == "L1" OR rule.level == "L2")
211
+ rule.autofix = (rule.level == "L1")
212
+ rules.append(rule)
213
+ RETURN rules
214
+ ```
215
+ }
216
+
217
+ ValidationExecution {
218
+ For each parsed rule:
219
+ 1. Glob files matching scope (excluding patterns in `exclude`)
220
+ 2. For Pattern rules: Execute regex match against file contents
221
+ 3. For Check rules: Use LLM to interpret semantic check
222
+ 4. Collect violations with file path, line number, code snippet
223
+ 5. Categorize by level for reporting
224
+ }
225
+ }
226
+
227
+ ComplianceReportFormat {
228
+ ```markdown
229
+ ## Constitution Compliance Report
230
+
231
+ **Constitution:** CONSTITUTION.md
232
+ **Target:** [spec-id or file path or "entire codebase"]
233
+ **Checked:** [ISO timestamp]
234
+
235
+ ### Summary
236
+
237
+ - Passed: [N] rules
238
+ - L3 Advisories: [N] rules
239
+ - L2 Blocking: [N] rules
240
+ - L1 Critical: [N] rules
241
+
242
+ ### Critical Violations (L1 - Autofix Required)
243
+
244
+ #### SEC-001: No Hardcoded Secrets
245
+
246
+ - **Location:** `src/services/PaymentService.ts:42`
247
+ - **Finding:** Hardcoded secret detected. Use environment variables.
248
+ - **Code:** `const API_KEY = 'sk_live_xxx...'`
249
+ - **Autofix:** Replace with `process.env.PAYMENT_API_KEY`
250
+
251
+ ### Blocking Violations (L2 - Human Action Required)
252
+
253
+ #### ARCH-001: Repository Pattern
254
+
255
+ - **Location:** `src/services/UserService.ts:18`
256
+ - **Finding:** Direct database call outside repository.
257
+ - **Code:** `await prisma.user.findMany(...)`
258
+ - **Action Required:** Extract to UserRepository
259
+
260
+ ### Advisories (L3 - Optional)
261
+
262
+ #### QUAL-001: Function Length
263
+
264
+ - **Location:** `src/utils/helpers.ts:45`
265
+ - **Finding:** Function exceeds recommended 25 lines (actual: 38)
266
+ - **Suggestion:** Consider extracting helper functions
267
+
268
+ ### Recommendations
269
+
270
+ 1. [Prioritized action item based on violations]
271
+ 2. [Next action item]
272
+ ```
273
+ }
274
+
275
+ GracefulDegradation {
276
+ | Scenario | Behavior |
277
+ |----------|----------|
278
+ | No CONSTITUTION.md | Report "No constitution found. Skipping constitution checks." |
279
+ | Invalid rule format | Skip rule, warn user, continue with other rules |
280
+ | Invalid regex pattern | Report as config error, skip rule |
281
+ | Scope matches no files | Report as info, not a failure |
282
+ | File read error | Skip file, warn, continue |
283
+ }
284
+
285
+ IntegrationPoints {
286
+ This skill is called by:
287
+ - `/constitution` -- For creation and updates
288
+ - `/validate` -- For constitution validation
289
+ - `/implement` -- For active enforcement during implementation
290
+ - `/review` -- For code review compliance checks
291
+ }
292
+
293
+ ValidationChecklist {
294
+ Before completing constitution creation:
295
+ - [ ] All `[NEEDS DISCOVERY]` markers resolved
296
+ - [ ] Every rule has valid level (L1/L2/L3)
297
+ - [ ] Every rule has either `pattern` or `check`
298
+ - [ ] Every rule has `scope` and `message`
299
+ - [ ] Rules are specific to this project (not generic)
300
+ - [ ] User has confirmed proposed rules
301
+ }
302
+
303
+ CategoryIDPrefixes {
304
+ When parsing rules, IDs are auto-generated from category:
305
+
306
+ | Category | Prefix | Example |
307
+ |----------|--------|---------|
308
+ | Security | SEC | SEC-001 |
309
+ | Architecture | ARCH | ARCH-001 |
310
+ | Code Quality | QUAL | QUAL-001 |
311
+ | Testing | TEST | TEST-001 |
312
+ | Custom | CUST | CUST-001 |
313
+ | [Custom Name] | First 4 letters uppercase | PERF-001 |
314
+ }
315
+ }
@@ -0,0 +1,202 @@
1
+ # Project Constitution
2
+
3
+ > Version: 1.0.0 | Last Updated: 2026-01-04
4
+ > Project Type: single-app (Next.js with TypeScript)
5
+
6
+ ## Security
7
+
8
+ ### No Hardcoded Secrets
9
+
10
+ ```yaml
11
+ level: L1
12
+ pattern: "(api_key|apikey|secret|password|token|credential)\\s*[:=]\\s*['\"][^'\"]{8,}['\"]"
13
+ scope: "**/*.{ts,js,json,yaml,yml}"
14
+ exclude: "**/*.test.*, **/*.spec.*, **/*.example.*, .env.example"
15
+ message: Hardcoded secret detected. Use environment variables.
16
+ ```
17
+
18
+ Secrets must never be committed to source control. Use environment variables via `process.env` or a secret management solution.
19
+
20
+ ### No Eval Usage
21
+
22
+ ```yaml
23
+ level: L1
24
+ pattern: "\\beval\\s*\\("
25
+ scope: "src/**/*.{ts,js}"
26
+ message: eval() is prohibited for security reasons.
27
+ ```
28
+
29
+ eval() enables code injection attacks. Use safer alternatives like JSON.parse() for data parsing.
30
+
31
+ ### No innerHTML Assignment
32
+
33
+ ```yaml
34
+ level: L1
35
+ pattern: "\\.(innerHTML|outerHTML)\\s*="
36
+ scope: "src/**/*.{ts,tsx,js,jsx}"
37
+ exclude: "**/*.test.*"
38
+ message: Direct innerHTML assignment risks XSS. Use React's dangerouslySetInnerHTML with sanitization or DOM methods.
39
+ ```
40
+
41
+ Direct DOM manipulation with user content can lead to cross-site scripting vulnerabilities.
42
+
43
+ ## Architecture
44
+
45
+ ### Repository Pattern Required
46
+
47
+ ```yaml
48
+ level: L1
49
+ check: Database queries (Prisma, TypeORM, Knex, raw SQL) only in files matching *Repository.ts or *Repository.js
50
+ scope: "src/**/*.{ts,js}"
51
+ exclude: "**/repositories/**, **/prisma/**"
52
+ message: Direct database call outside repository layer.
53
+ ```
54
+
55
+ All database operations must go through repository classes to maintain separation of concerns and enable testing.
56
+
57
+ ### No Direct API Calls in Components
58
+
59
+ ```yaml
60
+ level: L1
61
+ check: HTTP calls (fetch, axios) only in files under services/ or api/ or hooks/
62
+ scope: "src/components/**"
63
+ message: API calls must go through service layer.
64
+ ```
65
+
66
+ Components should be pure UI; data fetching belongs in the service layer or custom hooks.
67
+
68
+ ### No Barrel Exports
69
+
70
+ ```yaml
71
+ level: L1
72
+ pattern: "export \\* from"
73
+ scope: "src/**/*.ts"
74
+ exclude: "src/index.ts"
75
+ message: Barrel exports prohibited. Import from specific files.
76
+ ```
77
+
78
+ Barrel exports cause circular dependency issues and make tree-shaking ineffective. Always import from specific module files.
79
+
80
+ ## Code Quality
81
+
82
+ ### No Console Statements in Production
83
+
84
+ ```yaml
85
+ level: L2
86
+ pattern: "console\\.(log|debug|info)"
87
+ scope: "src/**/*.{ts,js}"
88
+ exclude: "**/*.test.*, **/*.spec.*, src/utils/logger.ts"
89
+ message: Remove console statements. Use logger utility.
90
+ ```
91
+
92
+ Console statements should be replaced with the structured logger for production observability.
93
+
94
+ ### Functions Under 25 Lines
95
+
96
+ ```yaml
97
+ level: L3
98
+ check: Functions should not exceed 25 lines
99
+ scope: "src/**/*.{ts,js}"
100
+ message: Function too long. Consider extracting into smaller functions.
101
+ ```
102
+
103
+ Smaller functions improve readability and testability, but this is a guideline not a strict requirement.
104
+
105
+ ### No Magic Numbers
106
+
107
+ ```yaml
108
+ level: L3
109
+ pattern: "[^0-9]\\b[2-9]\\d{2,}\\b(?![0-9])"
110
+ scope: "src/**/*.{ts,js}"
111
+ exclude: "**/*.test.*, **/*.spec.*, **/constants/**"
112
+ message: Magic number detected. Consider extracting to named constant.
113
+ ```
114
+
115
+ Numbers other than 0, 1, or small constants should be named for clarity.
116
+
117
+ ## Testing
118
+
119
+ ### No .only in Committed Tests
120
+
121
+ ```yaml
122
+ level: L1
123
+ pattern: "\\.(only|skip)\\s*\\("
124
+ scope: "**/*.test.*, **/*.spec.*"
125
+ message: Remove .only/.skip before committing tests.
126
+ ```
127
+
128
+ Focused tests prevent the full suite from running and may hide failures.
129
+
130
+ ### No console.log in Tests
131
+
132
+ ```yaml
133
+ level: L2
134
+ pattern: "console\\.log"
135
+ scope: "**/*.test.ts, **/*.spec.ts"
136
+ message: Use assertions instead of console.log in tests.
137
+ ```
138
+
139
+ Tests should use assertions; console.log often indicates incomplete test development.
140
+
141
+ ### Test File Recommended
142
+
143
+ ```yaml
144
+ level: L3
145
+ check: Every file in src/ should have corresponding .test.ts or .spec.ts
146
+ scope: "src/**/*.ts"
147
+ exclude: "src/**/*.d.ts, src/**/index.ts, src/**/*.test.ts, src/**/*.spec.ts"
148
+ message: Missing test file for this module.
149
+ ```
150
+
151
+ Test coverage is encouraged. Critical business logic should have corresponding tests.
152
+
153
+ ## React Patterns
154
+
155
+ ### No Direct State Mutation
156
+
157
+ ```yaml
158
+ level: L1
159
+ pattern: "this\\.state\\.[a-zA-Z]+\\s*="
160
+ scope: "src/**/*.{tsx,jsx}"
161
+ exclude: "**/*.test.*"
162
+ message: Use setState instead of direct state mutation.
163
+ ```
164
+
165
+ Direct state mutation bypasses React's rendering lifecycle and causes bugs.
166
+
167
+ ### Key Prop Required in Lists
168
+
169
+ ```yaml
170
+ level: L2
171
+ check: Array.map rendering JSX must include key prop with unique value (not array index)
172
+ scope: "src/**/*.{tsx,jsx}"
173
+ message: Missing or invalid key prop in list rendering. Use unique identifiers.
174
+ ```
175
+
176
+ Missing or index-based keys cause inefficient re-renders and bugs with stateful children.
177
+
178
+ ### No useEffect Dependencies Warning
179
+
180
+ ```yaml
181
+ level: L2
182
+ check: useEffect hooks should have explicit dependency arrays (not missing the second argument)
183
+ scope: "src/**/*.{tsx,jsx}"
184
+ message: useEffect without dependency array runs on every render.
185
+ ```
186
+
187
+ Missing dependency arrays often indicate unintended behavior.
188
+
189
+ ## Custom Rules
190
+
191
+ <!-- Project-specific rules can be added here -->
192
+
193
+ ### No Direct Environment Access in Components
194
+
195
+ ```yaml
196
+ level: L2
197
+ pattern: "process\\.env\\."
198
+ scope: "src/components/**/*.{tsx,jsx}"
199
+ message: Access environment variables through config module, not directly in components.
200
+ ```
201
+
202
+ Environment variables should be centralized for validation and default handling.