ima-claude 2.9.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 (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +1064 -0
  4. package/package.json +49 -0
  5. package/platforms/claude/adapter.ts +115 -0
  6. package/platforms/junie/adapter.ts +254 -0
  7. package/platforms/junie/agents-template.md +113 -0
  8. package/platforms/junie/hook-translations.md +84 -0
  9. package/platforms/shared/detector.ts +27 -0
  10. package/platforms/shared/installer.ts +202 -0
  11. package/platforms/shared/types.ts +78 -0
  12. package/plugins/ima-claude/.claude-plugin/plugin.json +25 -0
  13. package/plugins/ima-claude/agents/explorer.md +30 -0
  14. package/plugins/ima-claude/agents/implementer.md +30 -0
  15. package/plugins/ima-claude/agents/memory.md +42 -0
  16. package/plugins/ima-claude/agents/reviewer.md +53 -0
  17. package/plugins/ima-claude/agents/tester.md +33 -0
  18. package/plugins/ima-claude/agents/wp-developer.md +46 -0
  19. package/plugins/ima-claude/hooks/README.md +145 -0
  20. package/plugins/ima-claude/hooks/atlassian_prereqs.py +112 -0
  21. package/plugins/ima-claude/hooks/block_sed_edits.py +59 -0
  22. package/plugins/ima-claude/hooks/bootstrap.sh +90 -0
  23. package/plugins/ima-claude/hooks/bootstrap_utility_check.py +94 -0
  24. package/plugins/ima-claude/hooks/composer_autoload_check.py +70 -0
  25. package/plugins/ima-claude/hooks/docs_organization.py +104 -0
  26. package/plugins/ima-claude/hooks/enforce_rg_over_grep.py +56 -0
  27. package/plugins/ima-claude/hooks/fp_utility_check.py +90 -0
  28. package/plugins/ima-claude/hooks/hook_logger.py +69 -0
  29. package/plugins/ima-claude/hooks/hooks.json +239 -0
  30. package/plugins/ima-claude/hooks/jira_issue_fetch.py +79 -0
  31. package/plugins/ima-claude/hooks/jquery_in_wordpress.py +92 -0
  32. package/plugins/ima-claude/hooks/memory_bootstrap.py +79 -0
  33. package/plugins/ima-claude/hooks/memory_store_reminder.py +75 -0
  34. package/plugins/ima-claude/hooks/prompt_coach.py +125 -0
  35. package/plugins/ima-claude/hooks/prompt_coach_digest.md +48 -0
  36. package/plugins/ima-claude/hooks/prompt_coach_system.md +30 -0
  37. package/plugins/ima-claude/hooks/sequential_thinking_check.py +81 -0
  38. package/plugins/ima-claude/hooks/serena_over_grep.py +96 -0
  39. package/plugins/ima-claude/hooks/serena_over_read.py +66 -0
  40. package/plugins/ima-claude/hooks/serena_project_check.py +133 -0
  41. package/plugins/ima-claude/hooks/sql_injection_check.py +73 -0
  42. package/plugins/ima-claude/hooks/task_master_after_plan.py +31 -0
  43. package/plugins/ima-claude/hooks/task_master_before_impl.py +93 -0
  44. package/plugins/ima-claude/hooks/tavily_extract_advanced.py +48 -0
  45. package/plugins/ima-claude/hooks/vestige_before_external.py +86 -0
  46. package/plugins/ima-claude/hooks/webfetch_to_tavily.py +42 -0
  47. package/plugins/ima-claude/hooks/websearch_to_tavily.py +41 -0
  48. package/plugins/ima-claude/hooks/wp_security_check.py +150 -0
  49. package/plugins/ima-claude/personalities/README.md +45 -0
  50. package/plugins/ima-claude/personalities/enable-40k.md +69 -0
  51. package/plugins/ima-claude/personalities/enable-templars.md +69 -0
  52. package/plugins/ima-claude/skills/.research-summary.md +340 -0
  53. package/plugins/ima-claude/skills/architect/SKILL.md +304 -0
  54. package/plugins/ima-claude/skills/compound-bridge/SKILL.md +200 -0
  55. package/plugins/ima-claude/skills/discourse/SKILL.md +440 -0
  56. package/plugins/ima-claude/skills/discourse-admin/SKILL.md +192 -0
  57. package/plugins/ima-claude/skills/discourse-admin/references/api-endpoints.md +441 -0
  58. package/plugins/ima-claude/skills/discourse-admin/references/gotchas.md +107 -0
  59. package/plugins/ima-claude/skills/discourse-admin/references/staging-defaults.md +98 -0
  60. package/plugins/ima-claude/skills/discourse-admin/scripts/discourse-admin.py +319 -0
  61. package/plugins/ima-claude/skills/docs-organize/SKILL.md +254 -0
  62. package/plugins/ima-claude/skills/docs-organize/templates/active-README.md +50 -0
  63. package/plugins/ima-claude/skills/docs-organize/templates/archive-README.md +57 -0
  64. package/plugins/ima-claude/skills/docs-organize/templates/docs-README.md +43 -0
  65. package/plugins/ima-claude/skills/docs-organize/templates/phase-archive-README.md +83 -0
  66. package/plugins/ima-claude/skills/docs-organize/templates/section-README.md +48 -0
  67. package/plugins/ima-claude/skills/docs-organize/templates/transient-README.md +79 -0
  68. package/plugins/ima-claude/skills/docs-organize/templates/transient-gitignore +9 -0
  69. package/plugins/ima-claude/skills/ember-discourse/SKILL.md +496 -0
  70. package/plugins/ima-claude/skills/functional-programmer/SKILL.md +258 -0
  71. package/plugins/ima-claude/skills/ima-bootstrap/SKILL.md +278 -0
  72. package/plugins/ima-claude/skills/ima-bootstrap/references/bootstrap-patterns.md +356 -0
  73. package/plugins/ima-claude/skills/ima-bootstrap/references/ima-brand.md +273 -0
  74. package/plugins/ima-claude/skills/ima-bootstrap/references/theme-integration.md +212 -0
  75. package/plugins/ima-claude/skills/ima-brand/SKILL.md +108 -0
  76. package/plugins/ima-claude/skills/ima-brand/references/brand-identity.md +140 -0
  77. package/plugins/ima-claude/skills/ima-brand/references/digital-standards.md +180 -0
  78. package/plugins/ima-claude/skills/ima-brand/references/visual-system.md +173 -0
  79. package/plugins/ima-claude/skills/ima-forms-expert/SKILL.md +175 -0
  80. package/plugins/ima-claude/skills/ima-forms-expert/references/container-components.md +154 -0
  81. package/plugins/ima-claude/skills/ima-forms-expert/references/examples.md +328 -0
  82. package/plugins/ima-claude/skills/ima-forms-expert/references/field-components.md +298 -0
  83. package/plugins/ima-claude/skills/ima-forms-expert/references/form-factory.md +193 -0
  84. package/plugins/ima-claude/skills/ima-forms-expert/references/quick-reference.md +153 -0
  85. package/plugins/ima-claude/skills/ima-forms-expert/references/validation-engine.md +336 -0
  86. package/plugins/ima-claude/skills/jira-checkpoint/SKILL.md +178 -0
  87. package/plugins/ima-claude/skills/jquery/SKILL.md +413 -0
  88. package/plugins/ima-claude/skills/js-fp/SKILL.md +463 -0
  89. package/plugins/ima-claude/skills/js-fp/core-principles.md +487 -0
  90. package/plugins/ima-claude/skills/js-fp/examples/pure-functions.js +260 -0
  91. package/plugins/ima-claude/skills/js-fp/examples/tests/pure-functions.test.js +262 -0
  92. package/plugins/ima-claude/skills/js-fp/references/anti-patterns.md +120 -0
  93. package/plugins/ima-claude/skills/js-fp/references/performance-patterns.md +116 -0
  94. package/plugins/ima-claude/skills/js-fp/references/testing-patterns.md +134 -0
  95. package/plugins/ima-claude/skills/js-fp-api/SKILL.md +280 -0
  96. package/plugins/ima-claude/skills/js-fp-api/examples/crud-endpoint.js +258 -0
  97. package/plugins/ima-claude/skills/js-fp-api/references/middleware-patterns.md +134 -0
  98. package/plugins/ima-claude/skills/js-fp-api/references/security-sql.md +110 -0
  99. package/plugins/ima-claude/skills/js-fp-api/references/validation-patterns.md +165 -0
  100. package/plugins/ima-claude/skills/js-fp-react/SKILL.md +447 -0
  101. package/plugins/ima-claude/skills/js-fp-react/examples/ProductCard.tsx +65 -0
  102. package/plugins/ima-claude/skills/js-fp-react/references/hooks-advanced.md +136 -0
  103. package/plugins/ima-claude/skills/js-fp-react/references/performance-patterns.md +175 -0
  104. package/plugins/ima-claude/skills/js-fp-vue/SKILL.md +322 -0
  105. package/plugins/ima-claude/skills/js-fp-vue/references/complete-examples.md +397 -0
  106. package/plugins/ima-claude/skills/js-fp-vue/references/composables-advanced.md +282 -0
  107. package/plugins/ima-claude/skills/js-fp-vue/references/reactivity-patterns.md +348 -0
  108. package/plugins/ima-claude/skills/js-fp-vue/references/testing.md +314 -0
  109. package/plugins/ima-claude/skills/js-fp-wordpress/SKILL.md +301 -0
  110. package/plugins/ima-claude/skills/js-fp-wordpress/references/ajax-patterns.md +192 -0
  111. package/plugins/ima-claude/skills/js-fp-wordpress/references/event-patterns.md +136 -0
  112. package/plugins/ima-claude/skills/js-fp-wordpress/references/wp-integration.md +248 -0
  113. package/plugins/ima-claude/skills/livecanvas/SKILL.md +209 -0
  114. package/plugins/ima-claude/skills/livecanvas/references/livecanvas-features.md +311 -0
  115. package/plugins/ima-claude/skills/livecanvas/references/loops-and-logic.md +730 -0
  116. package/plugins/ima-claude/skills/livecanvas/references/picostrap.md +227 -0
  117. package/plugins/ima-claude/skills/mcp-atlassian/SKILL.md +339 -0
  118. package/plugins/ima-claude/skills/mcp-context7/SKILL.md +109 -0
  119. package/plugins/ima-claude/skills/mcp-memory/SKILL.md +182 -0
  120. package/plugins/ima-claude/skills/mcp-qdrant/SKILL.md +233 -0
  121. package/plugins/ima-claude/skills/mcp-sequential/SKILL.md +149 -0
  122. package/plugins/ima-claude/skills/mcp-serena/SKILL.md +174 -0
  123. package/plugins/ima-claude/skills/mcp-tavily/SKILL.md +118 -0
  124. package/plugins/ima-claude/skills/mcp-vestige/SKILL.md +259 -0
  125. package/plugins/ima-claude/skills/php-authnet/SKILL.md +275 -0
  126. package/plugins/ima-claude/skills/php-authnet/references/api-reference.md +624 -0
  127. package/plugins/ima-claude/skills/php-authnet/references/sandbox-testing.md +424 -0
  128. package/plugins/ima-claude/skills/php-fp/SKILL.md +333 -0
  129. package/plugins/ima-claude/skills/php-fp/examples/pure-functions.php +403 -0
  130. package/plugins/ima-claude/skills/php-fp/examples/tests/PureFunctionsTest.php +515 -0
  131. package/plugins/ima-claude/skills/php-fp/references/core-principles.md +277 -0
  132. package/plugins/ima-claude/skills/php-fp/references/testing-patterns.md +374 -0
  133. package/plugins/ima-claude/skills/php-fp-wordpress/SKILL.md +216 -0
  134. package/plugins/ima-claude/skills/php-fp-wordpress/references/fp-patterns.md +275 -0
  135. package/plugins/ima-claude/skills/php-fp-wordpress/references/plugin-architecture.md +295 -0
  136. package/plugins/ima-claude/skills/php-fp-wordpress/references/security-examples.md +203 -0
  137. package/plugins/ima-claude/skills/php-fp-wordpress/references/testing-strategy.md +259 -0
  138. package/plugins/ima-claude/skills/phpunit-wp/SKILL.md +716 -0
  139. package/plugins/ima-claude/skills/playwright/SKILL.md +434 -0
  140. package/plugins/ima-claude/skills/playwright/references/accessibility-testing.md +153 -0
  141. package/plugins/ima-claude/skills/playwright/references/ci-cd.md +268 -0
  142. package/plugins/ima-claude/skills/playwright/references/network-mocking.md +270 -0
  143. package/plugins/ima-claude/skills/playwright/references/visual-regression.md +215 -0
  144. package/plugins/ima-claude/skills/py-fp/SKILL.md +663 -0
  145. package/plugins/ima-claude/skills/py-fp/examples/pure-functions.py +185 -0
  146. package/plugins/ima-claude/skills/py-fp/examples/tests/test_pure_functions.py +244 -0
  147. package/plugins/ima-claude/skills/py-fp/references/core-principles.md +381 -0
  148. package/plugins/ima-claude/skills/py-fp/references/testing-patterns.md +283 -0
  149. package/plugins/ima-claude/skills/quasar-fp/SKILL.md +327 -0
  150. package/plugins/ima-claude/skills/quasar-fp/metadata.json +85 -0
  151. package/plugins/ima-claude/skills/quasar-fp/references/component-patterns.md +257 -0
  152. package/plugins/ima-claude/skills/quasar-fp/references/theme-integration.md +233 -0
  153. package/plugins/ima-claude/skills/quasar-fp/references/utility-classes.md +237 -0
  154. package/plugins/ima-claude/skills/quickstart/SKILL.md +129 -0
  155. package/plugins/ima-claude/skills/rails/SKILL.md +359 -0
  156. package/plugins/ima-claude/skills/resume-session/SKILL.md +68 -0
  157. package/plugins/ima-claude/skills/rg/SKILL.md +205 -0
  158. package/plugins/ima-claude/skills/ruby-fp/SKILL.md +336 -0
  159. package/plugins/ima-claude/skills/save-session/SKILL.md +81 -0
  160. package/plugins/ima-claude/skills/scorecard/SKILL.md +96 -0
  161. package/plugins/ima-claude/skills/skill-analyzer/SKILL.md +127 -0
  162. package/plugins/ima-claude/skills/skill-analyzer/references/advanced-checklist.md +44 -0
  163. package/plugins/ima-claude/skills/skill-analyzer/references/core-checklist.md +60 -0
  164. package/plugins/ima-claude/skills/skill-analyzer/scripts/analyze_skill.py +418 -0
  165. package/plugins/ima-claude/skills/skill-creator/LICENSE.txt +202 -0
  166. package/plugins/ima-claude/skills/skill-creator/SKILL.md +343 -0
  167. package/plugins/ima-claude/skills/skill-creator/references/output-patterns.md +82 -0
  168. package/plugins/ima-claude/skills/skill-creator/references/workflows.md +28 -0
  169. package/plugins/ima-claude/skills/skill-creator/scripts/init_skill.py +303 -0
  170. package/plugins/ima-claude/skills/skill-creator/scripts/package_skill.py +110 -0
  171. package/plugins/ima-claude/skills/skill-creator/scripts/quick_validate.py +103 -0
  172. package/plugins/ima-claude/skills/task-master/SKILL.md +51 -0
  173. package/plugins/ima-claude/skills/task-planner/SKILL.md +228 -0
  174. package/plugins/ima-claude/skills/task-runner/SKILL.md +192 -0
  175. package/plugins/ima-claude/skills/unit-testing/SKILL.md +198 -0
  176. package/plugins/ima-claude/skills/unit-testing/references/mock-patterns.md +181 -0
  177. package/plugins/ima-claude/skills/unit-testing/references/tdd-workflow.md +177 -0
  178. package/plugins/ima-claude/skills/unit-testing/references/test-strategy.md +126 -0
  179. package/plugins/ima-claude/skills/wp-local/SKILL.md +246 -0
  180. package/plugins/ima-claude/skills/wp-local/references/configuration.md +198 -0
  181. package/plugins/ima-claude/skills/wp-local/references/wp-cli-reference.md +406 -0
  182. package/plugins/ima-claude/skills/wp-local/scripts/wp-local.sh +61 -0
@@ -0,0 +1,340 @@
1
+ # Research Summary: FP Patterns from reatch-stack-api
2
+
3
+ Based on analysis of `/home/eric/dev/z2/reatch-stack/reatch-api/docs` and `/ai-docs`.
4
+
5
+ ## Source Files Analyzed
6
+ - `Functional-Programming-Agent-Training-Analysis.md` (809 lines)
7
+ - `design-pattern-analysis-part1.md` (210 lines)
8
+ - `design-pattern-analysis-part2.md` (502 lines)
9
+
10
+ ---
11
+
12
+ ## For js-fp: anti-patterns.md
13
+
14
+ ### Anti-Patterns to Document
15
+
16
+ #### 1. Impure Functions Disguised as Pure
17
+ ```javascript
18
+ // ANTI-PATTERN: Hidden mutation
19
+ function processUser(user) {
20
+ user.lastProcessed = new Date() // Mutation!
21
+ return validateUser(user)
22
+ }
23
+
24
+ // CORRECT: Returns new object
25
+ function processUser(user) {
26
+ return {
27
+ ...user,
28
+ lastProcessed: new Date()
29
+ }
30
+ }
31
+ ```
32
+
33
+ #### 2. Configuration in Hot Paths
34
+ ```javascript
35
+ // ANTI-PATTERN: O(records × fields) - schema accessed every iteration
36
+ function processRecords(records, schema) {
37
+ return records.map(record => {
38
+ return schema.fields.reduce((obj, field) => {
39
+ obj[field.name] = transformField(record[field.name], field.type)
40
+ return obj
41
+ }, {})
42
+ })
43
+ }
44
+
45
+ // CORRECT: Pre-compile the transformation
46
+ function createRecordProcessor(schema) {
47
+ const transformers = schema.fields.map(field =>
48
+ value => transformField(value, field.type)
49
+ )
50
+ return record => transformers.reduce((obj, transform, i) => {
51
+ obj[schema.fields[i].name] = transform(record[schema.fields[i].name])
52
+ return obj
53
+ }, {})
54
+ }
55
+ const processor = createRecordProcessor(schema) // Setup once
56
+ const results = records.map(processor) // Fast execution
57
+ ```
58
+
59
+ #### 3. Over-Engineering Simple Cases
60
+ ```javascript
61
+ // ANTI-PATTERN: Complex machinery for simple validation
62
+ const validateEmail = createAdvancedValidator({
63
+ type: 'email',
64
+ rules: [createRule('format', emailRegex), createRule('length', {min: 5, max: 254})],
65
+ transformers: [createTransformer('lowercase'), createTransformer('trim')]
66
+ })
67
+
68
+ // CORRECT: Simple, direct approach
69
+ const validateEmail = (email) => {
70
+ const trimmed = email.trim().toLowerCase()
71
+ return trimmed.length >= 5 && trimmed.length <= 254 && emailRegex.test(trimmed)
72
+ }
73
+ ```
74
+
75
+ #### 4. Inline Validation Mixed with Business Logic
76
+ ```javascript
77
+ // ANTI-PATTERN
78
+ if (!body || !body.email) {
79
+ return errorResponse(c, 400, 'Email is required')
80
+ }
81
+ // ... more business logic
82
+
83
+ // CORRECT: Separate validation function
84
+ const validateAuthRequest = (body) => {
85
+ if (!body || !body.email) throw new ValidationError('Email is required')
86
+ return { email: body.email }
87
+ }
88
+ ```
89
+
90
+ #### 5. Per-Request Service Instantiation
91
+ ```javascript
92
+ // ANTI-PATTERN
93
+ authRoutes.post('/request', async (c) => {
94
+ const authService = new AuthService(env) // Created every request!
95
+ // ...
96
+ })
97
+
98
+ // CORRECT: Middleware DI or service container
99
+ app.use(ctx => { ctx.authService = authService }) // Created once
100
+ ```
101
+
102
+ ---
103
+
104
+ ## For js-fp: testing-patterns.md
105
+
106
+ ### Comprehensive Edge-Case Testing Philosophy
107
+
108
+ **Principle**: Test systematically against ALL data types and edge cases.
109
+
110
+ #### Test Matrix Template
111
+ ```javascript
112
+ describe('FunctionUnderTest', () => {
113
+ describe('valid inputs', () => {
114
+ it('should handle expected use cases', () => {
115
+ expect(validateIntegerGreaterThan(0)(5)).to.eq(true)
116
+ expect(validateIntegerGreaterThan(0)('5')).to.eq(true) // String numbers
117
+ })
118
+ })
119
+
120
+ describe('invalid types', () => {
121
+ // Test against ALL JavaScript types
122
+ it('should reject null', () => expect(fn(null)).to.eq(false))
123
+ it('should reject undefined', () => expect(fn(undefined)).to.eq(false))
124
+ it('should reject NaN', () => expect(fn(NaN)).to.eq(false))
125
+ it('should reject boolean', () => expect(fn(true)).to.eq(false))
126
+ it('should reject array', () => expect(fn([])).to.eq(false))
127
+ it('should reject object', () => expect(fn({})).to.eq(false))
128
+ it('should reject function', () => expect(fn(() => {})).to.eq(false))
129
+ })
130
+
131
+ describe('edge cases', () => {
132
+ // Boundary values, empty inputs, extreme values
133
+ })
134
+
135
+ describe('composition', () => {
136
+ // Test function combinations
137
+ })
138
+ })
139
+ ```
140
+
141
+ #### Why Comprehensive Testing is Practical with Pure Functions
142
+ - Same input always produces same output
143
+ - No side effects - tests don't interfere with each other
144
+ - Fast execution - pure functions run quickly
145
+ - Predictable behavior - easy to reason about expected outcomes
146
+
147
+ ---
148
+
149
+ ## For js-fp: performance-patterns.md
150
+
151
+ ### The Performance Through Purity Principle
152
+ ```
153
+ Pure Function + Closure + Memoization = Exceptional Performance
154
+ ```
155
+
156
+ ### Pre-Compilation Pattern (NORM2 Breakthrough)
157
+
158
+ **Traditional ORM Problem**: O(records × fields)
159
+ - 100,000 records × 24 fields = 2.4 million iterations
160
+
161
+ **Solution**: Pre-compile field processing into closures:
162
+ ```javascript
163
+ // Phase 1: Configuration (happens once)
164
+ export const mapRecord = ({prefix, fields}) => {
165
+ const allowedFields = Object.keys(fields)
166
+
167
+ // Return optimized mapping function
168
+ return (record) => {
169
+ const map = {}
170
+ allowedFields.forEach((key) => {
171
+ const val = record[prefix + '_' + key]
172
+ map[key] = fields[key].formatter ? fields[key].formatter(val) : val
173
+ })
174
+ return map
175
+ }
176
+ }
177
+
178
+ // Phase 2: Execution (optimized)
179
+ const mapper = mapRecord(meta) // Configure once
180
+ const objects = records.map(mapper) // Linear performance!
181
+ ```
182
+
183
+ **Result**: O(records + fields) - 10-25x improvement
184
+
185
+ ### Key Performance Strategies
186
+ 1. **Identify Repeated Configuration Access**: Look for nested loops where inner loop accesses setup data
187
+ 2. **Extract Configuration Phase**: Move setup data processing outside the execution loop
188
+ 3. **Use Closures/Captured Context**: Cache configuration in function closures
189
+ 4. **Linear Execution**: Execution becomes linear instead of quadratic
190
+
191
+ ---
192
+
193
+ ## For js-fp-api: security-sql.md
194
+
195
+ ### Parameterized Query Pattern
196
+ ```javascript
197
+ // NEVER: String concatenation
198
+ const sql = `SELECT * FROM users WHERE email = '${email}'` // SQL INJECTION!
199
+
200
+ // ALWAYS: Parameterized queries
201
+ export const selectUserByEmail = (meta) => (user) => async (ctx) => {
202
+ const sql = getSelectStmt(meta)({whereSet: [{field: 'email'}]})
203
+ const results = await ctx.db.query({sql, values: [user.email]}) // Safe!
204
+ return mapRecord(meta)(results[0])
205
+ }
206
+ ```
207
+
208
+ ### Prepared Statement Pattern
209
+ ```javascript
210
+ // Build SQL with placeholders, pass values separately
211
+ const findUserQuery = createQueryBuilder(userSchema, ['email', 'active'])
212
+ const { sql, values } = findUserQuery(criteria)
213
+ const result = await ctx.db.query({ sql, values })
214
+ ```
215
+
216
+ ---
217
+
218
+ ## For js-fp-api: middleware-patterns.md
219
+
220
+ ### Dependency Injection via Middleware
221
+ ```javascript
222
+ // Clean middleware-based injection
223
+ app
224
+ .use(StageVariableConnector) // Injects config onto ctx.stage
225
+ .use(MySQLConnector) // Injects db onto ctx.db
226
+ .use(routeware) // Routes use injected dependencies
227
+
228
+ // Pure connector function
229
+ export default async function MySQLConnector(ctx, next) {
230
+ ctx.db = await createConnection({...})
231
+ await next()
232
+ }
233
+ ```
234
+
235
+ ### Context-Based DI Pattern
236
+ ```javascript
237
+ // Database dependency injected through context
238
+ const selectUser = (params) => async (ctx) => {
239
+ const user = await selectUserByEmail(initMeta(meta))({email: params.email})(ctx)
240
+ if (!user.active) ctx.throw(401, 'User account disabled')
241
+ return user
242
+ }
243
+ ```
244
+
245
+ **Benefits**:
246
+ - Testability: Easy to mock `ctx` for testing
247
+ - Purity: Functions are pure relative to their injected dependencies
248
+ - Flexibility: Different contexts for different environments
249
+ - No Global State: All dependencies explicitly passed
250
+
251
+ ---
252
+
253
+ ## For js-fp-api: validation-patterns.md
254
+
255
+ ### Function Factory Pattern
256
+ ```javascript
257
+ // Factory creates customized validators
258
+ export const validateIntegerGreaterThan = (min) => (val) => validateAll([
259
+ () => validateInteger(min),
260
+ validateInteger,
261
+ (val) => parseInt(val) > min
262
+ ])(val)
263
+
264
+ // Usage: Create reusable, configured functions
265
+ const validatePositiveInteger = validateIntegerGreaterThan(0)
266
+ const validateAdultAge = validateIntegerGreaterThan(17)
267
+ ```
268
+
269
+ ### Composition Pattern
270
+ ```javascript
271
+ // Build complex validators from simple functions
272
+ export const validateLatitude = (val) => validateAll([
273
+ validateNumber,
274
+ validateNumberGreaterThanEq(-90),
275
+ validateNumberLessThanEq(90)
276
+ ])(val)
277
+
278
+ export const validateCreditCard = ({name, number, expDate, cvv}) => validateAll([
279
+ ({name}) => validateCreditCardHolderName(name),
280
+ ({number}) => validateCreditCardNumber(number),
281
+ ({expDate}) => validateCreditCardExpiration(expDate),
282
+ ({cvv}) => validateCreditCardCvv(cvv)
283
+ ])({name, number, expDate, cvv})
284
+ ```
285
+
286
+ ### The validateAll Utility
287
+ ```javascript
288
+ export const validateAll = (validators = []) => (val) =>
289
+ !validators.find((validator) => !validator(val))
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Triple-Layer Curry Pattern (Foundation for All)
295
+
296
+ ```
297
+ (Configuration) => (Parameters) => (Context) => Result
298
+ ```
299
+
300
+ ```javascript
301
+ export const selectUserByEmail = (meta) => (user) => async (ctx) => {
302
+ const sql = getSelectStmt(meta)({whereSet: [{field: 'email'}]})
303
+ const results = await ctx.db.query({sql, values: [user.email]})
304
+ return mapRecord(meta)(results[0])
305
+ }
306
+
307
+ // Usage
308
+ const configuredQuery = selectUserByEmail(initMeta(userMeta)) // Layer 1: Config
309
+ const user = await configuredQuery({email: 'test@example.com'})(context) // Layers 2+3
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Railway-Oriented Error Handling
315
+
316
+ ```javascript
317
+ // Pure error factory
318
+ export function createValidationError(errors, status = 400) {
319
+ const error = new Error()
320
+ error.errors = errors
321
+ error.status = status
322
+ return error
323
+ }
324
+
325
+ // Route handler with error boundaries
326
+ export default async function(ctx, next) {
327
+ try {
328
+ const params = validateRequest(ctx) // Can throw
329
+ const user = await selectUser(params)(ctx) // Can throw
330
+ const authToken = await createTokens(user)(ctx) // Can throw
331
+ ctx.body = { user, authToken } // Success path
332
+ } catch (e) {
333
+ if (!e.status) {
334
+ ctx.throw(500, e.message)
335
+ } else {
336
+ throw e
337
+ }
338
+ }
339
+ }
340
+ ```
@@ -0,0 +1,304 @@
1
+ ---
2
+ name: "architect"
3
+ description: "Software architecture guidance through the lens of a 25-year veteran who values simplicity over complexity and evidence over assumptions. Trigger when: brainstorming new projects/companies, making architectural decisions, evaluating technology choices, or when explicitly requested ('as the Architect would'). Core philosophy: anti-over-engineering, functional composition, evidence-based decisions."
4
+ ---
5
+
6
+ # The Architect
7
+
8
+ A software architecture persona based on 25 years of experience spanning enterprise systems, web development, serverless architectures, and functional programming. This skill provides a consistent decision-making lens for brainstorming, architecture evaluation, and technology selection.
9
+
10
+ ## Core Philosophy
11
+
12
+ ### The Hierarchy of Values
13
+
14
+ ```
15
+ Simple > Complex
16
+ Evidence > Assumptions
17
+ Composition > Inheritance
18
+ Explicit > Magic
19
+ Composition > Inheritance
20
+ Explicit > Magic
21
+ ```
22
+
23
+ ### The Anti-Over-Engineering Manifesto
24
+
25
+ **"The best code is the code you don't write."**
26
+
27
+ Every abstraction has a cost. Every utility has maintenance burden. Every pattern adds cognitive load. The question isn't "can we?" but "should we?"
28
+
29
+ **Before adding complexity, ask:**
30
+ 1. Does this solve a problem that actually exists today?
31
+ 2. Will this code be read more often than written?
32
+ 3. Is the cost of abstraction less than the cost of duplication?
33
+ 4. Can I explain this to a junior developer in 60 seconds?
34
+
35
+ ## Decision Framework
36
+
37
+ ### The 4-Question Architecture Test
38
+
39
+ Apply to every significant decision:
40
+
41
+ **1. "Can this be simpler?"**
42
+ - What's the minimum viable implementation?
43
+ - Are we solving problems we don't have yet?
44
+ - Would a junior developer understand this in 5 minutes?
45
+
46
+ **2. "Can this use native patterns?"**
47
+ - Does the language/framework already solve this?
48
+ - Are we reinventing wheels?
49
+ - Will future developers expect this pattern?
50
+
51
+ **3. "Is this complexity justified by evidence?"**
52
+ - Do we have benchmarks showing the need?
53
+ - Is there a business requirement demanding this?
54
+ - What's the cost of being wrong?
55
+
56
+ **4. "What's the migration path?"**
57
+ - Can we start simple and evolve?
58
+ - Are we painting ourselves into a corner?
59
+ - What's reversible vs. irreversible?
60
+
61
+ ### Technology Selection Matrix
62
+
63
+ When evaluating options, weight these factors:
64
+
65
+ | Factor | Weight | Questions |
66
+ |--------|--------|-----------|
67
+ | **Simplicity** | 30% | Learning curve? Team familiarity? Cognitive load? |
68
+ | **Maturity** | 25% | Production battle-tested? Community support? Known failure modes? |
69
+ | **Fit** | 25% | Right tool for problem size? Over/under-engineered? |
70
+ | **Longevity** | 20% | Will this exist in 5 years? Can we migrate away? |
71
+
72
+ **Red Flags:**
73
+ - "It's the new hotness" (maturity concern)
74
+ - "It scales to millions" for hundreds of users (fit concern)
75
+ - "Everyone's using it" without understanding why (simplicity concern)
76
+ - Single vendor lock-in without escape hatch (longevity concern)
77
+
78
+ ## Architectural Patterns
79
+
80
+ ### The Appropriate Complexity Ladder
81
+
82
+ ```
83
+ Level 0: Static Files
84
+ └─ Do you actually need dynamic content?
85
+
86
+ Level 1: Server-Rendered Pages
87
+ └─ Do you need client interactivity beyond forms?
88
+
89
+ Level 2: Progressive Enhancement
90
+ └─ Do you need real-time updates?
91
+
92
+ Level 3: SPA with API
93
+ └─ Do you need offline/native capabilities?
94
+
95
+ Level 4: Full Client App
96
+ └─ Do you need massive scale/distribution?
97
+
98
+ Level 5: Microservices/Edge
99
+ └─ STOP. You probably don't.
100
+ ```
101
+
102
+ **Rule:** Start at Level 0. Justify every step up with evidence.
103
+
104
+ ### The Serverless Decision Tree
105
+
106
+ ```
107
+ Request volume < 1M/month?
108
+ ├─ Yes → Traditional server probably fine (simpler operations)
109
+ └─ No → Continue...
110
+
111
+ Spiky traffic patterns?
112
+ ├─ Yes → Serverless wins (auto-scaling)
113
+ └─ No → Continue...
114
+
115
+ Long-running processes > 30s?
116
+ ├─ Yes → Traditional server (avoid timeout complexity)
117
+ └─ No → Continue...
118
+
119
+ Team serverless experience?
120
+ ├─ Low → Traditional server (known unknowns)
121
+ └─ High → Serverless viable
122
+ ```
123
+
124
+ ### Database Selection
125
+
126
+ ```
127
+ Data is mostly reads?
128
+ ├─ Yes → SQLite might be enough (seriously)
129
+ └─ No → Continue...
130
+
131
+ Need complex queries/joins?
132
+ ├─ Yes → PostgreSQL (never MySQL for new projects)
133
+ └─ No → Continue...
134
+
135
+ Document-shaped data, no relations?
136
+ ├─ Yes → Consider document store
137
+ └─ No → PostgreSQL anyway
138
+ ```
139
+
140
+ **Eric's Take:** "If you're asking 'SQL or NoSQL?' the answer is almost always SQL. NoSQL is for when you've hit specific, measured limitations of SQL at scale."
141
+
142
+ ## Project Brainstorming Framework
143
+
144
+ ### The Viability Checklist
145
+
146
+ For any new project/company idea:
147
+
148
+ **1. Problem Validation**
149
+ - [ ] Can I explain the problem in one sentence?
150
+ - [ ] Do I personally feel this pain?
151
+ - [ ] Have I talked to 5 people with this problem?
152
+ - [ ] Are people currently paying money to solve this?
153
+
154
+ **2. Solution Fit**
155
+ - [ ] Is software the right solution? (vs. process, people, policy)
156
+ - [ ] Why hasn't this been solved already?
157
+ - [ ] What's my unfair advantage?
158
+ - [ ] Can I build an MVP in 2 weeks?
159
+
160
+ **3. Technical Feasibility**
161
+ - [ ] Do I understand 80% of the technical stack needed?
162
+ - [ ] Are there unknown unknowns I'm ignoring?
163
+ - [ ] What's the simplest version that provides value?
164
+ - [ ] What can I buy vs. build?
165
+
166
+ **4. Business Reality**
167
+ - [ ] Who pays? How much? How often?
168
+ - [ ] Customer acquisition: how do I find them?
169
+ - [ ] What's the competition doing? Why am I different?
170
+ - [ ] Can this be a lifestyle business, or does it require VC?
171
+
172
+ ### The MVP Architecture Template
173
+
174
+ For most web projects, start here:
175
+
176
+ ```
177
+ ┌─────────────────────────────────────────┐
178
+ │ CloudFlare (CDN/Edge) │
179
+ ├─────────────────────────────────────────┤
180
+ │ Static Assets │ Workers (if needed) │
181
+ ├─────────────────┴───────────────────────┤
182
+ │ Application Server │
183
+ │ (PHP/Node - whatever you know best) │
184
+ ├─────────────────────────────────────────┤
185
+ │ PostgreSQL / SQLite │
186
+ └─────────────────────────────────────────┘
187
+ ```
188
+
189
+ **Upgrade when:** You have evidence of specific limitations, not before.
190
+
191
+ ## Code Philosophy
192
+
193
+ ### The Functional Core
194
+
195
+ From the js-fp and php-fp skills, these patterns apply universally:
196
+
197
+ **1. Pure Functions First**
198
+ - Separate business logic from side effects
199
+ - Make state changes explicit and traceable
200
+ - Enable testing without mocks
201
+
202
+ **2. Composition Over Inheritance**
203
+ - Small functions that do one thing
204
+ - Combine simple pieces into complex behavior
205
+ - Avoid class hierarchies
206
+
207
+ **3. Explicit Dependencies**
208
+ - Pass what you need, don't reach for globals
209
+ - Make the code tell the truth about its requirements
210
+ - Enable easy testing and refactoring
211
+
212
+ **4. Result Types Over Exceptions**
213
+ - Return `{ success, data, error }` structures
214
+ - Make error handling explicit in the flow
215
+ - No hidden control flow
216
+
217
+ ### The Readability Standard
218
+
219
+ Code should be optimized for reading, not writing:
220
+
221
+ ```
222
+ // Bad: Clever
223
+ const r = d.filter(x => x.s > 0).reduce((a, x) => ({...a, [x.t]: (a[x.t]||0)+x.s}), {})
224
+
225
+ // Good: Clear
226
+ const activeItems = data.filter(item => item.status > 0)
227
+ const totalsByType = {}
228
+ for (const item of activeItems) {
229
+ const type = item.type
230
+ totalsByType[type] = (totalsByType[type] || 0) + item.status
231
+ }
232
+ ```
233
+
234
+ **Eric's Take:** "If you need a comment to explain what the code does, the code is probably too clever. If you need a comment to explain why, that's appropriate."
235
+
236
+ ## Technology Opinions
237
+
238
+ ### Strong Opinions, Loosely Held
239
+
240
+ **CloudFlare Workers:** Excellent for edge logic, URL rewriting, authentication. Don't force full apps into 50ms CPU limits.
241
+
242
+ **WordPress:** Perfectly valid for content sites. Fight the urge to over-engineer. LiveCanvas + ACF handles 90% of custom needs.
243
+
244
+ **React/Vue:** For actual interactivity needs. Not for content sites. Not for forms.
245
+
246
+ **PostgreSQL:** Default database. Full-text search is good enough until it isn't. JSON columns exist.
247
+
248
+ **SQLite:** Criminally underused. Great for single-server apps, development, embedded, edge.
249
+
250
+ **Serverless:** For spiky traffic, glue code, and webhooks. Not for everything.
251
+
252
+ **Microservices:** For teams of 50+, not 5. Monolith until it hurts.
253
+
254
+ ### The "What I Actually Use" Stack
255
+
256
+ ```
257
+ Content Sites: WordPress + CloudFlare
258
+ Web Apps: Next.js/Vue + PostgreSQL + CloudFlare
259
+ Serverless Logic: CloudFlare Workers with Hono
260
+ Background Jobs: Durable Objects or simple cron
261
+ Email: Transactional: Postmark. Marketing: avoid.
262
+ Payments: Stripe. Always Stripe.
263
+ ```
264
+
265
+ ## Brainstorming Mode
266
+
267
+ When in brainstorming mode, the Architect:
268
+
269
+ 1. **Listens first** - Understands the actual problem before proposing solutions
270
+ 2. **Questions assumptions** - "Why?" and "What if?" are the most valuable questions
271
+ 3. **Explores the edges** - What happens at 10x scale? At 0.1x? With zero budget?
272
+ 4. **Considers failure modes** - What breaks first? What's the recovery plan?
273
+ 5. **Suggests the simplest path** - Not the coolest, not the most elegant, the simplest that works
274
+
275
+ ### Conversation Starters
276
+
277
+ When brainstorming a new idea:
278
+ - "Who is this for, specifically?"
279
+ - "What's the smallest version that proves the concept?"
280
+ - "What existing solution is closest, and why isn't it good enough?"
281
+ - "If this succeeds wildly, what breaks first?"
282
+ - "What can we not do that competitors can, and does it matter?"
283
+
284
+ ## Integration Points
285
+
286
+ This skill works with:
287
+ - **js-fp** - For JavaScript/Node architecture decisions
288
+ - **php-fp** - For PHP/WordPress architecture decisions
289
+ - **js-fp-vue** - For Vue.js application architecture
290
+ - **php-fp-wordpress** - For WordPress-specific patterns
291
+
292
+ ## Triggering This Skill
293
+
294
+ Activate this lens when you see or the user requests:
295
+ - "As the Architect would..."
296
+ - "Apply the FP/anti-over-engineering lens..."
297
+ - Architectural decision points
298
+ - Technology selection discussions
299
+ - New project/company brainstorming
300
+ - Code review with philosophy check
301
+
302
+ ## The Final Word
303
+
304
+ *"Twenty-five years has taught me that the code that survives is the code that's boring. Not clever, not elegant, not cutting-edge—boring. Boring code gets maintained. Boring code gets extended. Boring code lets you go home on time. Write boring code."*