@howlil/ez-agents 3.4.1 → 3.5.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 (162) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -20
  3. package/agents/ez-observer-agent.md +260 -0
  4. package/agents/ez-release-agent.md +333 -0
  5. package/agents/ez-requirements-agent.md +377 -0
  6. package/agents/ez-scrum-master-agent.md +242 -0
  7. package/agents/ez-tech-lead-agent.md +267 -0
  8. package/bin/install.js +3221 -3230
  9. package/commands/ez/arch-review.md +102 -0
  10. package/commands/ez/execute-phase.md +11 -0
  11. package/commands/ez/export-session.md +79 -0
  12. package/commands/ez/gather-requirements.md +117 -0
  13. package/commands/ez/git-workflow.md +72 -0
  14. package/commands/ez/hotfix.md +120 -0
  15. package/commands/ez/import-session.md +82 -0
  16. package/commands/ez/join-discord.md +18 -18
  17. package/commands/ez/list-sessions.md +96 -0
  18. package/commands/ez/package-manager.md +316 -0
  19. package/commands/ez/plan-phase.md +9 -1
  20. package/commands/ez/preflight.md +79 -0
  21. package/commands/ez/progress.md +13 -1
  22. package/commands/ez/release.md +153 -0
  23. package/commands/ez/resume.md +107 -0
  24. package/commands/ez/standup.md +85 -0
  25. package/ez-agents/bin/ez-tools.cjs +1095 -716
  26. package/ez-agents/bin/lib/assistant-adapter.cjs +264 -264
  27. package/ez-agents/bin/lib/audit-exec.cjs +7 -2
  28. package/ez-agents/bin/lib/bdd-validator.cjs +622 -0
  29. package/ez-agents/bin/lib/circuit-breaker.cjs +118 -118
  30. package/ez-agents/bin/lib/config.cjs +190 -190
  31. package/ez-agents/bin/lib/content-scanner.cjs +238 -0
  32. package/ez-agents/bin/lib/context-cache.cjs +154 -0
  33. package/ez-agents/bin/lib/context-errors.cjs +71 -0
  34. package/ez-agents/bin/lib/context-manager.cjs +220 -0
  35. package/ez-agents/bin/lib/discussion-synthesizer.cjs +458 -0
  36. package/ez-agents/bin/lib/file-access.cjs +207 -0
  37. package/ez-agents/bin/lib/file-lock.cjs +236 -236
  38. package/ez-agents/bin/lib/frontmatter.cjs +299 -299
  39. package/ez-agents/bin/lib/fs-utils.cjs +153 -153
  40. package/ez-agents/bin/lib/git-errors.cjs +83 -0
  41. package/ez-agents/bin/lib/git-utils.cjs +118 -0
  42. package/ez-agents/bin/lib/git-workflow-engine.cjs +1157 -0
  43. package/ez-agents/bin/lib/index.cjs +157 -113
  44. package/ez-agents/bin/lib/init.cjs +757 -757
  45. package/ez-agents/bin/lib/lockfile-validator.cjs +227 -0
  46. package/ez-agents/bin/lib/logger.cjs +124 -124
  47. package/ez-agents/bin/lib/memory-compression.cjs +256 -0
  48. package/ez-agents/bin/lib/metrics-tracker.cjs +406 -0
  49. package/ez-agents/bin/lib/milestone.cjs +241 -241
  50. package/ez-agents/bin/lib/model-provider.cjs +241 -241
  51. package/ez-agents/bin/lib/package-manager-detector.cjs +203 -0
  52. package/ez-agents/bin/lib/package-manager-executor.cjs +385 -0
  53. package/ez-agents/bin/lib/package-manager-service.cjs +216 -0
  54. package/ez-agents/bin/lib/phase.cjs +925 -925
  55. package/ez-agents/bin/lib/planning-write.cjs +107 -107
  56. package/ez-agents/bin/lib/release-validator.cjs +614 -0
  57. package/ez-agents/bin/lib/retry.cjs +119 -119
  58. package/ez-agents/bin/lib/roadmap.cjs +306 -306
  59. package/ez-agents/bin/lib/safe-exec.cjs +128 -128
  60. package/ez-agents/bin/lib/safe-path.cjs +130 -130
  61. package/ez-agents/bin/lib/session-chain.cjs +304 -0
  62. package/ez-agents/bin/lib/session-errors.cjs +81 -0
  63. package/ez-agents/bin/lib/session-export.cjs +251 -0
  64. package/ez-agents/bin/lib/session-import.cjs +262 -0
  65. package/ez-agents/bin/lib/session-manager.cjs +280 -0
  66. package/ez-agents/bin/lib/state.cjs +736 -736
  67. package/ez-agents/bin/lib/temp-file.cjs +239 -239
  68. package/ez-agents/bin/lib/template.cjs +223 -223
  69. package/ez-agents/bin/lib/test-file-lock.cjs +112 -112
  70. package/ez-agents/bin/lib/test-graceful.cjs +93 -93
  71. package/ez-agents/bin/lib/test-logger.cjs +60 -60
  72. package/ez-agents/bin/lib/test-safe-exec.cjs +38 -38
  73. package/ez-agents/bin/lib/test-safe-path.cjs +33 -33
  74. package/ez-agents/bin/lib/test-temp-file.cjs +125 -125
  75. package/ez-agents/bin/lib/tier-manager.cjs +428 -0
  76. package/ez-agents/bin/lib/timeout-exec.cjs +63 -63
  77. package/ez-agents/bin/lib/url-fetch.cjs +170 -0
  78. package/ez-agents/bin/lib/verify.cjs +15 -1
  79. package/ez-agents/references/checkpoints.md +776 -776
  80. package/ez-agents/references/continuation-format.md +249 -249
  81. package/ez-agents/references/metrics-schema.md +118 -0
  82. package/ez-agents/references/planning-config.md +140 -0
  83. package/ez-agents/references/questioning.md +162 -162
  84. package/ez-agents/references/tdd.md +263 -263
  85. package/ez-agents/references/tier-strategy.md +103 -0
  86. package/ez-agents/templates/bdd-feature.md +173 -0
  87. package/ez-agents/templates/codebase/concerns.md +310 -310
  88. package/ez-agents/templates/codebase/conventions.md +307 -307
  89. package/ez-agents/templates/codebase/integrations.md +280 -280
  90. package/ez-agents/templates/codebase/stack.md +186 -186
  91. package/ez-agents/templates/codebase/testing.md +480 -480
  92. package/ez-agents/templates/config.json +37 -37
  93. package/ez-agents/templates/continue-here.md +78 -78
  94. package/ez-agents/templates/discussion.md +68 -0
  95. package/ez-agents/templates/incident-runbook.md +205 -0
  96. package/ez-agents/templates/milestone-archive.md +123 -123
  97. package/ez-agents/templates/milestone.md +115 -115
  98. package/ez-agents/templates/release-checklist.md +133 -0
  99. package/ez-agents/templates/requirements.md +231 -231
  100. package/ez-agents/templates/research-project/ARCHITECTURE.md +204 -204
  101. package/ez-agents/templates/research-project/FEATURES.md +147 -147
  102. package/ez-agents/templates/research-project/PITFALLS.md +200 -200
  103. package/ez-agents/templates/research-project/STACK.md +120 -120
  104. package/ez-agents/templates/research-project/SUMMARY.md +170 -170
  105. package/ez-agents/templates/retrospective.md +54 -54
  106. package/ez-agents/templates/roadmap.md +202 -202
  107. package/ez-agents/templates/rollback-plan.md +201 -0
  108. package/ez-agents/templates/summary-minimal.md +41 -41
  109. package/ez-agents/templates/summary-standard.md +48 -48
  110. package/ez-agents/templates/summary.md +248 -248
  111. package/ez-agents/templates/user-setup.md +311 -311
  112. package/ez-agents/templates/verification-report.md +322 -322
  113. package/ez-agents/workflows/add-phase.md +112 -112
  114. package/ez-agents/workflows/add-tests.md +351 -351
  115. package/ez-agents/workflows/add-todo.md +158 -158
  116. package/ez-agents/workflows/arch-review.md +54 -0
  117. package/ez-agents/workflows/audit-milestone.md +332 -332
  118. package/ez-agents/workflows/autonomous.md +131 -30
  119. package/ez-agents/workflows/check-todos.md +177 -177
  120. package/ez-agents/workflows/cleanup.md +152 -152
  121. package/ez-agents/workflows/complete-milestone.md +766 -766
  122. package/ez-agents/workflows/diagnose-issues.md +219 -219
  123. package/ez-agents/workflows/discovery-phase.md +289 -289
  124. package/ez-agents/workflows/discuss-phase.md +762 -762
  125. package/ez-agents/workflows/execute-phase.md +513 -468
  126. package/ez-agents/workflows/execute-plan.md +483 -483
  127. package/ez-agents/workflows/export-session.md +255 -0
  128. package/ez-agents/workflows/gather-requirements.md +206 -0
  129. package/ez-agents/workflows/health.md +159 -159
  130. package/ez-agents/workflows/help.md +584 -492
  131. package/ez-agents/workflows/hotfix.md +291 -0
  132. package/ez-agents/workflows/import-session.md +303 -0
  133. package/ez-agents/workflows/insert-phase.md +130 -130
  134. package/ez-agents/workflows/list-phase-assumptions.md +178 -178
  135. package/ez-agents/workflows/map-codebase.md +316 -316
  136. package/ez-agents/workflows/new-milestone.md +339 -10
  137. package/ez-agents/workflows/new-project.md +293 -299
  138. package/ez-agents/workflows/node-repair.md +92 -92
  139. package/ez-agents/workflows/pause-work.md +122 -122
  140. package/ez-agents/workflows/plan-milestone-gaps.md +274 -274
  141. package/ez-agents/workflows/plan-phase.md +673 -651
  142. package/ez-agents/workflows/progress.md +372 -382
  143. package/ez-agents/workflows/quick.md +610 -610
  144. package/ez-agents/workflows/release.md +253 -0
  145. package/ez-agents/workflows/remove-phase.md +155 -155
  146. package/ez-agents/workflows/research-phase.md +74 -74
  147. package/ez-agents/workflows/resume-project.md +307 -307
  148. package/ez-agents/workflows/resume-session.md +215 -0
  149. package/ez-agents/workflows/set-profile.md +81 -81
  150. package/ez-agents/workflows/settings.md +242 -242
  151. package/ez-agents/workflows/standup.md +64 -0
  152. package/ez-agents/workflows/stats.md +57 -57
  153. package/ez-agents/workflows/transition.md +544 -544
  154. package/ez-agents/workflows/ui-phase.md +290 -290
  155. package/ez-agents/workflows/ui-review.md +157 -157
  156. package/ez-agents/workflows/update.md +320 -320
  157. package/ez-agents/workflows/validate-phase.md +167 -167
  158. package/ez-agents/workflows/verify-phase.md +243 -243
  159. package/ez-agents/workflows/verify-work.md +584 -584
  160. package/package.json +10 -4
  161. package/scripts/build-hooks.js +43 -43
  162. package/scripts/run-tests.cjs +29 -29
