sublation-os 1.0.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 (52) hide show
  1. package/.claude/agents/sublation-os/implementation-verifier.md +141 -0
  2. package/.claude/agents/sublation-os/implementer-v2.md +542 -0
  3. package/.claude/agents/sublation-os/implementer.md +53 -0
  4. package/.claude/agents/sublation-os/product-planner.md +210 -0
  5. package/.claude/agents/sublation-os/spec-initializer.md +92 -0
  6. package/.claude/agents/sublation-os/spec-shaper.md +300 -0
  7. package/.claude/agents/sublation-os/spec-writer.md +139 -0
  8. package/.claude/agents/sublation-os/tasks-list-creator.md +236 -0
  9. package/.claude/commands/sublation-os/address-comments.md +74 -0
  10. package/.claude/commands/sublation-os/commit-message.md +84 -0
  11. package/.claude/commands/sublation-os/create-tasks.md +40 -0
  12. package/.claude/commands/sublation-os/implement-tasks.md +55 -0
  13. package/.claude/commands/sublation-os/investigate.md +164 -0
  14. package/.claude/commands/sublation-os/learn.md +131 -0
  15. package/.claude/commands/sublation-os/optimise.md +108 -0
  16. package/.claude/commands/sublation-os/plan-product.md +36 -0
  17. package/.claude/commands/sublation-os/pr-description.md +15 -0
  18. package/.claude/commands/sublation-os/recall.md +114 -0
  19. package/.claude/commands/sublation-os/review-v2.md +701 -0
  20. package/.claude/commands/sublation-os/review.md +12 -0
  21. package/.claude/commands/sublation-os/shape-spec.md +52 -0
  22. package/.claude/commands/sublation-os/test-plan.md +12 -0
  23. package/.claude/commands/sublation-os/write-spec.md +22 -0
  24. package/.sublation-os/config.yml +13 -0
  25. package/.sublation-os/memory/MEMORY_GUIDE.md +344 -0
  26. package/.sublation-os/memory/architecture-lessons.md +41 -0
  27. package/.sublation-os/memory/backend-lessons.md +41 -0
  28. package/.sublation-os/memory/frontend-lessons.md +41 -0
  29. package/.sublation-os/memory/general-lessons.md +41 -0
  30. package/.sublation-os/memory/index.md +94 -0
  31. package/.sublation-os/memory/learned-lessons.md +75 -0
  32. package/.sublation-os/memory/testing-lessons.md +41 -0
  33. package/.sublation-os/specs/.gitkeep +0 -0
  34. package/.sublation-os/standards/backend/api.md +10 -0
  35. package/.sublation-os/standards/backend/migrations.md +9 -0
  36. package/.sublation-os/standards/backend/models.md +10 -0
  37. package/.sublation-os/standards/backend/queries.md +9 -0
  38. package/.sublation-os/standards/frontend/accessibility.md +10 -0
  39. package/.sublation-os/standards/frontend/components.md +11 -0
  40. package/.sublation-os/standards/frontend/css.md +7 -0
  41. package/.sublation-os/standards/frontend/responsive.md +11 -0
  42. package/.sublation-os/standards/global/coding-style.md +10 -0
  43. package/.sublation-os/standards/global/commenting.md +5 -0
  44. package/.sublation-os/standards/global/conventions.md +11 -0
  45. package/.sublation-os/standards/global/error-handling.md +9 -0
  46. package/.sublation-os/standards/global/tech-stack.md +31 -0
  47. package/.sublation-os/standards/global/validation.md +11 -0
  48. package/.sublation-os/standards/testing/test-writing.md +9 -0
  49. package/LICENSE +21 -0
  50. package/README.md +155 -0
  51. package/bin/install.js +137 -0
  52. package/package.json +43 -0
