@ktpartners/dgs-platform 2.6.2

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 (256) hide show
  1. package/LICENSE +38 -0
  2. package/README.md +851 -0
  3. package/agents/dgs-codebase-cross-analyzer.md +183 -0
  4. package/agents/dgs-codebase-mapper.md +782 -0
  5. package/agents/dgs-codebase-synthesizer.md +156 -0
  6. package/agents/dgs-debugger.md +1256 -0
  7. package/agents/dgs-executor.md +550 -0
  8. package/agents/dgs-integration-checker.md +481 -0
  9. package/agents/dgs-nyquist-auditor.md +178 -0
  10. package/agents/dgs-phase-researcher.md +563 -0
  11. package/agents/dgs-phase-verifier.md +450 -0
  12. package/agents/dgs-plan-checker.md +708 -0
  13. package/agents/dgs-planner.md +1324 -0
  14. package/agents/dgs-project-researcher.md +631 -0
  15. package/agents/dgs-research-synthesizer.md +249 -0
  16. package/agents/dgs-roadmapper.md +652 -0
  17. package/agents/dgs-verifier.md +607 -0
  18. package/bin/install.js +2073 -0
  19. package/commands/dgs/add-doc.md +45 -0
  20. package/commands/dgs/add-idea.md +38 -0
  21. package/commands/dgs/add-phase.md +43 -0
  22. package/commands/dgs/add-repo.md +54 -0
  23. package/commands/dgs/add-tests.md +41 -0
  24. package/commands/dgs/add-todo.md +47 -0
  25. package/commands/dgs/approve-spec.md +38 -0
  26. package/commands/dgs/audit-milestone.md +36 -0
  27. package/commands/dgs/audit-phase.md +37 -0
  28. package/commands/dgs/cancel-job.md +23 -0
  29. package/commands/dgs/capture-principle.md +143 -0
  30. package/commands/dgs/check-todos.md +45 -0
  31. package/commands/dgs/cleanup.md +18 -0
  32. package/commands/dgs/complete-milestone.md +136 -0
  33. package/commands/dgs/complete-project.md +70 -0
  34. package/commands/dgs/consolidate-ideas.md +50 -0
  35. package/commands/dgs/create-milestone-job.md +37 -0
  36. package/commands/dgs/debug.md +164 -0
  37. package/commands/dgs/develop-idea.md +53 -0
  38. package/commands/dgs/discuss-idea.md +41 -0
  39. package/commands/dgs/discuss-phase.md +83 -0
  40. package/commands/dgs/execute-phase.md +41 -0
  41. package/commands/dgs/fast.md +38 -0
  42. package/commands/dgs/find-related-ideas.md +43 -0
  43. package/commands/dgs/health.md +28 -0
  44. package/commands/dgs/help.md +22 -0
  45. package/commands/dgs/import-spec.md +36 -0
  46. package/commands/dgs/init-product.md +28 -0
  47. package/commands/dgs/insert-phase.md +32 -0
  48. package/commands/dgs/join-discord.md +18 -0
  49. package/commands/dgs/list-docs.md +40 -0
  50. package/commands/dgs/list-ideas.md +42 -0
  51. package/commands/dgs/list-jobs.md +22 -0
  52. package/commands/dgs/list-phase-assumptions.md +46 -0
  53. package/commands/dgs/list-projects.md +57 -0
  54. package/commands/dgs/list-specs.md +40 -0
  55. package/commands/dgs/map-codebase.md +92 -0
  56. package/commands/dgs/new-milestone.md +44 -0
  57. package/commands/dgs/new-project.md +42 -0
  58. package/commands/dgs/node-repair.md +26 -0
  59. package/commands/dgs/overlap-check.md +20 -0
  60. package/commands/dgs/pause-work.md +38 -0
  61. package/commands/dgs/plan-milestone-gaps.md +34 -0
  62. package/commands/dgs/plan-phase.md +44 -0
  63. package/commands/dgs/progress.md +24 -0
  64. package/commands/dgs/quick.md +41 -0
  65. package/commands/dgs/reactivate-project.md +70 -0
  66. package/commands/dgs/reapply-patches.md +110 -0
  67. package/commands/dgs/refine-spec.md +38 -0
  68. package/commands/dgs/reject-idea.md +43 -0
  69. package/commands/dgs/remove-doc.md +44 -0
  70. package/commands/dgs/remove-phase.md +31 -0
  71. package/commands/dgs/remove-repo.md +69 -0
  72. package/commands/dgs/research-idea.md +43 -0
  73. package/commands/dgs/research-phase.md +189 -0
  74. package/commands/dgs/restore-idea.md +45 -0
  75. package/commands/dgs/resume-work.md +40 -0
  76. package/commands/dgs/rollback-job.md +24 -0
  77. package/commands/dgs/run-job.md +35 -0
  78. package/commands/dgs/search.md +40 -0
  79. package/commands/dgs/set-profile.md +34 -0
  80. package/commands/dgs/settings.md +38 -0
  81. package/commands/dgs/switch-project.md +58 -0
  82. package/commands/dgs/undo-consolidation.md +42 -0
  83. package/commands/dgs/update-idea.md +44 -0
  84. package/commands/dgs/update.md +37 -0
  85. package/commands/dgs/validate-phase.md +35 -0
  86. package/commands/dgs/verify-work.md +39 -0
  87. package/commands/dgs/write-spec.md +49 -0
  88. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-01-SUMMARY.md +84 -0
  89. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-02-SUMMARY.md +86 -0
  90. package/deliver-great-systems/.planning/phases/10-v1-to-v2-migration-flow/10-01-SUMMARY.md +85 -0
  91. package/deliver-great-systems/bin/dgs-tools.cjs +1444 -0
  92. package/deliver-great-systems/bin/lib/auto-test.cjs +1365 -0
  93. package/deliver-great-systems/bin/lib/commands.cjs +570 -0
  94. package/deliver-great-systems/bin/lib/config.cjs +417 -0
  95. package/deliver-great-systems/bin/lib/conflict-agent.cjs +1063 -0
  96. package/deliver-great-systems/bin/lib/conflict-agent.test.cjs +554 -0
  97. package/deliver-great-systems/bin/lib/context.cjs +929 -0
  98. package/deliver-great-systems/bin/lib/context.test.cjs +693 -0
  99. package/deliver-great-systems/bin/lib/core.cjs +744 -0
  100. package/deliver-great-systems/bin/lib/core.test.cjs +822 -0
  101. package/deliver-great-systems/bin/lib/docs.cjs +919 -0
  102. package/deliver-great-systems/bin/lib/docs.test.cjs +211 -0
  103. package/deliver-great-systems/bin/lib/execution.cjs +705 -0
  104. package/deliver-great-systems/bin/lib/execution.test.cjs +1472 -0
  105. package/deliver-great-systems/bin/lib/frontmatter.cjs +324 -0
  106. package/deliver-great-systems/bin/lib/ideas.cjs +1406 -0
  107. package/deliver-great-systems/bin/lib/ideas.test.cjs +1417 -0
  108. package/deliver-great-systems/bin/lib/identity.cjs +125 -0
  109. package/deliver-great-systems/bin/lib/init.cjs +1114 -0
  110. package/deliver-great-systems/bin/lib/init.test.cjs +1271 -0
  111. package/deliver-great-systems/bin/lib/jobs.cjs +2015 -0
  112. package/deliver-great-systems/bin/lib/jobs.test.cjs +2619 -0
  113. package/deliver-great-systems/bin/lib/merge-conflicts.cjs +654 -0
  114. package/deliver-great-systems/bin/lib/merge-conflicts.test.cjs +370 -0
  115. package/deliver-great-systems/bin/lib/migration.cjs +352 -0
  116. package/deliver-great-systems/bin/lib/migration.test.cjs +582 -0
  117. package/deliver-great-systems/bin/lib/milestone.cjs +243 -0
  118. package/deliver-great-systems/bin/lib/overlap.cjs +437 -0
  119. package/deliver-great-systems/bin/lib/overlap.test.cjs +747 -0
  120. package/deliver-great-systems/bin/lib/path-audit.test.cjs +384 -0
  121. package/deliver-great-systems/bin/lib/paths.cjs +144 -0
  122. package/deliver-great-systems/bin/lib/paths.test.cjs +486 -0
  123. package/deliver-great-systems/bin/lib/phase.cjs +910 -0
  124. package/deliver-great-systems/bin/lib/projects.cjs +691 -0
  125. package/deliver-great-systems/bin/lib/projects.test.cjs +871 -0
  126. package/deliver-great-systems/bin/lib/repos.cjs +1432 -0
  127. package/deliver-great-systems/bin/lib/repos.test.cjs +1882 -0
  128. package/deliver-great-systems/bin/lib/roadmap.cjs +305 -0
  129. package/deliver-great-systems/bin/lib/search.cjs +570 -0
  130. package/deliver-great-systems/bin/lib/specs.cjs +1303 -0
  131. package/deliver-great-systems/bin/lib/state.cjs +893 -0
  132. package/deliver-great-systems/bin/lib/template.cjs +228 -0
  133. package/deliver-great-systems/bin/lib/test-helpers.cjs +291 -0
  134. package/deliver-great-systems/bin/lib/verify.cjs +796 -0
  135. package/deliver-great-systems/references/checkpoints.md +776 -0
  136. package/deliver-great-systems/references/conflict-resolution.md +66 -0
  137. package/deliver-great-systems/references/context-tiers.md +166 -0
  138. package/deliver-great-systems/references/continuation-format.md +249 -0
  139. package/deliver-great-systems/references/decimal-phase-calculation.md +67 -0
  140. package/deliver-great-systems/references/git-integration.md +250 -0
  141. package/deliver-great-systems/references/git-planning-commit.md +40 -0
  142. package/deliver-great-systems/references/model-profile-resolution.md +36 -0
  143. package/deliver-great-systems/references/model-profiles.md +95 -0
  144. package/deliver-great-systems/references/phase-argument-parsing.md +61 -0
  145. package/deliver-great-systems/references/planning-config.md +224 -0
  146. package/deliver-great-systems/references/questioning.md +162 -0
  147. package/deliver-great-systems/references/spec-review-loop.md +177 -0
  148. package/deliver-great-systems/references/tdd.md +265 -0
  149. package/deliver-great-systems/references/ui-brand.md +160 -0
  150. package/deliver-great-systems/references/verification-patterns.md +612 -0
  151. package/deliver-great-systems/templates/DEBUG.md +166 -0
  152. package/deliver-great-systems/templates/UAT.md +251 -0
  153. package/deliver-great-systems/templates/VALIDATION.md +95 -0
  154. package/deliver-great-systems/templates/claude-md.md +74 -0
  155. package/deliver-great-systems/templates/codebase/architecture.md +257 -0
  156. package/deliver-great-systems/templates/codebase/concerns.md +312 -0
  157. package/deliver-great-systems/templates/codebase/conventions.md +309 -0
  158. package/deliver-great-systems/templates/codebase/integrations.md +282 -0
  159. package/deliver-great-systems/templates/codebase/stack.md +188 -0
  160. package/deliver-great-systems/templates/codebase/structure.md +287 -0
  161. package/deliver-great-systems/templates/codebase/testing.md +482 -0
  162. package/deliver-great-systems/templates/config.json +38 -0
  163. package/deliver-great-systems/templates/context.md +354 -0
  164. package/deliver-great-systems/templates/continue-here.md +80 -0
  165. package/deliver-great-systems/templates/debug-subagent-prompt.md +93 -0
  166. package/deliver-great-systems/templates/discovery.md +148 -0
  167. package/deliver-great-systems/templates/milestone-archive.md +125 -0
  168. package/deliver-great-systems/templates/milestone.md +117 -0
  169. package/deliver-great-systems/templates/phase-prompt.md +615 -0
  170. package/deliver-great-systems/templates/planner-subagent-prompt.md +119 -0
  171. package/deliver-great-systems/templates/project.md +186 -0
  172. package/deliver-great-systems/templates/requirements.md +233 -0
  173. package/deliver-great-systems/templates/research-project/ARCHITECTURE.md +206 -0
  174. package/deliver-great-systems/templates/research-project/FEATURES.md +149 -0
  175. package/deliver-great-systems/templates/research-project/PITFALLS.md +202 -0
  176. package/deliver-great-systems/templates/research-project/STACK.md +122 -0
  177. package/deliver-great-systems/templates/research-project/SUMMARY.md +172 -0
  178. package/deliver-great-systems/templates/research.md +554 -0
  179. package/deliver-great-systems/templates/retrospective.md +54 -0
  180. package/deliver-great-systems/templates/roadmap.md +204 -0
  181. package/deliver-great-systems/templates/state.md +178 -0
  182. package/deliver-great-systems/templates/summary-complex.md +59 -0
  183. package/deliver-great-systems/templates/summary-minimal.md +41 -0
  184. package/deliver-great-systems/templates/summary-standard.md +48 -0
  185. package/deliver-great-systems/templates/summary.md +253 -0
  186. package/deliver-great-systems/templates/user-setup.md +313 -0
  187. package/deliver-great-systems/templates/verification-report.md +324 -0
  188. package/deliver-great-systems/workflows/add-doc.md +151 -0
  189. package/deliver-great-systems/workflows/add-idea.md +96 -0
  190. package/deliver-great-systems/workflows/add-phase.md +120 -0
  191. package/deliver-great-systems/workflows/add-tests.md +359 -0
  192. package/deliver-great-systems/workflows/add-todo.md +162 -0
  193. package/deliver-great-systems/workflows/approve-spec.md +194 -0
  194. package/deliver-great-systems/workflows/audit-milestone.md +364 -0
  195. package/deliver-great-systems/workflows/audit-phase.md +462 -0
  196. package/deliver-great-systems/workflows/cancel-job.md +108 -0
  197. package/deliver-great-systems/workflows/check-todos.md +181 -0
  198. package/deliver-great-systems/workflows/cleanup.md +247 -0
  199. package/deliver-great-systems/workflows/codereview.md +526 -0
  200. package/deliver-great-systems/workflows/complete-milestone.md +1298 -0
  201. package/deliver-great-systems/workflows/consolidate-ideas.md +365 -0
  202. package/deliver-great-systems/workflows/create-milestone-job.md +177 -0
  203. package/deliver-great-systems/workflows/develop-idea.md +544 -0
  204. package/deliver-great-systems/workflows/diagnose-issues.md +231 -0
  205. package/deliver-great-systems/workflows/discovery-phase.md +301 -0
  206. package/deliver-great-systems/workflows/discuss-idea.md +263 -0
  207. package/deliver-great-systems/workflows/discuss-phase.md +733 -0
  208. package/deliver-great-systems/workflows/execute-phase.md +571 -0
  209. package/deliver-great-systems/workflows/execute-plan.md +592 -0
  210. package/deliver-great-systems/workflows/find-related-ideas.md +271 -0
  211. package/deliver-great-systems/workflows/health.md +173 -0
  212. package/deliver-great-systems/workflows/help.md +997 -0
  213. package/deliver-great-systems/workflows/import-spec.md +381 -0
  214. package/deliver-great-systems/workflows/init-product.md +767 -0
  215. package/deliver-great-systems/workflows/insert-phase.md +138 -0
  216. package/deliver-great-systems/workflows/list-docs.md +119 -0
  217. package/deliver-great-systems/workflows/list-ideas.md +154 -0
  218. package/deliver-great-systems/workflows/list-jobs.md +89 -0
  219. package/deliver-great-systems/workflows/list-phase-assumptions.md +192 -0
  220. package/deliver-great-systems/workflows/list-specs.md +101 -0
  221. package/deliver-great-systems/workflows/map-codebase.md +621 -0
  222. package/deliver-great-systems/workflows/new-milestone.md +591 -0
  223. package/deliver-great-systems/workflows/new-project.md +1113 -0
  224. package/deliver-great-systems/workflows/node-repair.md +94 -0
  225. package/deliver-great-systems/workflows/overlap-check.md +86 -0
  226. package/deliver-great-systems/workflows/pause-work.md +134 -0
  227. package/deliver-great-systems/workflows/plan-milestone-gaps.md +306 -0
  228. package/deliver-great-systems/workflows/plan-phase.md +698 -0
  229. package/deliver-great-systems/workflows/progress.md +386 -0
  230. package/deliver-great-systems/workflows/quick.md +845 -0
  231. package/deliver-great-systems/workflows/refine-spec.md +275 -0
  232. package/deliver-great-systems/workflows/reject-idea.md +109 -0
  233. package/deliver-great-systems/workflows/remove-doc.md +117 -0
  234. package/deliver-great-systems/workflows/remove-phase.md +163 -0
  235. package/deliver-great-systems/workflows/research-idea.md +325 -0
  236. package/deliver-great-systems/workflows/research-phase.md +81 -0
  237. package/deliver-great-systems/workflows/restore-idea.md +101 -0
  238. package/deliver-great-systems/workflows/resume-project.md +311 -0
  239. package/deliver-great-systems/workflows/rollback-job.md +130 -0
  240. package/deliver-great-systems/workflows/run-job.md +498 -0
  241. package/deliver-great-systems/workflows/search.md +130 -0
  242. package/deliver-great-systems/workflows/set-profile.md +83 -0
  243. package/deliver-great-systems/workflows/settings.md +470 -0
  244. package/deliver-great-systems/workflows/transition.md +563 -0
  245. package/deliver-great-systems/workflows/undo-consolidation.md +155 -0
  246. package/deliver-great-systems/workflows/update-idea.md +157 -0
  247. package/deliver-great-systems/workflows/update.md +242 -0
  248. package/deliver-great-systems/workflows/validate-phase.md +177 -0
  249. package/deliver-great-systems/workflows/verify-phase.md +253 -0
  250. package/deliver-great-systems/workflows/verify-work.md +671 -0
  251. package/deliver-great-systems/workflows/write-spec.md +450 -0
  252. package/hooks/dist/dgs-check-update.js +62 -0
  253. package/hooks/dist/dgs-context-monitor.js +141 -0
  254. package/hooks/dist/dgs-statusline.js +115 -0
  255. package/package.json +60 -0
  256. package/scripts/build-hooks.js +43 -0