@@ -1,307 +1,307 @@
1
- # Coding Conventions Template
2
-
3
- Template for `.planning/codebase/CONVENTIONS.md` - captures coding style and patterns.
4
-
5
- **Purpose:** Document how code is written in this codebase. Prescriptive guide for Claude to match existing style.
6
-
7
- ---
8
-
9
- ## File Template
10
-
11
- ```markdown
12
- # Coding Conventions
13
-
14
- **Analysis Date:** [YYYY-MM-DD]
15
-
16
- ## Naming Patterns
17
-
18
- **Files:**
19
- - [Pattern: e.g., "kebab-case for all files"]
20
- - [Test files: e.g., "*.test.ts alongside source"]
21
- - [Components: e.g., "PascalCase.tsx for React components"]
22
-
23
- **Functions:**
24
- - [Pattern: e.g., "camelCase for all functions"]
25
- - [Async: e.g., "no special prefix for async functions"]
26
- - [Handlers: e.g., "handleEventName for event handlers"]
27
-
28
- **Variables:**
29
- - [Pattern: e.g., "camelCase for variables"]
30
- - [Constants: e.g., "UPPER_SNAKE_CASE for constants"]
31
- - [Private: e.g., "_prefix for private members" or "no prefix"]
32
-
33
- **Types:**
34
- - [Interfaces: e.g., "PascalCase, no I prefix"]
35
- - [Types: e.g., "PascalCase for type aliases"]
36
- - [Enums: e.g., "PascalCase for enum name, UPPER_CASE for values"]
37
-
38
- ## Code Style
39
-
40
- **Formatting:**
41
- - [Tool: e.g., "Prettier with config in .prettierrc"]
42
- - [Line length: e.g., "100 characters max"]
43
- - [Quotes: e.g., "single quotes for strings"]
44
- - [Semicolons: e.g., "required" or "omitted"]
45
-
46
- **Linting:**
47
- - [Tool: e.g., "ESLint with eslint.config.js"]
48
- - [Rules: e.g., "extends airbnb-base, no console in production"]
49
- - [Run: e.g., "npm run lint"]
50
-
51
- ## Import Organization
52
-
53
- **Order:**
54
- 1. [e.g., "External packages (react, express, etc.)"]
55
- 2. [e.g., "Internal modules (@/lib, @/components)"]
56
- 3. [e.g., "Relative imports (., ..)"]
57
- 4. [e.g., "Type imports (import type {})"]
58
-
59
- **Grouping:**
60
- - [Blank lines: e.g., "blank line between groups"]
61
- - [Sorting: e.g., "alphabetical within each group"]
62
-
63
- **Path Aliases:**
64
- - [Aliases used: e.g., "@/ for src/, @components/ for src/components/"]
65
-
66
- ## Error Handling
67
-
68
- **Patterns:**
69
- - [Strategy: e.g., "throw errors, catch at boundaries"]
70
- - [Custom errors: e.g., "extend Error class, named *Error"]
71
- - [Async: e.g., "use try/catch, no .catch() chains"]
72
-
73
- **Error Types:**
74
- - [When to throw: e.g., "invalid input, missing dependencies"]
75
- - [When to return: e.g., "expected failures return Result<T, E>"]
76
- - [Logging: e.g., "log error with context before throwing"]
77
-
78
- ## Logging
79
-
80
- **Framework:**
81
- - [Tool: e.g., "console.log, pino, winston"]
82
- - [Levels: e.g., "debug, info, warn, error"]
83
-
84
- **Patterns:**
85
- - [Format: e.g., "structured logging with context object"]
86
- - [When: e.g., "log state transitions, external calls"]
87
- - [Where: e.g., "log at service boundaries, not in utils"]
88
-
89
- ## Comments
90
-
91
- **When to Comment:**
92
- - [e.g., "explain why, not what"]
93
- - [e.g., "document business logic, algorithms, edge cases"]
94
- - [e.g., "avoid obvious comments like // increment counter"]
95
-
96
- **JSDoc/TSDoc:**
97
- - [Usage: e.g., "required for public APIs, optional for internal"]
98
- - [Format: e.g., "use @param, @returns, @throws tags"]
99
-
100
- **TODO Comments:**
101
- - [Pattern: e.g., "// TODO(username): description"]
102
- - [Tracking: e.g., "link to issue number if available"]
103
-
104
- ## Function Design
105
-
106
- **Size:**
107
- - [e.g., "keep under 50 lines, extract helpers"]
108
-
109
- **Parameters:**
110
- - [e.g., "max 3 parameters, use object for more"]
111
- - [e.g., "destructure objects in parameter list"]
112
-
113
- **Return Values:**
114
- - [e.g., "explicit returns, no implicit undefined"]
115
- - [e.g., "return early for guard clauses"]
116
-
117
- ## Module Design
118
-
119
- **Exports:**
120
- - [e.g., "named exports preferred, default exports for React components"]
121
- - [e.g., "export from index.ts for public API"]
122
-
123
- **Barrel Files:**
124
- - [e.g., "use index.ts to re-export public API"]
125
- - [e.g., "avoid circular dependencies"]
126
-
127
- ---
128
-
129
- *Convention analysis: [date]*
130
- *Update when patterns change*
131
- ```
132
-
133
- <good_examples>
134
- ```markdown
135
- # Coding Conventions
136
-
137
- **Analysis Date:** 2025-01-20
138
-
139
- ## Naming Patterns
140
-
141
- **Files:**
142
- - kebab-case for all files (command-handler.ts, user-service.ts)
143
- - *.test.ts alongside source files
144
- - index.ts for barrel exports
145
-
146
- **Functions:**
147
- - camelCase for all functions
148
- - No special prefix for async functions
149
- - handleEventName for event handlers (handleClick, handleSubmit)
150
-
151
- **Variables:**
152
- - camelCase for variables
153
- - UPPER_SNAKE_CASE for constants (MAX_RETRIES, API_BASE_URL)
154
- - No underscore prefix (no private marker in TS)
155
-
156
- **Types:**
157
- - PascalCase for interfaces, no I prefix (User, not IUser)
158
- - PascalCase for type aliases (UserConfig, ResponseData)
159
- - PascalCase for enum names, UPPER_CASE for values (Status.PENDING)
160
-
161
- ## Code Style
162
-
163
- **Formatting:**
164
- - Prettier with .prettierrc
165
- - 100 character line length
166
- - Single quotes for strings
167
- - Semicolons required
168
- - 2 space indentation
169
-
170
- **Linting:**
171
- - ESLint with eslint.config.js
172
- - Extends @typescript-eslint/recommended
173
- - No console.log in production code (use logger)
174
- - Run: npm run lint
175
-
176
- ## Import Organization
177
-
178
- **Order:**
179
- 1. External packages (react, express, commander)
180
- 2. Internal modules (@/lib, @/services)
181
- 3. Relative imports (./utils, ../types)
182
- 4. Type imports (import type { User })
183
-
184
- **Grouping:**
185
- - Blank line between groups
186
- - Alphabetical within each group
187
- - Type imports last within each group
188
-
189
- **Path Aliases:**
190
- - @/ maps to src/
191
- - No other aliases defined
192
-
193
- ## Error Handling
194
-
195
- **Patterns:**
196
- - Throw errors, catch at boundaries (route handlers, main functions)
197
- - Extend Error class for custom errors (ValidationError, NotFoundError)
198
- - Async functions use try/catch, no .catch() chains
199
-
200
- **Error Types:**
201
- - Throw on invalid input, missing dependencies, invariant violations
202
- - Log error with context before throwing: logger.error({ err, userId }, 'Failed to process')
203
- - Include cause in error message: new Error('Failed to X', { cause: originalError })
204
-
205
- ## Logging
206
-
207
- **Framework:**
208
- - pino logger instance exported from lib/logger.ts
209
- - Levels: debug, info, warn, error (no trace)
210
-
211
- **Patterns:**
212
- - Structured logging with context: logger.info({ userId, action }, 'User action')
213
- - Log at service boundaries, not in utility functions
214
- - Log state transitions, external API calls, errors
215
- - No console.log in committed code
216
-
217
- ## Comments
218
-
219
- **When to Comment:**
220
- - Explain why, not what: // Retry 3 times because API has transient failures
221
- - Document business rules: // Users must verify email within 24 hours
222
- - Explain non-obvious algorithms or workarounds
223
- - Avoid obvious comments: // set count to 0
224
-
225
- **JSDoc/TSDoc:**
226
- - Required for public API functions
227
- - Optional for internal functions if signature is self-explanatory
228
- - Use @param, @returns, @throws tags
229
-
230
- **TODO Comments:**
231
- - Format: // TODO: description (no username, using git blame)
232
- - Link to issue if exists: // TODO: Fix race condition (issue #123)
233
-
234
- ## Function Design
235
-
236
- **Size:**
237
- - Keep under 50 lines
238
- - Extract helpers for complex logic
239
- - One level of abstraction per function
240
-
241
- **Parameters:**
242
- - Max 3 parameters
243
- - Use options object for 4+ parameters: function create(options: CreateOptions)
244
- - Destructure in parameter list: function process({ id, name }: ProcessParams)
245
-
246
- **Return Values:**
247
- - Explicit return statements
248
- - Return early for guard clauses
249
- - Use Result<T, E> type for expected failures
250
-
251
- ## Module Design
252
-
253
- **Exports:**
254
- - Named exports preferred
255
- - Default exports only for React components
256
- - Export public API from index.ts barrel files
257
-
258
- **Barrel Files:**
259
- - index.ts re-exports public API
260
- - Keep internal helpers private (don't export from index)
261
- - Avoid circular dependencies (import from specific files if needed)
262
-
263
- ---
264
-
265
- *Convention analysis: 2025-01-20*
266
- *Update when patterns change*
267
- ```
268
- </good_examples>
269
-
270
- <guidelines>
271
- **What belongs in CONVENTIONS.md:**
272
- - Naming patterns observed in the codebase
273
- - Formatting rules (Prettier config, linting rules)
274
- - Import organization patterns
275
- - Error handling strategy
276
- - Logging approach
277
- - Comment conventions
278
- - Function and module design patterns
279
-
280
- **What does NOT belong here:**
281
- - Architecture decisions (that's ARCHITECTURE.md)
282
- - Technology choices (that's STACK.md)
283
- - Test patterns (that's TESTING.md)
284
- - File organization (that's STRUCTURE.md)
285
-
286
- **When filling this template:**
287
- - Check .prettierrc, .eslintrc, or similar config files
288
- - Examine 5-10 representative source files for patterns
289
- - Look for consistency: if 80%+ follows a pattern, document it
290
- - Be prescriptive: "Use X" not "Sometimes Y is used"
291
- - Note deviations: "Legacy code uses Y, new code should use X"
292
- - Keep under ~150 lines total
293
-
294
- **Useful for phase planning when:**
295
- - Writing new code (match existing style)
296
- - Adding features (follow naming patterns)
297
- - Refactoring (apply consistent conventions)
298
- - Code review (check against documented patterns)
299
- - Onboarding (understand style expectations)
300
-
301
- **Analysis approach:**
302
- - Scan src/ directory for file naming patterns
303
- - Check package.json scripts for lint/format commands
304
- - Read 5-10 files to identify function naming, error handling
305
- - Look for config files (.prettierrc, eslint.config.js)
306
- - Note patterns in imports, comments, function signatures
307
- </guidelines>
1
+ # Coding Conventions Template
2
+
3
+ Template for `.planning/codebase/CONVENTIONS.md` - captures coding style and patterns.
4
+
5
+ **Purpose:** Document how code is written in this codebase. Prescriptive guide for Claude to match existing style.
6
+
7
+ ---
8
+
9
+ ## File Template
10
+
11
+ ```markdown
12
+ # Coding Conventions
13
+
14
+ **Analysis Date:** [YYYY-MM-DD]
15
+
16
+ ## Naming Patterns
17
+
18
+ **Files:**
19
+ - [Pattern: e.g., "kebab-case for all files"]
20
+ - [Test files: e.g., "*.test.ts alongside source"]
21
+ - [Components: e.g., "PascalCase.tsx for React components"]
22
+
23
+ **Functions:**
24
+ - [Pattern: e.g., "camelCase for all functions"]
25
+ - [Async: e.g., "no special prefix for async functions"]
26
+ - [Handlers: e.g., "handleEventName for event handlers"]
27
+
28
+ **Variables:**
29
+ - [Pattern: e.g., "camelCase for variables"]
30
+ - [Constants: e.g., "UPPER_SNAKE_CASE for constants"]
31
+ - [Private: e.g., "_prefix for private members" or "no prefix"]
32
+
33
+ **Types:**
34
+ - [Interfaces: e.g., "PascalCase, no I prefix"]
35
+ - [Types: e.g., "PascalCase for type aliases"]
36
+ - [Enums: e.g., "PascalCase for enum name, UPPER_CASE for values"]
37
+
38
+ ## Code Style
39
+
40
+ **Formatting:**
41
+ - [Tool: e.g., "Prettier with config in .prettierrc"]
42
+ - [Line length: e.g., "100 characters max"]
43
+ - [Quotes: e.g., "single quotes for strings"]
44
+ - [Semicolons: e.g., "required" or "omitted"]
45
+
46
+ **Linting:**
47
+ - [Tool: e.g., "ESLint with eslint.config.js"]
48
+ - [Rules: e.g., "extends airbnb-base, no console in production"]
49
+ - [Run: e.g., "npm run lint"]
50
+
51
+ ## Import Organization
52
+
53
+ **Order:**
54
+ 1. [e.g., "External packages (react, express, etc.)"]
55
+ 2. [e.g., "Internal modules (@/lib, @/components)"]
56
+ 3. [e.g., "Relative imports (., ..)"]
57
+ 4. [e.g., "Type imports (import type {})"]
58
+
59
+ **Grouping:**
60
+ - [Blank lines: e.g., "blank line between groups"]
61
+ - [Sorting: e.g., "alphabetical within each group"]
62
+
63
+ **Path Aliases:**
64
+ - [Aliases used: e.g., "@/ for src/, @components/ for src/components/"]
65
+
66
+ ## Error Handling
67
+
68
+ **Patterns:**
69
+ - [Strategy: e.g., "throw errors, catch at boundaries"]
70
+ - [Custom errors: e.g., "extend Error class, named *Error"]
71
+ - [Async: e.g., "use try/catch, no .catch() chains"]
72
+
73
+ **Error Types:**
74
+ - [When to throw: e.g., "invalid input, missing dependencies"]
75
+ - [When to return: e.g., "expected failures return Result<T, E>"]
76
+ - [Logging: e.g., "log error with context before throwing"]
77
+
78
+ ## Logging
79
+
80
+ **Framework:**
81
+ - [Tool: e.g., "console.log, pino, winston"]
82
+ - [Levels: e.g., "debug, info, warn, error"]
83
+
84
+ **Patterns:**
85
+ - [Format: e.g., "structured logging with context object"]
86
+ - [When: e.g., "log state transitions, external calls"]
87
+ - [Where: e.g., "log at service boundaries, not in utils"]
88
+
89
+ ## Comments
90
+
91
+ **When to Comment:**
92
+ - [e.g., "explain why, not what"]
93
+ - [e.g., "document business logic, algorithms, edge cases"]
94
+ - [e.g., "avoid obvious comments like // increment counter"]
95
+
96
+ **JSDoc/TSDoc:**
97
+ - [Usage: e.g., "required for public APIs, optional for internal"]
98
+ - [Format: e.g., "use @param, @returns, @throws tags"]
99
+
100
+ **TODO Comments:**
101
+ - [Pattern: e.g., "// TODO(username): description"]
102
+ - [Tracking: e.g., "link to issue number if available"]
103
+
104
+ ## Function Design
105
+
106
+ **Size:**
107
+ - [e.g., "keep under 50 lines, extract helpers"]
108
+
109
+ **Parameters:**
110
+ - [e.g., "max 3 parameters, use object for more"]
111
+ - [e.g., "destructure objects in parameter list"]
112
+
113
+ **Return Values:**
114
+ - [e.g., "explicit returns, no implicit undefined"]
115
+ - [e.g., "return early for guard clauses"]
116
+
117
+ ## Module Design
118
+
119
+ **Exports:**
120
+ - [e.g., "named exports preferred, default exports for React components"]
121
+ - [e.g., "export from index.ts for public API"]
122
+
123
+ **Barrel Files:**
124
+ - [e.g., "use index.ts to re-export public API"]
125
+ - [e.g., "avoid circular dependencies"]
126
+
127
+ ---
128
+
129
+ *Convention analysis: [date]*
130
+ *Update when patterns change*
131
+ ```
132
+
133
+ <good_examples>
134
+ ```markdown
135
+ # Coding Conventions
136
+
137
+ **Analysis Date:** 2025-01-20
138
+
139
+ ## Naming Patterns
140
+
141
+ **Files:**
142
+ - kebab-case for all files (command-handler.ts, user-service.ts)
143
+ - *.test.ts alongside source files
144
+ - index.ts for barrel exports
145
+
146
+ **Functions:**
147
+ - camelCase for all functions
148
+ - No special prefix for async functions
149
+ - handleEventName for event handlers (handleClick, handleSubmit)
150
+
151
+ **Variables:**
152
+ - camelCase for variables
153
+ - UPPER_SNAKE_CASE for constants (MAX_RETRIES, API_BASE_URL)
154
+ - No underscore prefix (no private marker in TS)
155
+
156
+ **Types:**
157
+ - PascalCase for interfaces, no I prefix (User, not IUser)
158
+ - PascalCase for type aliases (UserConfig, ResponseData)
159
+ - PascalCase for enum names, UPPER_CASE for values (Status.PENDING)
160
+
161
+ ## Code Style
162
+
163
+ **Formatting:**
164
+ - Prettier with .prettierrc
165
+ - 100 character line length
166
+ - Single quotes for strings
167
+ - Semicolons required
168
+ - 2 space indentation
169
+
170
+ **Linting:**
171
+ - ESLint with eslint.config.js
172
+ - Extends @typescript-eslint/recommended
173
+ - No console.log in production code (use logger)
174
+ - Run: npm run lint
175
+
176
+ ## Import Organization
177
+
178
+ **Order:**
179
+ 1. External packages (react, express, commander)
180
+ 2. Internal modules (@/lib, @/services)
181
+ 3. Relative imports (./utils, ../types)
182
+ 4. Type imports (import type { User })
183
+
184
+ **Grouping:**
185
+ - Blank line between groups
186
+ - Alphabetical within each group
187
+ - Type imports last within each group
188
+
189
+ **Path Aliases:**
190
+ - @/ maps to src/
191
+ - No other aliases defined
192
+
193
+ ## Error Handling
194
+
195
+ **Patterns:**
196
+ - Throw errors, catch at boundaries (route handlers, main functions)
197
+ - Extend Error class for custom errors (ValidationError, NotFoundError)
198
+ - Async functions use try/catch, no .catch() chains
199
+
200
+ **Error Types:**
201
+ - Throw on invalid input, missing dependencies, invariant violations
202
+ - Log error with context before throwing: logger.error({ err, userId }, 'Failed to process')
203
+ - Include cause in error message: new Error('Failed to X', { cause: originalError })
204
+
205
+ ## Logging
206
+
207
+ **Framework:**
208
+ - pino logger instance exported from lib/logger.ts
209
+ - Levels: debug, info, warn, error (no trace)
210
+
211
+ **Patterns:**
212
+ - Structured logging with context: logger.info({ userId, action }, 'User action')
213
+ - Log at service boundaries, not in utility functions
214
+ - Log state transitions, external API calls, errors
215
+ - No console.log in committed code
216
+
217
+ ## Comments
218
+
219
+ **When to Comment:**
220
+ - Explain why, not what: // Retry 3 times because API has transient failures
221
+ - Document business rules: // Users must verify email within 24 hours
222
+ - Explain non-obvious algorithms or workarounds
223
+ - Avoid obvious comments: // set count to 0
224
+
225
+ **JSDoc/TSDoc:**
226
+ - Required for public API functions
227
+ - Optional for internal functions if signature is self-explanatory
228
+ - Use @param, @returns, @throws tags
229
+
230
+ **TODO Comments:**
231
+ - Format: // TODO: description (no username, using git blame)
232
+ - Link to issue if exists: // TODO: Fix race condition (issue #123)
233
+
234
+ ## Function Design
235
+
236
+ **Size:**
237
+ - Keep under 50 lines
238
+ - Extract helpers for complex logic
239
+ - One level of abstraction per function
240
+
241
+ **Parameters:**
242
+ - Max 3 parameters
243
+ - Use options object for 4+ parameters: function create(options: CreateOptions)
244
+ - Destructure in parameter list: function process({ id, name }: ProcessParams)
245
+
246
+ **Return Values:**
247
+ - Explicit return statements
248
+ - Return early for guard clauses
249
+ - Use Result<T, E> type for expected failures
250
+
251
+ ## Module Design
252
+
253
+ **Exports:**
254
+ - Named exports preferred
255
+ - Default exports only for React components
256
+ - Export public API from index.ts barrel files
257
+
258
+ **Barrel Files:**
259
+ - index.ts re-exports public API
260
+ - Keep internal helpers private (don't export from index)
261
+ - Avoid circular dependencies (import from specific files if needed)
262
+
263
+ ---
264
+
265
+ *Convention analysis: 2025-01-20*
266
+ *Update when patterns change*
267
+ ```
268
+ </good_examples>
269
+
270
+ <guidelines>
271
+ **What belongs in CONVENTIONS.md:**
272
+ - Naming patterns observed in the codebase
273
+ - Formatting rules (Prettier config, linting rules)
274
+ - Import organization patterns
275
+ - Error handling strategy
276
+ - Logging approach
277
+ - Comment conventions
278
+ - Function and module design patterns
279
+
280
+ **What does NOT belong here:**
281
+ - Architecture decisions (that's ARCHITECTURE.md)
282
+ - Technology choices (that's STACK.md)
283
+ - Test patterns (that's TESTING.md)
284
+ - File organization (that's STRUCTURE.md)
285
+
286
+ **When filling this template:**
287
+ - Check .prettierrc, .eslintrc, or similar config files
288
+ - Examine 5-10 representative source files for patterns
289
+ - Look for consistency: if 80%+ follows a pattern, document it
290
+ - Be prescriptive: "Use X" not "Sometimes Y is used"
291
+ - Note deviations: "Legacy code uses Y, new code should use X"
292
+ - Keep under ~150 lines total
293
+
294
+ **Useful for phase planning when:**
295
+ - Writing new code (match existing style)
296
+ - Adding features (follow naming patterns)
297
+ - Refactoring (apply consistent conventions)
298
+ - Code review (check against documented patterns)
299
+ - Onboarding (understand style expectations)
300
+
301
+ **Analysis approach:**
302
+ - Scan src/ directory for file naming patterns
303
+ - Check package.json scripts for lint/format commands
304
+ - Read 5-10 files to identify function naming, error handling
305
+ - Look for config files (.prettierrc, eslint.config.js)
306
+ - Note patterns in imports, comments, function signatures
307
+ </guidelines>