@atlashub/smartstack-cli 1.13.2 → 1.14.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 (210) hide show
  1. package/.documentation/agents.html +1 -1
  2. package/.documentation/apex.html +1 -1
  3. package/.documentation/business-analyse.html +1 -1
  4. package/.documentation/cli-commands.html +3 -3
  5. package/.documentation/commands.html +1 -1
  6. package/.documentation/efcore.html +1 -1
  7. package/.documentation/gitflow.html +1 -1
  8. package/.documentation/hooks.html +1 -1
  9. package/.documentation/index.html +1 -1
  10. package/.documentation/init.html +3 -3
  11. package/.documentation/installation.html +1001 -352
  12. package/.documentation/ralph-loop.html +1 -1
  13. package/.documentation/test-web.html +1 -1
  14. package/README.md +88 -20
  15. package/dist/index.js +276 -85
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -1
  18. package/templates/agents/code-reviewer.md +163 -0
  19. package/templates/agents/efcore/db-deploy.md +25 -7
  20. package/templates/agents/efcore/db-reset.md +31 -10
  21. package/templates/agents/efcore/db-status.md +22 -5
  22. package/templates/agents/efcore/migration.md +69 -19
  23. package/templates/agents/gitflow/cleanup.md +8 -1
  24. package/templates/agents/gitflow/commit.md +7 -5
  25. package/templates/agents/gitflow/finish.md +6 -4
  26. package/templates/agents/gitflow/pr.md +8 -1
  27. package/templates/agents/gitflow/start.md +1 -1
  28. package/templates/commands/check-version.md +267 -0
  29. package/templates/commands/efcore/_shared.md +30 -1
  30. package/templates/commands/efcore/db-reset.md +18 -6
  31. package/templates/commands/gitflow/OPTIMIZATIONS.md +206 -0
  32. package/templates/commands/refactor.md +164 -0
  33. package/templates/project/DependencyInjection.Application.cs.template +25 -0
  34. package/templates/project/DependencyInjection.Infrastructure.cs.template +61 -0
  35. package/templates/project/DesignTimeExtensionsDbContextFactory.cs.template +70 -0
  36. package/templates/project/ExampleEntity.cs.template +116 -0
  37. package/templates/project/ExampleEntityConfiguration.cs.template +64 -0
  38. package/templates/project/ExampleService.cs.template +146 -0
  39. package/templates/project/ExtensionsDbContext.cs.template +41 -0
  40. package/templates/project/IExtensionsDbContext.cs.template +22 -0
  41. package/templates/project/Program.cs.template +47 -0
  42. package/templates/project/README.md +79 -0
  43. package/templates/ralph/README.md +10 -8
  44. package/templates/ralph/ralph.config.yaml +2 -2
  45. package/templates/skills/_shared.md +44 -44
  46. package/templates/skills/ai-prompt/SKILL.md +55 -55
  47. package/templates/skills/apex/SKILL.md +235 -0
  48. package/templates/skills/apex/steps/step-00-init.md +203 -0
  49. package/templates/skills/apex/steps/step-01-analyze.md +210 -0
  50. package/templates/skills/apex/steps/step-02-plan.md +217 -0
  51. package/templates/skills/apex/steps/step-03-execute.md +178 -0
  52. package/templates/skills/apex/steps/step-04-validate.md +217 -0
  53. package/templates/skills/apex/steps/step-05-examine.md +207 -0
  54. package/templates/skills/apex/steps/step-06-resolve.md +181 -0
  55. package/templates/skills/apex/steps/step-07-tests.md +206 -0
  56. package/templates/skills/apex/steps/step-08-run-tests.md +207 -0
  57. package/templates/skills/apex/templates/00-context.md +46 -0
  58. package/templates/skills/apex/templates/01-analyze.md +63 -0
  59. package/templates/skills/apex/templates/02-plan.md +63 -0
  60. package/templates/skills/apex/templates/03-execute.md +34 -0
  61. package/templates/skills/apex/templates/04-validate.md +61 -0
  62. package/templates/skills/apex/templates/05-examine.md +58 -0
  63. package/templates/skills/apex/templates/06-resolve.md +39 -0
  64. package/templates/skills/apex/templates/07-tests.md +56 -0
  65. package/templates/skills/apex/templates/08-run-tests.md +41 -0
  66. package/templates/skills/apex/templates/README.md +69 -0
  67. package/templates/skills/application/SKILL.md +50 -50
  68. package/templates/skills/application/templates-backend.md +25 -25
  69. package/templates/skills/application/templates-frontend.md +43 -43
  70. package/templates/skills/application/templates-i18n.md +29 -29
  71. package/templates/skills/application/templates-seed.md +77 -77
  72. package/templates/skills/business-analyse/SKILL.md +223 -0
  73. package/templates/skills/business-analyse/_shared.md +258 -0
  74. package/templates/skills/business-analyse/questionnaire/01-context.md +33 -0
  75. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +35 -0
  76. package/templates/skills/business-analyse/questionnaire/03-scope.md +35 -0
  77. package/templates/skills/business-analyse/questionnaire/04-data.md +36 -0
  78. package/templates/skills/business-analyse/questionnaire/05-integrations.md +36 -0
  79. package/templates/skills/business-analyse/questionnaire/06-security.md +40 -0
  80. package/templates/skills/business-analyse/questionnaire/07-ui.md +36 -0
  81. package/templates/skills/business-analyse/questionnaire/08-performance.md +35 -0
  82. package/templates/skills/business-analyse/questionnaire/09-constraints.md +35 -0
  83. package/templates/skills/business-analyse/questionnaire/10-documentation.md +35 -0
  84. package/templates/skills/business-analyse/questionnaire.md +177 -177
  85. package/templates/skills/business-analyse/react/components.md +340 -0
  86. package/templates/skills/business-analyse/react/i18n-template.md +245 -0
  87. package/templates/skills/business-analyse/react/schema.md +151 -0
  88. package/templates/skills/business-analyse/steps/step-00-init.md +293 -0
  89. package/templates/skills/business-analyse/steps/step-01-discover.md +267 -0
  90. package/templates/skills/business-analyse/steps/step-02-analyse.md +243 -0
  91. package/templates/skills/business-analyse/steps/step-03-specify.md +317 -0
  92. package/templates/skills/business-analyse/steps/step-04-validate.md +239 -0
  93. package/templates/skills/business-analyse/steps/step-05-handoff.md +336 -0
  94. package/templates/skills/business-analyse/steps/step-06-doc-html.md +261 -0
  95. package/templates/skills/business-analyse/templates/00-context.md +105 -0
  96. package/templates/skills/business-analyse/templates/frd-brd.md +97 -0
  97. package/templates/skills/business-analyse/templates/frd-discovery.md +78 -0
  98. package/templates/skills/business-analyse/templates/frd-handoff.md +118 -0
  99. package/templates/skills/business-analyse/templates/frd-spec.md +168 -0
  100. package/templates/skills/business-analyse/templates-frd.md +217 -217
  101. package/templates/skills/business-analyse/templates-react.md +26 -26
  102. package/templates/skills/controller/SKILL.md +141 -92
  103. package/templates/skills/controller/postman-templates.md +15 -15
  104. package/templates/skills/controller/steps/step-00-init.md +191 -0
  105. package/templates/skills/controller/steps/step-01-analyze.md +146 -0
  106. package/templates/skills/controller/steps/step-02-plan.md +176 -0
  107. package/templates/skills/controller/steps/step-03-generate.md +219 -0
  108. package/templates/skills/controller/steps/step-04-perms.md +219 -0
  109. package/templates/skills/controller/steps/step-05-validate.md +107 -0
  110. package/templates/skills/controller/templates.md +77 -77
  111. package/templates/skills/documentation/SKILL.md +79 -79
  112. package/templates/skills/feature-full/SKILL.md +38 -38
  113. package/templates/skills/gitflow/SKILL.md +277 -0
  114. package/templates/{commands → skills}/gitflow/_shared.md +20 -20
  115. package/templates/skills/gitflow/phases/abort.md +173 -0
  116. package/templates/skills/gitflow/phases/cleanup.md +226 -0
  117. package/templates/skills/gitflow/phases/status.md +178 -0
  118. package/templates/skills/gitflow/steps/step-commit.md +255 -0
  119. package/templates/skills/gitflow/steps/step-finish.md +255 -0
  120. package/templates/skills/gitflow/steps/step-init.md +209 -0
  121. package/templates/skills/gitflow/steps/step-merge.md +225 -0
  122. package/templates/skills/gitflow/steps/step-plan.md +208 -0
  123. package/templates/skills/gitflow/steps/step-pr.md +235 -0
  124. package/templates/skills/gitflow/steps/step-start.md +234 -0
  125. package/templates/skills/gitflow/steps/step-sync.md +200 -0
  126. package/templates/skills/gitflow/templates/config.json +53 -0
  127. package/templates/skills/notification/SKILL.md +51 -51
  128. package/templates/skills/ralph-loop/SKILL.md +228 -0
  129. package/templates/skills/ralph-loop/steps/step-00-init.md +201 -0
  130. package/templates/skills/ralph-loop/steps/step-01-task.md +169 -0
  131. package/templates/skills/ralph-loop/steps/step-02-execute.md +173 -0
  132. package/templates/skills/ralph-loop/steps/step-03-commit.md +170 -0
  133. package/templates/skills/ralph-loop/steps/step-04-check.md +162 -0
  134. package/templates/skills/ralph-loop/steps/step-05-report.md +181 -0
  135. package/templates/skills/review-code/SKILL.md +219 -0
  136. package/templates/skills/review-code/references/clean-code-principles.md +140 -0
  137. package/templates/skills/review-code/references/code-quality-metrics.md +174 -0
  138. package/templates/skills/review-code/references/feedback-patterns.md +149 -0
  139. package/templates/skills/review-code/references/security-checklist.md +127 -0
  140. package/templates/skills/ui-components/SKILL.md +54 -54
  141. package/templates/skills/workflow/SKILL.md +46 -46
  142. package/templates/commands/ai-prompt.md +0 -315
  143. package/templates/commands/apex/1-analyze.md +0 -100
  144. package/templates/commands/apex/2-plan.md +0 -145
  145. package/templates/commands/apex/3-execute.md +0 -171
  146. package/templates/commands/apex/4-examine.md +0 -116
  147. package/templates/commands/apex/5-tasks.md +0 -209
  148. package/templates/commands/apex.md +0 -76
  149. package/templates/commands/application/create.md +0 -362
  150. package/templates/commands/application/templates-backend.md +0 -463
  151. package/templates/commands/application/templates-frontend.md +0 -517
  152. package/templates/commands/application/templates-i18n.md +0 -478
  153. package/templates/commands/application/templates-seed.md +0 -362
  154. package/templates/commands/application.md +0 -303
  155. package/templates/commands/business-analyse/0-orchestrate.md +0 -156
  156. package/templates/commands/business-analyse/1-init.md +0 -99
  157. package/templates/commands/business-analyse/2-discover.md +0 -143
  158. package/templates/commands/business-analyse/3-analyse.md +0 -106
  159. package/templates/commands/business-analyse/4-specify.md +0 -133
  160. package/templates/commands/business-analyse/5-validate.md +0 -132
  161. package/templates/commands/business-analyse/6-handoff.md +0 -157
  162. package/templates/commands/business-analyse/7-doc-html.md +0 -103
  163. package/templates/commands/business-analyse/_shared.md +0 -176
  164. package/templates/commands/business-analyse/bug.md +0 -118
  165. package/templates/commands/business-analyse/change-request.md +0 -144
  166. package/templates/commands/business-analyse/hotfix.md +0 -116
  167. package/templates/commands/business-analyse.md +0 -121
  168. package/templates/commands/controller/create.md +0 -216
  169. package/templates/commands/controller/postman-templates.md +0 -528
  170. package/templates/commands/controller/templates.md +0 -600
  171. package/templates/commands/controller.md +0 -337
  172. package/templates/commands/create/agent.md +0 -138
  173. package/templates/commands/create/command.md +0 -166
  174. package/templates/commands/create/hook.md +0 -234
  175. package/templates/commands/create/plugin.md +0 -329
  176. package/templates/commands/create/project.md +0 -508
  177. package/templates/commands/create/skill.md +0 -199
  178. package/templates/commands/create.md +0 -220
  179. package/templates/commands/documentation/module.md +0 -202
  180. package/templates/commands/documentation/templates.md +0 -432
  181. package/templates/commands/documentation.md +0 -190
  182. package/templates/commands/epct.md +0 -69
  183. package/templates/commands/explain.md +0 -186
  184. package/templates/commands/feature-full.md +0 -267
  185. package/templates/commands/gitflow/1-init.md +0 -188
  186. package/templates/commands/gitflow/10-start.md +0 -190
  187. package/templates/commands/gitflow/11-finish.md +0 -382
  188. package/templates/commands/gitflow/12-cleanup.md +0 -103
  189. package/templates/commands/gitflow/13-sync.md +0 -216
  190. package/templates/commands/gitflow/14-rebase.md +0 -251
  191. package/templates/commands/gitflow/2-status.md +0 -122
  192. package/templates/commands/gitflow/3-commit.md +0 -209
  193. package/templates/commands/gitflow/4-plan.md +0 -174
  194. package/templates/commands/gitflow/5-exec.md +0 -202
  195. package/templates/commands/gitflow/6-abort.md +0 -121
  196. package/templates/commands/gitflow/7-pull-request.md +0 -176
  197. package/templates/commands/gitflow/8-review.md +0 -113
  198. package/templates/commands/gitflow/9-merge.md +0 -157
  199. package/templates/commands/gitflow.md +0 -128
  200. package/templates/commands/implement.md +0 -663
  201. package/templates/commands/init.md +0 -567
  202. package/templates/commands/mcp-integration.md +0 -330
  203. package/templates/commands/notification.md +0 -129
  204. package/templates/commands/oneshot.md +0 -57
  205. package/templates/commands/quickstart.md +0 -154
  206. package/templates/commands/ralph-loop/cancel-ralph.md +0 -18
  207. package/templates/commands/ralph-loop/help.md +0 -126
  208. package/templates/commands/ralph-loop/ralph-loop.md +0 -120
  209. package/templates/commands/review.md +0 -106
  210. package/templates/commands/workflow.md +0 -193
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: step-05-report
3
+ description: Generate final feature report
4
+ next_step: null
5
+ ---
6
+
7
+ # Step 5: Generate Report
8
+
9
+ ## YOUR TASK:
10
+
11
+ Generate a comprehensive feature report documenting what was accomplished.
12
+
13
+ ---
14
+
15
+ ## EXECUTION SEQUENCE:
16
+
17
+ ### 1. Gather Statistics
18
+
19
+ **Collect data from prd.json and progress.txt:**
20
+
21
+ ```javascript
22
+ const prd = readJSON('.ralph/prd.json');
23
+ const stats = {
24
+ feature: prd.feature,
25
+ started: prd.created,
26
+ completed: new Date().toISOString(),
27
+ iterations: prd.current_iteration,
28
+ maxIterations: prd.max_iterations,
29
+ tasksCompleted: prd.tasks.filter(t => t.passes).length,
30
+ tasksTotal: prd.tasks.length,
31
+ status: allComplete ? "COMPLETE" : "PARTIAL"
32
+ };
33
+ ```
34
+
35
+ ### 2. Collect File Changes
36
+
37
+ **Get files from git log:**
38
+
39
+ ```bash
40
+ git log --name-status --pretty=format:"%H" HEAD~{iterations}..HEAD
41
+ ```
42
+
43
+ **Categorize:**
44
+ - Files created (A)
45
+ - Files modified (M)
46
+ - Files deleted (D)
47
+
48
+ ### 3. Collect MCP Usage
49
+
50
+ **From verbose logs (if available):**
51
+
52
+ ```javascript
53
+ const mcpStats = {
54
+ validate_conventions: X,
55
+ check_migrations: Y,
56
+ scaffold_extension: Z,
57
+ context7_queries: W
58
+ };
59
+ ```
60
+
61
+ ### 4. Generate Report File
62
+
63
+ **Write to `.ralph/reports/{feature-slug}.md`:**
64
+
65
+ ```markdown
66
+ # Feature Report: {feature}
67
+
68
+ ## Summary
69
+ - **Started**: {started}
70
+ - **Completed**: {completed}
71
+ - **Duration**: {iterations} iterations
72
+ - **Status**: {status}
73
+
74
+ ## Task Progress
75
+
76
+ | # | Task | Status |
77
+ |---|------|--------|
78
+ | 1 | {task_1_description} | ✅ |
79
+ | 2 | {task_2_description} | ✅ |
80
+ | 3 | {task_3_description} | ❌ (if incomplete) |
81
+
82
+ ## MCP Usage Statistics
83
+
84
+ | Tool | Calls | Success | Failures |
85
+ |------|-------|---------|----------|
86
+ | validate_conventions | X | X | 0 |
87
+ | check_migrations | Y | Y | 0 |
88
+ | scaffold_extension | Z | Z | 0 |
89
+ | context7 query-docs | W | W | 0 |
90
+
91
+ ## Files Created
92
+
93
+ ```
94
+ {list of created files}
95
+ ```
96
+
97
+ ## Files Modified
98
+
99
+ ```
100
+ {list of modified files}
101
+ ```
102
+
103
+ ## Git Commits
104
+
105
+ ```
106
+ {commit_hash_1} feat(ralph): {message_1}
107
+ {commit_hash_2} feat(ralph): {message_2}
108
+ ```
109
+
110
+ ## Validations Performed
111
+
112
+ - [x] SmartStack conventions validated
113
+ - [x] EF Core migrations checked (if applicable)
114
+ - [x] No conflicts detected
115
+ - [x] Build passes
116
+ - [x] Tests pass (if applicable)
117
+
118
+ ## Key Learnings
119
+
120
+ {Extracted from progress.txt - key insights from each iteration}
121
+
122
+ ## Notes
123
+
124
+ {Any additional observations about the implementation}
125
+ ```
126
+
127
+ ### 5. Display Final Summary
128
+
129
+ ```
130
+ ╔══════════════════════════════════════════════════════════════════╗
131
+ ║ RALPH LOOP COMPLETE ║
132
+ ╠══════════════════════════════════════════════════════════════════╣
133
+ ║ Feature: {feature} ║
134
+ ║ Status: {status} ║
135
+ ║ Iterations: {iterations} ║
136
+ ║ Tasks: {tasksCompleted} / {tasksTotal} ║
137
+ ╠══════════════════════════════════════════════════════════════════╣
138
+ ║ Files Created: {created_count} ║
139
+ ║ Files Modified: {modified_count} ║
140
+ ║ Commits: {commit_count} ║
141
+ ╠══════════════════════════════════════════════════════════════════╣
142
+ ║ Report saved to: ║
143
+ ║ .ralph/reports/{feature-slug}.md ║
144
+ ╚══════════════════════════════════════════════════════════════════╝
145
+ ```
146
+
147
+ ### 6. Output Completion (if applicable)
148
+
149
+ **If all tasks complete and not already output:**
150
+
151
+ ```
152
+ <promise>{completion_promise}</promise>
153
+ ```
154
+
155
+ ---
156
+
157
+ ## CLEANUP OPTIONS:
158
+
159
+ **Suggest to user:**
160
+
161
+ ```
162
+ Next steps:
163
+ 1. Review report: .ralph/reports/{feature-slug}.md
164
+ 2. Run full test suite: dotnet test
165
+ 3. Create PR: /gitflow:7-pull-request
166
+ 4. Clean up Ralph files: rm -rf .ralph/
167
+ ```
168
+
169
+ ---
170
+
171
+ ## SUCCESS CRITERIA:
172
+
173
+ - Report generated in `.ralph/reports/`
174
+ - All statistics accurate
175
+ - File lists complete
176
+ - Learnings documented
177
+ - Final summary displayed
178
+
179
+ ## COMPLETION:
180
+
181
+ Ralph loop complete. No more steps.
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: review-code
3
+ description: This skill should be used when the user asks to "review code", "review this PR", "code review", "audit this code", or mentions reviewing pull requests, security checks, or code quality. Covers security (OWASP), clean code (SOLID), code smells, complexity metrics, and high-value feedback patterns. Focuses on impactful issues, not nitpicks.
4
+ ---
5
+
6
+ <objective>
7
+ Provide expert-level code review guidance that focuses on high-impact issues: security vulnerabilities, logic errors, maintainability problems, and architectural concerns. Skip nitpicks and style issues that should be automated.
8
+
9
+ Based on research from Google, Microsoft, OWASP, and academic studies on code review effectiveness.
10
+ </objective>
11
+
12
+ <quick_start>
13
+ <review_priority>
14
+ **Priority order**: Security > Correctness > Maintainability > Performance
15
+
16
+ **High-value feedback** (36-43% implementation rate):
17
+ - Bug fixes and logic errors
18
+ - Security vulnerabilities
19
+ - Readability/maintainability issues
20
+ - Missing error handling
21
+
22
+ **Skip these** (automate instead):
23
+ - Formatting/whitespace
24
+ - Simple naming conventions
25
+ - Linting violations
26
+ </review_priority>
27
+
28
+ <essential_checks>
29
+ 1. **Security**: Input validation, auth checks, secrets exposure
30
+ 2. **Logic**: Edge cases, error handling, null checks
31
+ 3. **Architecture**: Single responsibility, proper abstractions
32
+ 4. **Tests**: Coverage for new functionality
33
+ </essential_checks>
34
+ </quick_start>
35
+
36
+ <review_categories>
37
+ <category name="security" priority="critical">
38
+ **Must check in every review:**
39
+ - No hardcoded credentials (search: `password.*=.*['"]`, `api[_-]?key.*=`)
40
+ - Input validation on all user data
41
+ - Parameterized queries (no string concatenation for SQL)
42
+ - Authorization checks on every endpoint
43
+ - No `eval()`, `exec()`, dangerous functions
44
+
45
+ See [references/security-checklist.md](references/security-checklist.md) for OWASP Top 10 patterns.
46
+ </category>
47
+
48
+ <category name="logic" priority="critical">
49
+ **Verify correctness:**
50
+ - Business logic matches requirements
51
+ - Edge cases handled (null, empty, boundary values)
52
+ - Error handling present and appropriate
53
+ - Race conditions in async code
54
+ - Resource cleanup (connections, file handles)
55
+ </category>
56
+
57
+ <category name="clean_code" priority="high">
58
+ **Check for code smells:**
59
+ - Large functions (>50 lines) - violate Single Responsibility
60
+ - Deep nesting (>3 levels) - extract to functions
61
+ - Long parameter lists (>3 params) - use objects
62
+ - Duplicated code - extract to shared functions
63
+ - Magic numbers/strings - use named constants
64
+
65
+ See [references/clean-code-principles.md](references/clean-code-principles.md) for SOLID principles and code smells.
66
+ </category>
67
+
68
+ <category name="maintainability" priority="medium">
69
+ **Assess long-term health:**
70
+ - Cognitive complexity <15 per function
71
+ - Clear naming that reveals intent
72
+ - Appropriate abstractions (not over-engineered)
73
+ - Test coverage for critical paths
74
+ </category>
75
+ </review_categories>
76
+
77
+ <feedback_guidelines>
78
+ <valuable_feedback>
79
+ **Structure**: What + Why + How
80
+
81
+ ✓ "This function is 80 lines with 5 responsibilities. Consider extracting the validation logic (lines 20-45) into `validateUserInput()` for testability."
82
+
83
+ ✓ "SQL query uses string concatenation (line 34). Use parameterized queries to prevent injection: `db.query('SELECT * FROM users WHERE id = ?', [userId])`"
84
+
85
+ ✓ "Missing null check on `user.profile` (line 52). This will throw if user hasn't completed onboarding. Add: `if (!user.profile) return defaultProfile;`"
86
+ </valuable_feedback>
87
+
88
+ <wasteful_feedback>
89
+ ✗ "This could be cleaner" (vague)
90
+ ✗ "Rename this variable" (nitpick - use linter)
91
+ ✗ "Add a comment here" (if code is clear, no comment needed)
92
+ ✗ "I would do this differently" (subjective without reason)
93
+ </wasteful_feedback>
94
+
95
+ <priority_labels>
96
+ Use clear labels to distinguish severity:
97
+ - **[BLOCKING]**: Must fix before merge (security, bugs)
98
+ - **[SUGGESTION]**: Would improve code but not required
99
+ - **[NIT]**: Minor preference (mark clearly or skip entirely)
100
+
101
+ See [references/feedback-patterns.md](references/feedback-patterns.md) for communication strategies.
102
+ </priority_labels>
103
+ </feedback_guidelines>
104
+
105
+ <code_quality_metrics>
106
+ <metric name="cognitive_complexity">
107
+ - Target: <15 per function, <50 per module
108
+ - Each nesting level adds complexity
109
+ - Prefer early returns over deep nesting
110
+ </metric>
111
+
112
+ <metric name="function_size">
113
+ - Target: <50 lines, ideally <20
114
+ - Should fit on one screen
115
+ - One function = one responsibility
116
+ </metric>
117
+
118
+ <metric name="cyclomatic_complexity">
119
+ - Target: <10 per function
120
+ - Count: 1 + (if + while + for + case + catch + && + ||)
121
+ - High complexity = hard to test
122
+ </metric>
123
+
124
+ See [references/code-quality-metrics.md](references/code-quality-metrics.md) for detailed calculations.
125
+ </code_quality_metrics>
126
+
127
+ <anti_patterns>
128
+ <pattern name="nitpicking">
129
+ **Problem**: Excessive minor comments bury critical issues
130
+ **Impact**: Developers become defensive, stop reading feedback
131
+ **Solution**: Automate style with linters; focus humans on logic/security
132
+ </pattern>
133
+
134
+ <pattern name="vague_criticism">
135
+ **Problem**: "This is wrong" without explanation
136
+ **Impact**: Developer doesn't know how to fix; creates friction
137
+ **Solution**: Always include What + Why + How
138
+ </pattern>
139
+
140
+ <pattern name="blocking_on_preferences">
141
+ **Problem**: Blocking merge for subjective style preferences
142
+ **Impact**: Delays delivery; damages team trust
143
+ **Solution**: Reserve blocking for security/correctness only
144
+ </pattern>
145
+
146
+ <pattern name="reviewing_unchanged_code">
147
+ **Problem**: Commenting on code outside the PR diff
148
+ **Impact**: Scope creep; unfair to author
149
+ **Solution**: Focus only on changed lines; file separate issues for existing problems
150
+ </pattern>
151
+ </anti_patterns>
152
+
153
+ <react_nextjs_review>
154
+ ## React/Next.js Codebase Detection
155
+
156
+ **When reviewing a React or Next.js project**, launch an additional parallel agent for Vercel React best practices.
157
+
158
+ <detection>
159
+ **Detect React/Next.js codebase by checking:**
160
+ - `package.json` contains `"next"` or `"react"` dependencies
161
+ - Files with `.tsx`, `.jsx` extensions in changes
162
+ - `next.config.js` or `next.config.ts` exists
163
+ - `app/` or `pages/` directory structure (Next.js)
164
+ </detection>
165
+
166
+ <parallel_agent>
167
+ **If React/Next.js detected, launch parallel agent:**
168
+
169
+ ```yaml
170
+ agent:
171
+ type: code-reviewer
172
+ focus: "vercel-react-best-practices"
173
+ task: |
174
+ Review the recent code changes using Vercel React best practices.
175
+ Focus on:
176
+ - Eliminating waterfalls (async patterns, Promise.all)
177
+ - Bundle size optimization (dynamic imports, barrel files)
178
+ - Server-side performance (caching, serialization)
179
+ - Re-render optimization (memoization, state management)
180
+ - Rendering performance patterns
181
+
182
+ Use the /vercel-react-best-practices skill as reference.
183
+ Report findings with [BLOCKING], [SUGGESTION], or [NIT] labels.
184
+ ```
185
+
186
+ **Execution:**
187
+ 1. Check for React/Next.js in `package.json`
188
+ 2. If detected, use Task tool to launch parallel agent:
189
+ ```
190
+ Task tool with subagent_type="code-reviewer":
191
+ "Review recent changes against Vercel React best practices from /vercel-react-best-practices skill.
192
+ Focus on: async patterns, bundle optimization, server performance, re-renders.
193
+ Check changed files for violations of rules like async-parallel, bundle-barrel-imports,
194
+ server-cache-react, rerender-memo. Report with priority labels."
195
+ ```
196
+ 3. Merge findings into main review output
197
+ </parallel_agent>
198
+ </react_nextjs_review>
199
+
200
+ <success_criteria>
201
+ A good code review:
202
+ - Identifies security vulnerabilities (if any)
203
+ - Catches logic errors and edge cases
204
+ - Flags maintainability issues with specific fixes
205
+ - Uses priority labels ([BLOCKING] vs [SUGGESTION])
206
+ - Provides actionable feedback (What + Why + How)
207
+ - Avoids nitpicks on style/formatting
208
+ - Completes in reasonable time (<4 hours for small PRs)
209
+ - **[React/Next.js]** Includes Vercel best practices review when applicable
210
+ </success_criteria>
211
+
212
+ <reference_guides>
213
+ For detailed guidance and patterns:
214
+
215
+ - **`references/security-checklist.md`** - OWASP Top 10, authentication patterns, input validation, common vulnerabilities
216
+ - **`references/clean-code-principles.md`** - SOLID principles, naming conventions, function design, code smell detection
217
+ - **`references/feedback-patterns.md`** - Valuable vs wasteful feedback patterns, communication strategies, priority labeling
218
+ - **`references/code-quality-metrics.md`** - Complexity calculations, maintainability index, measurement techniques
219
+ </reference_guides>
@@ -0,0 +1,140 @@
1
+ <overview>
2
+ Clean code principles based on Robert Martin's Clean Code and industry research. SOLID principles, naming conventions, and code smell detection.
3
+ </overview>
4
+
5
+ <solid_principles>
6
+ | Principle | Rule | Violation Sign |
7
+ |-----------|------|----------------|
8
+ | **S**ingle Responsibility | One reason to change | Class/function does multiple things |
9
+ | **O**pen/Closed | Open for extension, closed for modification | Adding features requires changing existing code |
10
+ | **L**iskov Substitution | Subtypes must be substitutable | Subclass breaks when used as parent |
11
+ | **I**nterface Segregation | No forced dependencies | Implementing unused interface methods |
12
+ | **D**ependency Inversion | Depend on abstractions | Direct instantiation of dependencies |
13
+ </solid_principles>
14
+
15
+ <function_guidelines>
16
+ <size_and_scope>
17
+ Function size targets:
18
+
19
+ - Maximum 50 lines (ideally <20)
20
+ - Do ONE thing well
21
+ - Single level of abstraction
22
+ - Fit on one screen without scrolling
23
+ </size_and_scope>
24
+
25
+ <parameters>
26
+ Parameter limits:
27
+
28
+ - Maximum 3 parameters
29
+ - Avoid flag arguments (split into separate methods)
30
+ - Use objects for related parameters
31
+ </parameters>
32
+
33
+ <naming>
34
+ Function naming patterns:
35
+
36
+ - Verbs for functions: `getUserById()`, `calculateTotal()`
37
+ - Reveals intent without reading body
38
+ - No abbreviations: `getTransaction()` not `getTx()`
39
+ </naming>
40
+ </function_guidelines>
41
+
42
+ <naming_conventions>
43
+ General naming rules:
44
+
45
+ ✓ Descriptive, unambiguous names
46
+ ✓ Pronounceable and searchable
47
+ ✓ Class names: nouns (User, PaymentProcessor)
48
+ ✓ Method names: verbs (validate, calculate, fetch)
49
+ ✗ Single letter variables (except loop counters)
50
+ ✗ Hungarian notation (strName, intCount)
51
+ ✗ Abbreviations (usr, txn, cfg)
52
+ </naming_conventions>
53
+
54
+ <code_smells>
55
+ <critical_smells>
56
+ Flag these in review:
57
+
58
+ | Smell | Detection | Fix |
59
+ |-------|-----------|-----|
60
+ | **Duplicated Code** | Same logic in 2+ places | Extract to shared function |
61
+ | **Large Class/Method** | >50 lines, multiple responsibilities | Split by responsibility |
62
+ | **Long Parameter List** | >3 parameters | Use parameter object |
63
+ | **Feature Envy** | Method uses another class's data more | Move method to that class |
64
+ | **God Object** | One class controls everything | Split into focused classes |
65
+ </critical_smells>
66
+
67
+ <medium_smells>
68
+ Suggest these fixes:
69
+
70
+ | Smell | Detection | Fix |
71
+ |-------|-----------|-----|
72
+ | **Deep Nesting** | >3 levels of indentation | Guard clauses, early returns |
73
+ | **Magic Numbers** | Unexplained literals | Named constants |
74
+ | **Dead Code** | Commented-out or unreachable code | Delete it |
75
+ | **Shotgun Surgery** | Small change touches many files | Consolidate related code |
76
+ </medium_smells>
77
+ </code_smells>
78
+
79
+ <complexity_reduction>
80
+ <example_before>
81
+ Complex nested conditions:
82
+
83
+ ```javascript
84
+ function process(user) {
85
+ if (user) {
86
+ if (user.isActive) {
87
+ if (user.hasPermission) {
88
+ // actual logic here
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+ </example_before>
95
+
96
+ <example_after>
97
+ Simplified with guard clauses:
98
+
99
+ ```javascript
100
+ function process(user) {
101
+ if (!user) return;
102
+ if (!user.isActive) return;
103
+ if (!user.hasPermission) return;
104
+
105
+ // actual logic here
106
+ }
107
+ ```
108
+ </example_after>
109
+ </complexity_reduction>
110
+
111
+ <comments_best_practices>
112
+ <good_comments>
113
+ Valuable comments explain:
114
+
115
+ - Explain WHY (intent), not WHAT (code does that)
116
+ - Warn of consequences
117
+ - TODO with ticket number
118
+ </good_comments>
119
+
120
+ <bad_comments>
121
+ Avoid these comment types:
122
+
123
+ - Redundant (restates the code)
124
+ - Commented-out code (delete it)
125
+ - Closing brace comments (`} // end if`)
126
+ - Journal comments (use git history)
127
+ </bad_comments>
128
+ </comments_best_practices>
129
+
130
+ <boy_scout_rule>
131
+ > Leave code cleaner than you found it.
132
+
133
+ **Important**: In PRs, only clean code already being changed. Don't expand scope.
134
+ </boy_scout_rule>
135
+
136
+ <sources>
137
+ - Clean Code by Robert C. Martin
138
+ - [Google Engineering Practices](https://google.github.io/eng-practices/)
139
+ - [Microsoft Code Review Guide](https://microsoft.github.io/code-with-engineering-playbook/)
140
+ </sources>
@@ -0,0 +1,174 @@
1
+ <overview>
2
+ Quantitative code quality metrics for informed review decisions. Includes cognitive complexity, cyclomatic complexity, maintainability index, and technical debt indicators.
3
+ </overview>
4
+
5
+ <cognitive_complexity>
6
+ <definition>
7
+ **What it measures**: Mental effort required to understand code
8
+ </definition>
9
+
10
+ <targets>
11
+ Target complexity levels:
12
+
13
+ - Per function: <15 (ideal <10)
14
+ - Per module: <50
15
+ - Per file: <100
16
+ </targets>
17
+
18
+ <complexity_factors>
19
+ Factors that increase complexity:
20
+
21
+ - Each nesting level (+1 per level)
22
+ - Logical operators (&&, ||)
23
+ - Recursion
24
+ - Breaks in linear flow (break, continue, goto)
25
+ </complexity_factors>
26
+
27
+ <reduction_example>
28
+ Reducing cognitive complexity:
29
+
30
+ ```javascript
31
+ // HIGH COMPLEXITY (nested conditionals)
32
+ function process(data) {
33
+ if (data) {
34
+ if (data.valid) {
35
+ if (data.items.length > 0) {
36
+ for (const item of data.items) {
37
+ if (item.active) {
38
+ // process
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+
46
+ // LOW COMPLEXITY (guard clauses + extraction)
47
+ function process(data) {
48
+ if (!data?.valid) return;
49
+ if (!data.items?.length) return;
50
+
51
+ processActiveItems(data.items);
52
+ }
53
+
54
+ function processActiveItems(items) {
55
+ const active = items.filter(item => item.active);
56
+ active.forEach(processItem);
57
+ }
58
+ ```
59
+ </reduction_example>
60
+ </cognitive_complexity>
61
+
62
+ <cyclomatic_complexity>
63
+ <definition>
64
+ **What it measures**: Number of independent paths through code
65
+ </definition>
66
+
67
+ <formula>
68
+ **Formula**: 1 + (if + while + for + case + catch + && + ||)
69
+ </formula>
70
+
71
+ <targets>
72
+ | Score | Risk | Action |
73
+ |-------|------|--------|
74
+ | 1-4 | Low | Good |
75
+ | 5-7 | Moderate | Consider simplifying |
76
+ | 8-10 | High | Refactor recommended |
77
+ | >10 | Very High | Must refactor |
78
+ </targets>
79
+ </cyclomatic_complexity>
80
+
81
+ <function_size_metrics>
82
+ | Metric | Target | Warning | Critical |
83
+ |--------|--------|---------|----------|
84
+ | Lines | <20 | >30 | >50 |
85
+ | Parameters | ≤3 | 4 | >5 |
86
+ | Nesting depth | ≤2 | 3 | >3 |
87
+ | Return statements | 1-2 | 3-4 | >4 |
88
+ </function_size_metrics>
89
+
90
+ <maintainability_index>
91
+ <formula>
92
+ Microsoft's formula:
93
+
94
+ ```
95
+ MI = MAX(0, (171 - 5.2*ln(HalsteadVolume) - 0.23*CC - 16.2*ln(LOC)) * 100/171)
96
+ ```
97
+ </formula>
98
+
99
+ <interpretation>
100
+ | Score | Maintainability |
101
+ |-------|-----------------|
102
+ | 80-100 | High - easy to maintain |
103
+ | 60-79 | Moderate - some concerns |
104
+ | 40-59 | Low - refactoring recommended |
105
+ | <40 | Very Low - significant refactoring needed |
106
+ </interpretation>
107
+ </maintainability_index>
108
+
109
+ <technical_debt_indicators>
110
+ | Indicator | Healthy | Warning |
111
+ |-----------|---------|---------|
112
+ | Code duplication | <5% | >10% |
113
+ | Test coverage | >80% | <60% |
114
+ | Cyclomatic complexity avg | <5 | >8 |
115
+ | TODO/FIXME count | Stable | Growing |
116
+ | Dependency age | <6 months | >12 months |
117
+ </technical_debt_indicators>
118
+
119
+ <code_churn>
120
+ <definition>
121
+ **What it measures**: Frequency of code changes
122
+ </definition>
123
+
124
+ <warning_signs>
125
+ Signs of problematic churn:
126
+
127
+ - Same file changed in >50% of recent commits
128
+ - High churn + low test coverage = risk
129
+ - Late-project churn indicates instability
130
+ </warning_signs>
131
+ </code_churn>
132
+
133
+ <review_thresholds>
134
+ <must_comment>
135
+ Always comment on:
136
+
137
+ - Function complexity >15
138
+ - Nesting >3 levels
139
+ - Function >50 lines
140
+ - >3 parameters without object
141
+ </must_comment>
142
+
143
+ <consider_commenting>
144
+ Consider commenting on:
145
+
146
+ - Duplicated blocks >10 lines
147
+ - Method doing multiple things
148
+ - Unclear naming
149
+ </consider_commenting>
150
+
151
+ <dont_comment>
152
+ Skip commenting on:
153
+
154
+ - Slightly suboptimal but working code
155
+ - Style preferences
156
+ - Minor naming improvements
157
+ </dont_comment>
158
+ </review_thresholds>
159
+
160
+ <measurement_tools>
161
+ | Language | Tool |
162
+ |----------|------|
163
+ | JavaScript/TypeScript | ESLint (complexity rules), SonarQube |
164
+ | Python | Radon, Pylint |
165
+ | Java | SonarQube, PMD |
166
+ | Go | gocyclo, golangci-lint |
167
+ | General | SonarQube, CodeClimate |
168
+ </measurement_tools>
169
+
170
+ <sources>
171
+ - [SonarQube Cognitive Complexity](https://www.sonarsource.com/docs/CognitiveComplexity.pdf)
172
+ - [Microsoft Maintainability Index](https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning)
173
+ - [Cyclomatic Complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity)
174
+ </sources>