@@ -0,0 +1,309 @@
1
+ # Coding Conventions Template
2
+
3
+ Template for `codebase/CONVENTIONS.md` (in planning root) - captures coding style and patterns.
4
+
5
+ > **Layout-agnostic:** Workflows access the codebase directory via `${codebase_dir}` from init output. Works in both standard and root layouts.
6
+
7
+ **Purpose:** Document how code is written in this codebase. Prescriptive guide for Claude to match existing style.
8
+
9
+ ---
10
+
11
+ ## File Template
12
+
13
+ ```markdown
14
+ # Coding Conventions
15
+
16
+ **Analysis Date:** [YYYY-MM-DD]
17
+
18
+ ## Naming Patterns
19
+
20
+ **Files:**
21
+ - [Pattern: e.g., "kebab-case for all files"]
22
+ - [Test files: e.g., "*.test.ts alongside source"]
23
+ - [Components: e.g., "PascalCase.tsx for React components"]
24
+
25
+ **Functions:**
26
+ - [Pattern: e.g., "camelCase for all functions"]
27
+ - [Async: e.g., "no special prefix for async functions"]
28
+ - [Handlers: e.g., "handleEventName for event handlers"]
29
+
30
+ **Variables:**
31
+ - [Pattern: e.g., "camelCase for variables"]
32
+ - [Constants: e.g., "UPPER_SNAKE_CASE for constants"]
33
+ - [Private: e.g., "_prefix for private members" or "no prefix"]
34
+
35
+ **Types:**
36
+ - [Interfaces: e.g., "PascalCase, no I prefix"]
37
+ - [Types: e.g., "PascalCase for type aliases"]
38
+ - [Enums: e.g., "PascalCase for enum name, UPPER_CASE for values"]
39
+
40
+ ## Code Style
41
+
42
+ **Formatting:**
43
+ - [Tool: e.g., "Prettier with config in .prettierrc"]
44
+ - [Line length: e.g., "100 characters max"]
45
+ - [Quotes: e.g., "single quotes for strings"]
46
+ - [Semicolons: e.g., "required" or "omitted"]
47
+
48
+ **Linting:**
49
+ - [Tool: e.g., "ESLint with eslint.config.js"]
50
+ - [Rules: e.g., "extends airbnb-base, no console in production"]
51
+ - [Run: e.g., "npm run lint"]
52
+
53
+ ## Import Organization
54
+
55
+ **Order:**
56
+ 1. [e.g., "External packages (react, express, etc.)"]
57
+ 2. [e.g., "Internal modules (@/lib, @/components)"]
58
+ 3. [e.g., "Relative imports (., ..)"]
59
+ 4. [e.g., "Type imports (import type {})"]
60
+
61
+ **Grouping:**
62
+ - [Blank lines: e.g., "blank line between groups"]
63
+ - [Sorting: e.g., "alphabetical within each group"]
64
+
65
+ **Path Aliases:**
66
+ - [Aliases used: e.g., "@/ for src/, @components/ for src/components/"]
67
+
68
+ ## Error Handling
69
+
70
+ **Patterns:**
71
+ - [Strategy: e.g., "throw errors, catch at boundaries"]
72
+ - [Custom errors: e.g., "extend Error class, named *Error"]
73
+ - [Async: e.g., "use try/catch, no .catch() chains"]
74
+
75
+ **Error Types:**
76
+ - [When to throw: e.g., "invalid input, missing dependencies"]
77
+ - [When to return: e.g., "expected failures return Result<T, E>"]
78
+ - [Logging: e.g., "log error with context before throwing"]
79
+
80
+ ## Logging
81
+
82
+ **Framework:**
83
+ - [Tool: e.g., "console.log, pino, winston"]
84
+ - [Levels: e.g., "debug, info, warn, error"]
85
+
86
+ **Patterns:**
87
+ - [Format: e.g., "structured logging with context object"]
88
+ - [When: e.g., "log state transitions, external calls"]
89
+ - [Where: e.g., "log at service boundaries, not in utils"]
90
+
91
+ ## Comments
92
+
93
+ **When to Comment:**
94
+ - [e.g., "explain why, not what"]
95
+ - [e.g., "document business logic, algorithms, edge cases"]
96
+ - [e.g., "avoid obvious comments like // increment counter"]
97
+
98
+ **JSDoc/TSDoc:**
99
+ - [Usage: e.g., "required for public APIs, optional for internal"]
100
+ - [Format: e.g., "use @param, @returns, @throws tags"]
101
+
102
+ **TODO Comments:**
103
+ - [Pattern: e.g., "// TODO(username): description"]
104
+ - [Tracking: e.g., "link to issue number if available"]
105
+
106
+ ## Function Design
107
+
108
+ **Size:**
109
+ - [e.g., "keep under 50 lines, extract helpers"]
110
+
111
+ **Parameters:**
112
+ - [e.g., "max 3 parameters, use object for more"]
113
+ - [e.g., "destructure objects in parameter list"]
114
+
115
+ **Return Values:**
116
+ - [e.g., "explicit returns, no implicit undefined"]
117
+ - [e.g., "return early for guard clauses"]
118
+
119
+ ## Module Design
120
+
121
+ **Exports:**
122
+ - [e.g., "named exports preferred, default exports for React components"]
123
+ - [e.g., "export from index.ts for public API"]
124
+
125
+ **Barrel Files:**
126
+ - [e.g., "use index.ts to re-export public API"]
127
+ - [e.g., "avoid circular dependencies"]
128
+
129
+ ---
130
+
131
+ *Convention analysis: [date]*
132
+ *Update when patterns change*
133
+ ```
134
+
135
+ <good_examples>
136
+ ```markdown
137
+ # Coding Conventions
138
+
139
+ **Analysis Date:** 2025-01-20
140
+
141
+ ## Naming Patterns
142
+
143
+ **Files:**
144
+ - kebab-case for all files (command-handler.ts, user-service.ts)
145
+ - *.test.ts alongside source files
146
+ - index.ts for barrel exports
147
+
148
+ **Functions:**
149
+ - camelCase for all functions
150
+ - No special prefix for async functions
151
+ - handleEventName for event handlers (handleClick, handleSubmit)
152
+
153
+ **Variables:**
154
+ - camelCase for variables
155
+ - UPPER_SNAKE_CASE for constants (MAX_RETRIES, API_BASE_URL)
156
+ - No underscore prefix (no private marker in TS)
157
+
158
+ **Types:**
159
+ - PascalCase for interfaces, no I prefix (User, not IUser)
160
+ - PascalCase for type aliases (UserConfig, ResponseData)
161
+ - PascalCase for enum names, UPPER_CASE for values (Status.PENDING)
162
+
163
+ ## Code Style
164
+
165
+ **Formatting:**
166
+ - Prettier with .prettierrc
167
+ - 100 character line length
168
+ - Single quotes for strings
169
+ - Semicolons required
170
+ - 2 space indentation
171
+
172
+ **Linting:**
173
+ - ESLint with eslint.config.js
174
+ - Extends @typescript-eslint/recommended
175
+ - No console.log in production code (use logger)
176
+ - Run: npm run lint
177
+
178
+ ## Import Organization
179
+
180
+ **Order:**
181
+ 1. External packages (react, express, commander)
182
+ 2. Internal modules (@/lib, @/services)
183
+ 3. Relative imports (./utils, ../types)
184
+ 4. Type imports (import type { User })
185
+
186
+ **Grouping:**
187
+ - Blank line between groups
188
+ - Alphabetical within each group
189
+ - Type imports last within each group
190
+
191
+ **Path Aliases:**
192
+ - @/ maps to src/
193
+ - No other aliases defined
194
+
195
+ ## Error Handling
196
+
197
+ **Patterns:**
198
+ - Throw errors, catch at boundaries (route handlers, main functions)
199
+ - Extend Error class for custom errors (ValidationError, NotFoundError)
200
+ - Async functions use try/catch, no .catch() chains
201
+
202
+ **Error Types:**
203
+ - Throw on invalid input, missing dependencies, invariant violations
204
+ - Log error with context before throwing: logger.error({ err, userId }, 'Failed to process')
205
+ - Include cause in error message: new Error('Failed to X', { cause: originalError })
206
+
207
+ ## Logging
208
+
209
+ **Framework:**
210
+ - pino logger instance exported from lib/logger.ts
211
+ - Levels: debug, info, warn, error (no trace)
212
+
213
+ **Patterns:**
214
+ - Structured logging with context: logger.info({ userId, action }, 'User action')
215
+ - Log at service boundaries, not in utility functions
216
+ - Log state transitions, external API calls, errors
217
+ - No console.log in committed code
218
+
219
+ ## Comments
220
+
221
+ **When to Comment:**
222
+ - Explain why, not what: // Retry 3 times because API has transient failures
223
+ - Document business rules: // Users must verify email within 24 hours
224
+ - Explain non-obvious algorithms or workarounds
225
+ - Avoid obvious comments: // set count to 0
226
+
227
+ **JSDoc/TSDoc:**
228
+ - Required for public API functions
229
+ - Optional for internal functions if signature is self-explanatory
230
+ - Use @param, @returns, @throws tags
231
+
232
+ **TODO Comments:**
233
+ - Format: // TODO: description (no username, using git blame)
234
+ - Link to issue if exists: // TODO: Fix race condition (issue #123)
235
+
236
+ ## Function Design
237
+
238
+ **Size:**
239
+ - Keep under 50 lines
240
+ - Extract helpers for complex logic
241
+ - One level of abstraction per function
242
+
243
+ **Parameters:**
244
+ - Max 3 parameters
245
+ - Use options object for 4+ parameters: function create(options: CreateOptions)
246
+ - Destructure in parameter list: function process({ id, name }: ProcessParams)
247
+
248
+ **Return Values:**
249
+ - Explicit return statements
250
+ - Return early for guard clauses
251
+ - Use Result<T, E> type for expected failures
252
+
253
+ ## Module Design
254
+
255
+ **Exports:**
256
+ - Named exports preferred
257
+ - Default exports only for React components
258
+ - Export public API from index.ts barrel files
259
+
260
+ **Barrel Files:**
261
+ - index.ts re-exports public API
262
+ - Keep internal helpers private (don't export from index)
263
+ - Avoid circular dependencies (import from specific files if needed)
264
+
265
+ ---
266
+
267
+ *Convention analysis: 2025-01-20*
268
+ *Update when patterns change*
269
+ ```
270
+ </good_examples>
271
+
272
+ <guidelines>
273
+ **What belongs in CONVENTIONS.md:**
274
+ - Naming patterns observed in the codebase
275
+ - Formatting rules (Prettier config, linting rules)
276
+ - Import organization patterns
277
+ - Error handling strategy
278
+ - Logging approach
279
+ - Comment conventions
280
+ - Function and module design patterns
281
+
282
+ **What does NOT belong here:**
283
+ - Architecture decisions (that's ARCHITECTURE.md)
284
+ - Technology choices (that's STACK.md)
285
+ - Test patterns (that's TESTING.md)
286
+ - File organization (that's STRUCTURE.md)
287
+
288
+ **When filling this template:**
289
+ - Check .prettierrc, .eslintrc, or similar config files
290
+ - Examine 5-10 representative source files for patterns
291
+ - Look for consistency: if 80%+ follows a pattern, document it
292
+ - Be prescriptive: "Use X" not "Sometimes Y is used"
293
+ - Note deviations: "Legacy code uses Y, new code should use X"
294
+ - Keep under ~150 lines total
295
+
296
+ **Useful for phase planning when:**
297
+ - Writing new code (match existing style)
298
+ - Adding features (follow naming patterns)
299
+ - Refactoring (apply consistent conventions)
300
+ - Code review (check against documented patterns)
301
+ - Onboarding (understand style expectations)
302
+
303
+ **Analysis approach:**
304
+ - Scan src/ directory for file naming patterns
305
+ - Check package.json scripts for lint/format commands
306
+ - Read 5-10 files to identify function naming, error handling
307
+ - Look for config files (.prettierrc, eslint.config.js)
308
+ - Note patterns in imports, comments, function signatures
309
+ </guidelines>
@@ -0,0 +1,282 @@
1
+ # External Integrations Template
2
+
3
+ Template for `codebase/INTEGRATIONS.md` (in planning root) - captures external service dependencies.
4
+
5
+ > **Layout-agnostic:** Workflows access the codebase directory via `${codebase_dir}` from init output. Works in both standard and root layouts.
6
+
7
+ **Purpose:** Document what external systems this codebase communicates with. Focused on "what lives outside our code that we depend on."
8
+
9
+ ---
10
+
11
+ ## File Template
12
+
13
+ ```markdown
14
+ # External Integrations
15
+
16
+ **Analysis Date:** [YYYY-MM-DD]
17
+
18
+ ## APIs & External Services
19
+
20
+ **Payment Processing:**
21
+ - [Service] - [What it's used for: e.g., "subscription billing, one-time payments"]
22
+ - SDK/Client: [e.g., "stripe npm package v14.x"]
23
+ - Auth: [e.g., "API key in STRIPE_SECRET_KEY env var"]
24
+ - Endpoints used: [e.g., "checkout sessions, webhooks"]
25
+
26
+ **Email/SMS:**
27
+ - [Service] - [What it's used for: e.g., "transactional emails"]
28
+ - SDK/Client: [e.g., "sendgrid/mail v8.x"]
29
+ - Auth: [e.g., "API key in SENDGRID_API_KEY env var"]
30
+ - Templates: [e.g., "managed in SendGrid dashboard"]
31
+
32
+ **External APIs:**
33
+ - [Service] - [What it's used for]
34
+ - Integration method: [e.g., "REST API via fetch", "GraphQL client"]
35
+ - Auth: [e.g., "OAuth2 token in AUTH_TOKEN env var"]
36
+ - Rate limits: [if applicable]
37
+
38
+ ## Data Storage
39
+
40
+ **Databases:**
41
+ - [Type/Provider] - [e.g., "PostgreSQL on Supabase"]
42
+ - Connection: [e.g., "via DATABASE_URL env var"]
43
+ - Client: [e.g., "Prisma ORM v5.x"]
44
+ - Migrations: [e.g., "prisma migrate in migrations/"]
45
+
46
+ **File Storage:**
47
+ - [Service] - [e.g., "AWS S3 for user uploads"]
48
+ - SDK/Client: [e.g., "@aws-sdk/client-s3"]
49
+ - Auth: [e.g., "IAM credentials in AWS_* env vars"]
50
+ - Buckets: [e.g., "prod-uploads, dev-uploads"]
51
+
52
+ **Caching:**
53
+ - [Service] - [e.g., "Redis for session storage"]
54
+ - Connection: [e.g., "REDIS_URL env var"]
55
+ - Client: [e.g., "ioredis v5.x"]
56
+
57
+ ## Authentication & Identity
58
+
59
+ **Auth Provider:**
60
+ - [Service] - [e.g., "Supabase Auth", "Auth0", "custom JWT"]
61
+ - Implementation: [e.g., "Supabase client SDK"]
62
+ - Token storage: [e.g., "httpOnly cookies", "localStorage"]
63
+ - Session management: [e.g., "JWT refresh tokens"]
64
+
65
+ **OAuth Integrations:**
66
+ - [Provider] - [e.g., "Google OAuth for sign-in"]
67
+ - Credentials: [e.g., "GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET"]
68
+ - Scopes: [e.g., "email, profile"]
69
+
70
+ ## Monitoring & Observability
71
+
72
+ **Error Tracking:**
73
+ - [Service] - [e.g., "Sentry"]
74
+ - DSN: [e.g., "SENTRY_DSN env var"]
75
+ - Release tracking: [e.g., "via SENTRY_RELEASE"]
76
+
77
+ **Analytics:**
78
+ - [Service] - [e.g., "Mixpanel for product analytics"]
79
+ - Token: [e.g., "MIXPANEL_TOKEN env var"]
80
+ - Events tracked: [e.g., "user actions, page views"]
81
+
82
+ **Logs:**
83
+ - [Service] - [e.g., "CloudWatch", "Datadog", "none (stdout only)"]
84
+ - Integration: [e.g., "AWS Lambda built-in"]
85
+
86
+ ## CI/CD & Deployment
87
+
88
+ **Hosting:**
89
+ - [Platform] - [e.g., "Vercel", "AWS Lambda", "Docker on ECS"]
90
+ - Deployment: [e.g., "automatic on main branch push"]
91
+ - Environment vars: [e.g., "configured in Vercel dashboard"]
92
+
93
+ **CI Pipeline:**
94
+ - [Service] - [e.g., "GitHub Actions"]
95
+ - Workflows: [e.g., "test.yml, deploy.yml"]
96
+ - Secrets: [e.g., "stored in GitHub repo secrets"]
97
+
98
+ ## Environment Configuration
99
+
100
+ **Development:**
101
+ - Required env vars: [List critical vars]
102
+ - Secrets location: [e.g., ".env.local (gitignored)", "1Password vault"]
103
+ - Mock/stub services: [e.g., "Stripe test mode", "local PostgreSQL"]
104
+
105
+ **Staging:**
106
+ - Environment-specific differences: [e.g., "uses staging Stripe account"]
107
+ - Data: [e.g., "separate staging database"]
108
+
109
+ **Production:**
110
+ - Secrets management: [e.g., "Vercel environment variables"]
111
+ - Failover/redundancy: [e.g., "multi-region DB replication"]
112
+
113
+ ## Webhooks & Callbacks
114
+
115
+ **Incoming:**
116
+ - [Service] - [Endpoint: e.g., "/api/webhooks/stripe"]
117
+ - Verification: [e.g., "signature validation via stripe.webhooks.constructEvent"]
118
+ - Events: [e.g., "payment_intent.succeeded, customer.subscription.updated"]
119
+
120
+ **Outgoing:**
121
+ - [Service] - [What triggers it]
122
+ - Endpoint: [e.g., "external CRM webhook on user signup"]
123
+ - Retry logic: [if applicable]
124
+
125
+ ---
126
+
127
+ *Integration audit: [date]*
128
+ *Update when adding/removing external services*
129
+ ```
130
+
131
+ <good_examples>
132
+ ```markdown
133
+ # External Integrations
134
+
135
+ **Analysis Date:** 2025-01-20
136
+
137
+ ## APIs & External Services
138
+
139
+ **Payment Processing:**
140
+ - Stripe - Subscription billing and one-time course payments
141
+ - SDK/Client: stripe npm package v14.8
142
+ - Auth: API key in STRIPE_SECRET_KEY env var
143
+ - Endpoints used: checkout sessions, customer portal, webhooks
144
+
145
+ **Email/SMS:**
146
+ - SendGrid - Transactional emails (receipts, password resets)
147
+ - SDK/Client: @sendgrid/mail v8.1
148
+ - Auth: API key in SENDGRID_API_KEY env var
149
+ - Templates: Managed in SendGrid dashboard (template IDs in code)
150
+
151
+ **External APIs:**
152
+ - OpenAI API - Course content generation
153
+ - Integration method: REST API via openai npm package v4.x
154
+ - Auth: Bearer token in OPENAI_API_KEY env var
155
+ - Rate limits: 3500 requests/min (tier 3)
156
+
157
+ ## Data Storage
158
+
159
+ **Databases:**
160
+ - PostgreSQL on Supabase - Primary data store
161
+ - Connection: via DATABASE_URL env var
162
+ - Client: Prisma ORM v5.8
163
+ - Migrations: prisma migrate in prisma/migrations/
164
+
165
+ **File Storage:**
166
+ - Supabase Storage - User uploads (profile images, course materials)
167
+ - SDK/Client: @supabase/supabase-js v2.x
168
+ - Auth: Service role key in SUPABASE_SERVICE_ROLE_KEY
169
+ - Buckets: avatars (public), course-materials (private)
170
+
171
+ **Caching:**
172
+ - None currently (all database queries, no Redis)
173
+
174
+ ## Authentication & Identity
175
+
176
+ **Auth Provider:**
177
+ - Supabase Auth - Email/password + OAuth
178
+ - Implementation: Supabase client SDK with server-side session management
179
+ - Token storage: httpOnly cookies via @supabase/ssr
180
+ - Session management: JWT refresh tokens handled by Supabase
181
+
182
+ **OAuth Integrations:**
183
+ - Google OAuth - Social sign-in
184
+ - Credentials: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET (Supabase dashboard)
185
+ - Scopes: email, profile
186
+
187
+ ## Monitoring & Observability
188
+
189
+ **Error Tracking:**
190
+ - Sentry - Server and client errors
191
+ - DSN: SENTRY_DSN env var
192
+ - Release tracking: Git commit SHA via SENTRY_RELEASE
193
+
194
+ **Analytics:**
195
+ - None (planned: Mixpanel)
196
+
197
+ **Logs:**
198
+ - Vercel logs - stdout/stderr only
199
+ - Retention: 7 days on Pro plan
200
+
201
+ ## CI/CD & Deployment
202
+
203
+ **Hosting:**
204
+ - Vercel - Next.js app hosting
205
+ - Deployment: Automatic on main branch push
206
+ - Environment vars: Configured in Vercel dashboard (synced to .env.example)
207
+
208
+ **CI Pipeline:**
209
+ - GitHub Actions - Tests and type checking
210
+ - Workflows: .github/workflows/ci.yml
211
+ - Secrets: None needed (public repo tests only)
212
+
213
+ ## Environment Configuration
214
+
215
+ **Development:**
216
+ - Required env vars: DATABASE_URL, NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY
217
+ - Secrets location: .env.local (gitignored), team shared via 1Password vault
218
+ - Mock/stub services: Stripe test mode, Supabase local dev project
219
+
220
+ **Staging:**
221
+ - Uses separate Supabase staging project
222
+ - Stripe test mode
223
+ - Same Vercel account, different environment
224
+
225
+ **Production:**
226
+ - Secrets management: Vercel environment variables
227
+ - Database: Supabase production project with daily backups
228
+
229
+ ## Webhooks & Callbacks
230
+
231
+ **Incoming:**
232
+ - Stripe - /api/webhooks/stripe
233
+ - Verification: Signature validation via stripe.webhooks.constructEvent
234
+ - Events: payment_intent.succeeded, customer.subscription.updated, customer.subscription.deleted
235
+
236
+ **Outgoing:**
237
+ - None
238
+
239
+ ---
240
+
241
+ *Integration audit: 2025-01-20*
242
+ *Update when adding/removing external services*
243
+ ```
244
+ </good_examples>
245
+
246
+ <guidelines>
247
+ **What belongs in INTEGRATIONS.md:**
248
+ - External services the code communicates with
249
+ - Authentication patterns (where secrets live, not the secrets themselves)
250
+ - SDKs and client libraries used
251
+ - Environment variable names (not values)
252
+ - Webhook endpoints and verification methods
253
+ - Database connection patterns
254
+ - File storage locations
255
+ - Monitoring and logging services
256
+
257
+ **What does NOT belong here:**
258
+ - Actual API keys or secrets (NEVER write these)
259
+ - Internal architecture (that's ARCHITECTURE.md)
260
+ - Code patterns (that's PATTERNS.md)
261
+ - Technology choices (that's STACK.md)
262
+ - Performance issues (that's CONCERNS.md)
263
+
264
+ **When filling this template:**
265
+ - Check .env.example or .env.template for required env vars
266
+ - Look for SDK imports (stripe, @sendgrid/mail, etc.)
267
+ - Check for webhook handlers in routes/endpoints
268
+ - Note where secrets are managed (not the secrets)
269
+ - Document environment-specific differences (dev/staging/prod)
270
+ - Include auth patterns for each service
271
+
272
+ **Useful for phase planning when:**
273
+ - Adding new external service integrations
274
+ - Debugging authentication issues
275
+ - Understanding data flow outside the application
276
+ - Setting up new environments
277
+ - Auditing third-party dependencies
278
+ - Planning for service outages or migrations
279
+
280
+ **Security note:**
281
+ Document WHERE secrets live (env vars, Vercel dashboard, 1Password), never WHAT the secrets are.
282
+ </guidelines>