@@ -0,0 +1,701 @@
1
+ ---
2
+ argument-hint: [file-path or directory]
3
+ description: Comprehensive code review using Chain of Thought analysis and ReAct investigation
4
+ ---
5
+
6
+ You are conducting a comprehensive code review using **Chain of Thought (CoT)** reasoning for systematic analysis and **ReAct** for investigating suspicious patterns.
7
+
8
+ ## Code to Review
9
+ $message
10
+
11
+ ---
12
+
13
+ ## Review Process
14
+
15
+ ### Phase 1: Understanding (Chain of Thought)
16
+
17
+ Before identifying issues, deeply understand the code.
18
+
19
+ **Think through these questions systematically:**
20
+
21
+ 1. **Purpose**: What is this code supposed to do?
22
+ 2. **Context**: How does it fit into the larger system?
23
+ 3. **Complexity**: What are the most complex parts?
24
+ 4. **Critical paths**: What are the high-risk areas?
25
+ 5. **Stakeholders**: Who uses or depends on this code?
26
+
27
+ **Document your understanding:**
28
+ ```markdown
29
+ ## Code Understanding
30
+
31
+ **Purpose**: {1-2 sentence summary}
32
+
33
+ **Key Components**:
34
+ - {Component 1}: {What it does}
35
+ - {Component 2}: {What it does}
36
+
37
+ **Critical Paths**:
38
+ - {Path 1}: {Why it's critical}
39
+ - {Path 2}: {Why it's critical}
40
+
41
+ **Complexity Hotspots**:
42
+ - {Location 1}: {Why it's complex}
43
+ ```
44
+
45
+ ---
46
+
47
+ ### Phase 2: Load Context
48
+
49
+ Before reviewing, load relevant context:
50
+
51
+ #### User Standards
52
+ Read applicable standards from `.sublation-os/standards/`:
53
+ - For backend code: Read `backend/*.md`
54
+ - For frontend code: Read `frontend/*.md`
55
+ - For all code: Read `global/*.md`
56
+ - For tests: Read `testing/*.md`
57
+
58
+ #### Past Learnings
59
+ Read relevant memory files from `.sublation-os/memory/`:
60
+ - Start with `index.md` to identify relevant categories
61
+ - Read category-specific lessons (backend/frontend/testing/architecture)
62
+ - Look for:
63
+ - Known anti-patterns in this codebase
64
+ - Preferred patterns and conventions
65
+ - Security gotchas
66
+ - Performance lessons
67
+
68
+ ---
69
+
70
+ ### Phase 3: Multi-Dimensional Analysis (Chain of Thought)
71
+
72
+ Analyze the code across multiple dimensions. For each dimension, **think step by step** through potential issues.
73
+
74
+ #### Dimension 1: Correctness 🎯
75
+
76
+ **THINK**: Does this code do what it's supposed to do?
77
+
78
+ Analyze systematically:
79
+ - **Logic correctness**: Are conditions correct? Any off-by-one errors?
80
+ - **Edge cases**: What happens with null, empty, or unexpected inputs?
81
+ - **Error handling**: Are errors caught and handled appropriately?
82
+ - **Data integrity**: Could data be corrupted or lost?
83
+ - **Race conditions**: Any concurrency issues?
84
+
85
+ **For each issue found, use ReAct to investigate:**
86
+
87
+ **THOUGHT**: This loop condition looks suspicious - it might skip the last element
88
+
89
+ **ACTION**: Check the loop boundaries and test with example values
90
+
91
+ **OBSERVATION**: Confirmed - loop uses `<` instead of `<=`, missing last item
92
+
93
+ ---
94
+
95
+ #### Dimension 2: Security 🔒
96
+
97
+ **THINK**: What could an attacker exploit?
98
+
99
+ Use the STRIDE threat model:
100
+ - **Spoofing**: Can authentication be bypassed?
101
+ - **Tampering**: Can data be modified maliciously?
102
+ - **Repudiation**: Can actions be denied?
103
+ - **Information Disclosure**: Can sensitive data leak?
104
+ - **Denial of Service**: Can the service be disrupted?
105
+ - **Elevation of Privilege**: Can permissions be bypassed?
106
+
107
+ **Common vulnerabilities to check:**
108
+ - SQL Injection (unsanitized queries)
109
+ - XSS (unescaped output)
110
+ - CSRF (missing tokens)
111
+ - Authentication bypass
112
+ - Authorization flaws
113
+ - Insecure dependencies
114
+ - Hardcoded secrets
115
+ - Path traversal
116
+ - Command injection
117
+ - Insecure deserialization
118
+
119
+ **For each security concern:**
120
+
121
+ **THOUGHT**: This SQL query uses string concatenation - potential SQL injection
122
+
123
+ **ACTION**: Search codebase for the sanitization pattern used elsewhere
124
+
125
+ **OBSERVATION**: Other queries use parameterized queries - this should too
126
+
127
+ ---
128
+
129
+ #### Dimension 3: Performance ⚡
130
+
131
+ **THINK**: Where are the bottlenecks?
132
+
133
+ Analyze systematically:
134
+ - **Algorithmic complexity**: O(n²) where O(n) is possible?
135
+ - **Database queries**: N+1 queries? Missing indexes?
136
+ - **Caching**: Could results be cached?
137
+ - **Memory usage**: Unnecessary allocations? Memory leaks?
138
+ - **Network calls**: Too many API requests? Parallelizable?
139
+ - **Blocking operations**: Synchronous where async would help?
140
+
141
+ **For each performance issue:**
142
+
143
+ **THOUGHT**: This loads all records into memory - could be 100k+ rows
144
+
145
+ **ACTION**: Check if pagination or streaming is used elsewhere
146
+
147
+ **OBSERVATION**: Similar endpoints use cursor pagination - apply here
148
+
149
+ ---
150
+
151
+ #### Dimension 4: Maintainability 🔧
152
+
153
+ **THINK**: How hard is this to understand and modify?
154
+
155
+ Evaluate:
156
+ - **Readability**: Is the code clear? Are names descriptive?
157
+ - **Complexity**: Are functions too long? Too many branches?
158
+ - **Duplication**: Is code repeated unnecessarily?
159
+ - **Documentation**: Are complex parts explained?
160
+ - **Consistency**: Does it follow codebase conventions?
161
+ - **Dependencies**: Are they necessary? Up to date?
162
+ - **Technical debt**: What shortcuts were taken?
163
+
164
+ **Apply codebase patterns:**
165
+
166
+ **THOUGHT**: This function is 300 lines - violates the codebase pattern
167
+
168
+ **ACTION**: Check past learnings for preferred function size
169
+
170
+ **OBSERVATION**: Memory system shows 50-line limit with extraction pattern
171
+
172
+ ---
173
+
174
+ #### Dimension 5: Testing 🧪
175
+
176
+ **THINK**: How testable is this code? What's the test coverage?
177
+
178
+ Analyze:
179
+ - **Testability**: Are dependencies injectable? Functions pure?
180
+ - **Coverage**: Are critical paths tested?
181
+ - **Test quality**: Do tests verify behavior or implementation?
182
+ - **Edge cases**: Are error conditions tested?
183
+ - **Brittleness**: Will tests break with minor refactoring?
184
+
185
+ **Check against standards:**
186
+
187
+ **THOUGHT**: No tests found for this critical business logic
188
+
189
+ **ACTION**: Read testing standards to see requirements
190
+
191
+ **OBSERVATION**: Standards require >80% coverage for services - needs tests
192
+
193
+ ---
194
+
195
+ #### Dimension 6: Architecture 🏗️
196
+
197
+ **THINK**: Does this follow good design principles?
198
+
199
+ Evaluate:
200
+ - **SOLID principles**: Single responsibility, etc.
201
+ - **Separation of concerns**: Are layers properly separated?
202
+ - **Coupling**: Is code tightly coupled?
203
+ - **Cohesion**: Do related things belong together?
204
+ - **Patterns**: Are appropriate patterns used?
205
+ - **Extensibility**: Easy to extend without modification?
206
+
207
+ **Consider past learnings:**
208
+
209
+ **THOUGHT**: This controller has database access - breaks layering
210
+
211
+ **ACTION**: Check architecture lessons for preferred pattern
212
+
213
+ **OBSERVATION**: Codebase uses repository pattern - should apply here
214
+
215
+ ---
216
+
217
+ #### Dimension 7: Standards Compliance 📋
218
+
219
+ **THINK**: Does this follow the user's documented standards?
220
+
221
+ Check against `.sublation-os/standards/`:
222
+ - **Naming conventions**: Variables, functions, files
223
+ - **Code style**: Indentation, formatting, structure
224
+ - **Error handling**: Patterns used
225
+ - **Validation**: Input validation approach
226
+ - **API design**: REST conventions, response formats
227
+ - **Component structure**: File organization
228
+
229
+ **Flag violations:**
230
+
231
+ **THOUGHT**: Error handling doesn't match standards
232
+
233
+ **ACTION**: Read global/error-handling.md for requirements
234
+
235
+ **OBSERVATION**: Standards require try-catch with structured logging - missing
236
+
237
+ ---
238
+
239
+ ### Phase 4: Pattern Investigation (ReAct)
240
+
241
+ For any suspicious patterns, investigate systematically:
242
+
243
+ **Example:**
244
+
245
+ **THOUGHT**: I see several async operations that could run in parallel but are sequential
246
+
247
+ **ACTION**: Calculate potential time savings - 3 serial 100ms calls = 300ms
248
+
249
+ **OBSERVATION**: Could reduce to 100ms with Promise.all() - significant improvement
250
+
251
+ **THOUGHT**: Before recommending, check if there are dependencies between calls
252
+
253
+ **ACTION**: Analyze data flow between the async operations
254
+
255
+ **OBSERVATION**: No dependencies found - safe to parallelize
256
+
257
+ ---
258
+
259
+ ## Review Report Structure
260
+
261
+ Generate a comprehensive report following this structure:
262
+
263
+ ```markdown
264
+ # Code Review Report
265
+
266
+ **Reviewed**: {file paths}
267
+ **Date**: {current date}
268
+ **Reviewer**: review-v2 (AI-assisted)
269
+ **Lines of Code**: {approximate count}
270
+
271
+ ---
272
+
273
+ ## Executive Summary
274
+
275
+ {2-3 sentence overview of code quality and key findings}
276
+
277
+ **Overall Assessment**:
278
+ - Correctness: ⭐⭐⭐⭐⭐ (5/5)
279
+ - Security: ⭐⭐⭐⭐⬜ (4/5)
280
+ - Performance: ⭐⭐⭐⬜⬜ (3/5)
281
+ - Maintainability: ⭐⭐⭐⭐⬜ (4/5)
282
+ - Testing: ⭐⭐⬜⬜⬜ (2/5)
283
+ - Architecture: ⭐⭐⭐⭐⭐ (5/5)
284
+ - Standards: ⭐⭐⭐⭐⬜ (4/5)
285
+
286
+ **Recommendation**: ✅ Approve with changes | ⚠️ Needs significant work | ❌ Major issues
287
+
288
+ ---
289
+
290
+ ## Critical Issues 🔴
291
+
292
+ Issues that MUST be fixed before merging.
293
+
294
+ ### Issue 1: SQL Injection Vulnerability
295
+ **Location**: `src/controllers/userController.js:45`
296
+ **Severity**: 🔴 Critical - Security
297
+ **Category**: Security - SQL Injection
298
+
299
+ **Problem**:
300
+ ```javascript
301
+ // ❌ CURRENT (Line 45)
302
+ const query = `SELECT * FROM users WHERE id = ${userId}`;
303
+ db.query(query);
304
+ ```
305
+
306
+ **Why this is critical**:
307
+ An attacker can inject SQL through the userId parameter, potentially accessing or deleting all database records.
308
+
309
+ **Recommended fix**:
310
+ ```javascript
311
+ // ✅ RECOMMENDED
312
+ const query = 'SELECT * FROM users WHERE id = ?';
313
+ db.query(query, [userId]);
314
+ ```
315
+
316
+ **Reasoning**: Parameterized queries prevent SQL injection by treating input as data, not executable code. This pattern is used throughout the codebase (see src/models/User.js:23).
317
+
318
+ **THOUGHT process**: Found string concatenation in SQL query → Checked if input is sanitized → Not sanitized → Checked codebase for correct pattern → Found parameterized query pattern.
319
+
320
+ ---
321
+
322
+ ### Issue 2: {Next critical issue}
323
+ {Repeat structure}
324
+
325
+ ---
326
+
327
+ ## High Priority Issues 🟠
328
+
329
+ Issues that should be fixed soon.
330
+
331
+ ### Issue 1: N+1 Query Problem
332
+ **Location**: `src/services/orderService.js:78-85`
333
+ **Severity**: 🟠 High - Performance
334
+ **Category**: Performance - Database
335
+
336
+ **Problem**:
337
+ ```javascript
338
+ // ❌ CURRENT (Lines 78-85)
339
+ const orders = await Order.findAll();
340
+ for (const order of orders) {
341
+ order.items = await OrderItem.findByOrderId(order.id); // N queries
342
+ }
343
+ ```
344
+
345
+ **Impact**: With 1000 orders, this executes 1001 queries (1 + 1000). Response time: ~5-10 seconds.
346
+
347
+ **Recommended fix**:
348
+ ```javascript
349
+ // ✅ RECOMMENDED
350
+ const orders = await Order.findAll({
351
+ include: [{
352
+ model: OrderItem,
353
+ as: 'items'
354
+ }]
355
+ });
356
+ ```
357
+
358
+ **Performance gain**: Reduces to 1 query. Expected response time: ~50-100ms (50-100x improvement).
359
+
360
+ **Reasoning**: This ORM supports eager loading. Pattern used in src/services/productService.js:45. Past learnings (backend-lessons.md Entry 12) specifically flag N+1 queries as common problem.
361
+
362
+ **Alternative solution**: Could use a single JOIN query if ORM isn't flexible enough, but ORM solution is cleaner.
363
+
364
+ ---
365
+
366
+ ### Issue 2: {Next high priority issue}
367
+ {Repeat structure}
368
+
369
+ ---
370
+
371
+ ## Medium Priority Issues 🟡
372
+
373
+ Issues that improve quality but aren't urgent.
374
+
375
+ ### Issue 1: Function Too Complex
376
+ **Location**: `src/utils/validator.js:120-280`
377
+ **Severity**: 🟡 Medium - Maintainability
378
+ **Category**: Maintainability - Complexity
379
+
380
+ **Problem**:
381
+ - Function is 160 lines long
382
+ - Cyclomatic complexity: ~25 (threshold: 10)
383
+ - Difficult to test and understand
384
+
385
+ **Reasoning**: This violates the codebase convention (past learnings show 50-line function limit) and makes future modifications risky.
386
+
387
+ **Recommended refactoring**:
388
+ ```javascript
389
+ // ✅ SPLIT INTO FOCUSED FUNCTIONS
390
+ function validateUser(data) {
391
+ validateRequiredFields(data);
392
+ validateEmail(data.email);
393
+ validatePassword(data.password);
394
+ validateAge(data.age);
395
+ return true;
396
+ }
397
+
398
+ function validateRequiredFields(data) {
399
+ const required = ['email', 'password', 'name'];
400
+ for (const field of required) {
401
+ if (!data[field]) throw new Error(`${field} is required`);
402
+ }
403
+ }
404
+ ```
405
+
406
+ **Benefits**:
407
+ - Each function has single responsibility
408
+ - Easier to test individual validators
409
+ - More reusable
410
+ - Clearer intent
411
+
412
+ ---
413
+
414
+ ## Low Priority Issues 🟢
415
+
416
+ Nice-to-have improvements.
417
+
418
+ ### Issue 1: Inconsistent Naming
419
+ **Location**: `src/components/UserProfile.jsx`
420
+ **Severity**: 🟢 Low - Standards
421
+ **Category**: Standards - Naming conventions
422
+
423
+ **Problem**: Mix of camelCase and snake_case for variable names.
424
+
425
+ **Current**: `user_name`, `userId`, `profile_data`
426
+ **Standard**: All camelCase (per `standards/global/coding-style.md`)
427
+ **Recommended**: `userName`, `userId`, `profileData`
428
+
429
+ ---
430
+
431
+ ## Positive Observations ✅
432
+
433
+ Things done well that should be maintained:
434
+
435
+ 1. **Excellent error handling** (lines 23-35): Comprehensive try-catch with structured logging
436
+ 2. **Good separation of concerns**: Controller → Service → Repository pattern followed
437
+ 3. **Clear naming**: Functions and variables have descriptive names
438
+ 4. **Type safety**: Good use of TypeScript types (if applicable)
439
+ 5. **Documentation**: Complex algorithms are well-commented
440
+
441
+ ---
442
+
443
+ ## Standards Compliance Checklist
444
+
445
+ Against `.sublation-os/standards/`:
446
+
447
+ - ✅ **Coding style**: Follows indentation and formatting rules
448
+ - ✅ **Naming conventions**: Mostly consistent (minor issues noted above)
449
+ - ❌ **Error handling**: Missing structured logging in error paths
450
+ - ✅ **API design**: RESTful conventions followed
451
+ - ⚠️ **Testing**: Insufficient test coverage (45% vs 80% requirement)
452
+ - ✅ **Documentation**: Adequate inline comments
453
+ - ✅ **Validation**: Input validation present
454
+
455
+ ---
456
+
457
+ ## Past Learnings Applied
458
+
459
+ From `.sublation-os/memory/`:
460
+
461
+ ✅ **Applied**: Entry 8 (backend-lessons) - Used repository pattern correctly
462
+ ✅ **Applied**: Entry 15 (frontend-lessons) - Followed component composition pattern
463
+ ❌ **Missed**: Entry 12 (backend-lessons) - N+1 query antipattern present (flagged above)
464
+ ❌ **Missed**: Entry 23 (testing-lessons) - Missing edge case tests
465
+
466
+ ---
467
+
468
+ ## Testing Gaps
469
+
470
+ **Current coverage**: ~45% (estimated from test files)
471
+ **Required coverage**: 80% (per `standards/testing/test-writing.md`)
472
+
473
+ **Missing tests**:
474
+ 1. Edge case: Empty array input to `processOrders()`
475
+ 2. Error case: Network failure in API call
476
+ 3. Validation: Invalid email format handling
477
+ 4. Performance: Large dataset handling (1000+ items)
478
+
479
+ **Recommended test additions**:
480
+ ```javascript
481
+ // High priority test to add
482
+ describe('processOrders edge cases', () => {
483
+ it('should handle empty order array', async () => {
484
+ const result = await processOrders([]);
485
+ expect(result).toEqual([]);
486
+ });
487
+
488
+ it('should handle API failure gracefully', async () => {
489
+ mockApi.get.mockRejectedValue(new Error('Network error'));
490
+ await expect(processOrders(validOrders))
491
+ .rejects.toThrow('Failed to process orders');
492
+ });
493
+ });
494
+ ```
495
+
496
+ ---
497
+
498
+ ## Architecture Assessment
499
+
500
+ **Pattern analysis**:
501
+ - ✅ **Layered architecture**: Clear separation (Controller/Service/Repository)
502
+ - ✅ **Dependency injection**: Services injected, testable
503
+ - ⚠️ **Single Responsibility**: Some functions do too much (noted above)
504
+ - ✅ **DRY principle**: Minimal duplication
505
+ - ❌ **Open/Closed**: Some classes hard to extend (tight coupling)
506
+
507
+ **Recommendations**:
508
+ 1. Extract interface for OrderService to enable easier mocking
509
+ 2. Consider strategy pattern for different payment processors
510
+ 3. Use factory pattern for report generation (currently hardcoded)
511
+
512
+ ---
513
+
514
+ ## Security Assessment
515
+
516
+ **Vulnerabilities found**: 1 critical (SQL injection), 0 high, 2 medium
517
+
518
+ **Security checklist**:
519
+ - ❌ **Input validation**: Missing sanitization in userId parameter (CRITICAL)
520
+ - ✅ **Authentication**: JWT properly verified
521
+ - ✅ **Authorization**: Role checks present
522
+ - ⚠️ **Data exposure**: Sensitive fields (password hash) returned in API response
523
+ - ✅ **Dependencies**: No known vulnerabilities (checked npm audit)
524
+ - ✅ **Secrets**: No hardcoded credentials
525
+ - ✅ **HTTPS**: Enforced for all endpoints
526
+
527
+ ---
528
+
529
+ ## Performance Assessment
530
+
531
+ **Bottlenecks identified**:
532
+ 1. 🟠 N+1 query in order loading (~5s response time)
533
+ 2. 🟡 Synchronous file operations blocking event loop
534
+ 3. 🟡 Large payload (2MB) - no pagination
535
+
536
+ **Performance recommendations**:
537
+ 1. Fix N+1 query (50-100x improvement)
538
+ 2. Use async file operations or worker threads
539
+ 3. Implement cursor pagination for large datasets
540
+ 4. Add caching for frequently accessed data (e.g., user profiles)
541
+
542
+ **Estimated impact**: Fixing top 2 issues could reduce response time from ~6s to ~200ms.
543
+
544
+ ---
545
+
546
+ ## Refactoring Opportunities
547
+
548
+ **Technical debt identified**:
549
+
550
+ 1. **Extract utility functions**: Date formatting code repeated 5 times
551
+ 2. **Simplify complex conditionals**: Lines 145-180 have deeply nested if statements
552
+ 3. **Remove dead code**: Commented-out code at lines 200-220
553
+ 4. **Upgrade patterns**: Still using callbacks where async/await would be clearer
554
+
555
+ **Priority**: Medium (not blocking, but improves maintainability)
556
+
557
+ ---
558
+
559
+ ## Action Items
560
+
561
+ ### Must Do (Before Merge) 🔴
562
+ 1. [ ] Fix SQL injection vulnerability (Line 45)
563
+ 2. [ ] {Other critical issues}
564
+
565
+ ### Should Do (This Sprint) 🟠
566
+ 1. [ ] Fix N+1 query performance issue
567
+ 2. [ ] Add missing error handling with structured logging
568
+ 3. [ ] Increase test coverage to 80%
569
+
570
+ ### Nice to Have (Backlog) 🟡🟢
571
+ 1. [ ] Refactor complex validator function
572
+ 2. [ ] Standardize variable naming
573
+ 3. [ ] Add caching layer
574
+ 4. [ ] Extract repeated utility functions
575
+
576
+ ---
577
+
578
+ ## Recommendations for Developer
579
+
580
+ **Strengths to maintain**:
581
+ - Good architectural layering
582
+ - Clear naming and documentation
583
+ - Proper use of design patterns
584
+
585
+ **Areas for improvement**:
586
+ - Security awareness (parameterized queries)
587
+ - Performance optimization (database query patterns)
588
+ - Test coverage (aim for 80%+)
589
+
590
+ **Learning resources**:
591
+ - SQL injection prevention: [OWASP guide]
592
+ - N+1 queries: See `backend-lessons.md` Entry 12
593
+ - Testing patterns: See `testing-lessons.md`
594
+
595
+ ---
596
+
597
+ ## Next Review
598
+
599
+ **When to review again**:
600
+ - After critical issues are fixed
601
+ - Before merging to main branch
602
+ - After adding missing tests
603
+
604
+ **Focus areas for next review**:
605
+ - Verify security fixes
606
+ - Validate performance improvements
607
+ - Check test coverage increase
608
+
609
+ ---
610
+
611
+ ## Appendix: Investigation Notes
612
+
613
+ {Include any detailed ReAct investigation cycles that were particularly complex or instructive}
614
+
615
+ ### Investigation 1: SQL Injection Analysis
616
+
617
+ **THOUGHT**: Saw string concatenation in SQL - potential injection
618
+
619
+ **ACTION**: Checked if input is validated before query
620
+
621
+ **OBSERVATION**: No validation found - direct concatenation
622
+
623
+ **THOUGHT**: Need to confirm this is exploitable and find correct pattern
624
+
625
+ **ACTION**: Checked similar queries in codebase
626
+
627
+ **OBSERVATION**: All other queries use parameterized approach - this is the outlier
628
+
629
+ **CONCLUSION**: Confirmed vulnerability, pattern for fix identified
630
+ ```
631
+
632
+ ---
633
+
634
+ ## Quality Standards for Reviews
635
+
636
+ ### Excellent Review Characteristics
637
+
638
+ ✅ **Specific**: References exact file paths and line numbers
639
+ ✅ **Actionable**: Provides concrete code examples
640
+ ✅ **Reasoned**: Explains WHY something is an issue
641
+ ✅ **Contextual**: Considers codebase patterns and history
642
+ ✅ **Balanced**: Notes positive aspects, not just problems
643
+ ✅ **Prioritized**: Clear severity levels
644
+ ✅ **Evidence-based**: Uses ReAct to investigate before concluding
645
+
646
+ ### Poor Review Characteristics
647
+
648
+ ❌ **Vague**: "Code quality could be better"
649
+ ❌ **Unreasoned**: "This is wrong" without explanation
650
+ ❌ **Inconsistent**: Flags patterns that match codebase style
651
+ ❌ **Impractical**: Suggests major refactors without considering cost
652
+ ❌ **Unbalanced**: Only criticism, no recognition of good work
653
+
654
+ ---
655
+
656
+ ## Post-Review Actions
657
+
658
+ ### Save Review Report
659
+ Save to: `.sublation-os/reviews/[YYYY-MM-DD]-[file-or-feature-name]-review.md`
660
+
661
+ ### Suggest Learning Capture
662
+ If notable issues found, suggest running `/learn` to capture:
663
+ - New antipatterns discovered
664
+ - Security vulnerabilities specific to this codebase
665
+ - Performance patterns to avoid
666
+ - Better approaches identified
667
+
668
+ ### Track Metrics (Optional)
669
+ Consider tracking over time:
670
+ - Average severity of issues found
671
+ - Time to fix issues by severity
672
+ - Recurring issue patterns
673
+ - Test coverage trends
674
+
675
+ ---
676
+
677
+ ## Integration Points
678
+
679
+ **With `/investigate`**: If review finds bugs, use `/investigate` to diagnose root cause
680
+
681
+ **With `/learn`**: Capture codebase-specific patterns discovered during review
682
+
683
+ **With `implementer-v2`**: Review can inform implementation standards
684
+
685
+ **With `.sublation-os/memory/`**: Check past learnings, add new ones
686
+
687
+ ---
688
+
689
+ ## Summary
690
+
691
+ This review command provides:
692
+ - **7-dimensional analysis** (Correctness, Security, Performance, Maintainability, Testing, Architecture, Standards)
693
+ - **Chain of Thought reasoning** for systematic evaluation
694
+ - **ReAct investigation** for suspicious patterns
695
+ - **Severity-based prioritization** with specific action items
696
+ - **Integration with codebase knowledge** (standards + memory)
697
+ - **Concrete, actionable recommendations** with code examples
698
+ - **Balanced perspective** (positive + negative observations)
699
+ - **Documentation** for future reference
700
+
701
+ The goal is not just to find issues, but to **understand context**, **reason through trade-offs**, and **provide practical guidance** that improves code quality while respecting existing patterns and constraints.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Review code for correctness, maintainability, and clarity
3
+ ---
4
+
5
+ ## 🧠 Summary
6
+ {Brief overview of what the code does}
7
+
8
+ ## ⚠️ Issues Found
9
+ - {List of bugs, anti-patterns, or risks}
10
+
11
+ ## ✅ Suggestions
12
+ - {Recommended refactors or improvements}