plan-flow-skill 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.claude/commands/create-contract.md +468 -0
  2. package/.claude/commands/create-plan.md +512 -0
  3. package/.claude/commands/discovery-plan.md +561 -0
  4. package/.claude/commands/execute-plan.md +682 -0
  5. package/.claude/commands/review-code.md +459 -0
  6. package/.claude/commands/review-pr.md +651 -0
  7. package/.claude/commands/setup.md +1609 -0
  8. package/.claude/commands/write-tests.md +543 -0
  9. package/.claude/rules/core/allowed-patterns.md +175 -0
  10. package/.claude/rules/core/complexity-scoring.md +225 -0
  11. package/.claude/rules/core/forbidden-patterns.md +253 -0
  12. package/.claude/rules/languages/python-patterns.md +6 -0
  13. package/.claude/rules/languages/typescript-patterns.md +7 -0
  14. package/.claude/rules/patterns/contract-patterns.md +332 -0
  15. package/.claude/rules/patterns/discovery-patterns.md +342 -0
  16. package/.claude/rules/patterns/discovery-templates.md +319 -0
  17. package/.claude/rules/patterns/jest-patterns.md +482 -0
  18. package/.claude/rules/patterns/plans-patterns.md +225 -0
  19. package/.claude/rules/patterns/plans-templates.md +227 -0
  20. package/.claude/rules/patterns/pytest-patterns.md +457 -0
  21. package/.claude/rules/patterns/review-code-templates.md +305 -0
  22. package/.claude/rules/patterns/review-pr-patterns.md +360 -0
  23. package/.claude/rules/tools/auth-pr-tool.md +30 -0
  24. package/.claude/rules/tools/interactive-questions-tool.md +235 -0
  25. package/.claude/rules/tools/jest-testing-tool.md +73 -0
  26. package/.claude/rules/tools/plan-mode-tool.md +164 -0
  27. package/.claude/rules/tools/pytest-testing-tool.md +121 -0
  28. package/.claude/rules/tools/reference-expansion-tool.md +326 -0
  29. package/LICENSE +21 -0
  30. package/README.md +167 -0
  31. package/dist/cli/commands/init.d.ts +6 -0
  32. package/dist/cli/commands/init.d.ts.map +1 -0
  33. package/dist/cli/commands/init.js +139 -0
  34. package/dist/cli/commands/init.js.map +1 -0
  35. package/dist/cli/handlers/claude.d.ts +9 -0
  36. package/dist/cli/handlers/claude.d.ts.map +1 -0
  37. package/dist/cli/handlers/claude.js +119 -0
  38. package/dist/cli/handlers/claude.js.map +1 -0
  39. package/dist/cli/handlers/codex.d.ts +9 -0
  40. package/dist/cli/handlers/codex.d.ts.map +1 -0
  41. package/dist/cli/handlers/codex.js +100 -0
  42. package/dist/cli/handlers/codex.js.map +1 -0
  43. package/dist/cli/handlers/cursor.d.ts +8 -0
  44. package/dist/cli/handlers/cursor.d.ts.map +1 -0
  45. package/dist/cli/handlers/cursor.js +34 -0
  46. package/dist/cli/handlers/cursor.js.map +1 -0
  47. package/dist/cli/handlers/openclaw.d.ts +8 -0
  48. package/dist/cli/handlers/openclaw.d.ts.map +1 -0
  49. package/dist/cli/handlers/openclaw.js +34 -0
  50. package/dist/cli/handlers/openclaw.js.map +1 -0
  51. package/dist/cli/handlers/shared.d.ts +9 -0
  52. package/dist/cli/handlers/shared.d.ts.map +1 -0
  53. package/dist/cli/handlers/shared.js +44 -0
  54. package/dist/cli/handlers/shared.js.map +1 -0
  55. package/dist/cli/index.d.ts +8 -0
  56. package/dist/cli/index.d.ts.map +1 -0
  57. package/dist/cli/index.js +43 -0
  58. package/dist/cli/index.js.map +1 -0
  59. package/dist/cli/types.d.ts +26 -0
  60. package/dist/cli/types.d.ts.map +1 -0
  61. package/dist/cli/types.js +5 -0
  62. package/dist/cli/types.js.map +1 -0
  63. package/dist/cli/utils/files.d.ts +37 -0
  64. package/dist/cli/utils/files.d.ts.map +1 -0
  65. package/dist/cli/utils/files.js +122 -0
  66. package/dist/cli/utils/files.js.map +1 -0
  67. package/dist/cli/utils/logger.d.ts +11 -0
  68. package/dist/cli/utils/logger.d.ts.map +1 -0
  69. package/dist/cli/utils/logger.js +34 -0
  70. package/dist/cli/utils/logger.js.map +1 -0
  71. package/dist/cli/utils/prompts.d.ts +10 -0
  72. package/dist/cli/utils/prompts.d.ts.map +1 -0
  73. package/dist/cli/utils/prompts.js +65 -0
  74. package/dist/cli/utils/prompts.js.map +1 -0
  75. package/dist/test/setup.d.ts +5 -0
  76. package/dist/test/setup.d.ts.map +1 -0
  77. package/dist/test/setup.js +7 -0
  78. package/dist/test/setup.js.map +1 -0
  79. package/package.json +63 -0
  80. package/rules/core/_index.mdc +89 -0
  81. package/rules/core/allowed-patterns.mdc +185 -0
  82. package/rules/core/complexity-scoring.mdc +235 -0
  83. package/rules/core/forbidden-patterns.mdc +263 -0
  84. package/rules/languages/_index.mdc +80 -0
  85. package/rules/languages/python-patterns.mdc +188 -0
  86. package/rules/languages/typescript-patterns.mdc +128 -0
  87. package/rules/patterns/_index.mdc +185 -0
  88. package/rules/patterns/contract-patterns.mdc +344 -0
  89. package/rules/patterns/discovery-patterns.mdc +354 -0
  90. package/rules/patterns/discovery-templates.mdc +329 -0
  91. package/rules/patterns/jest-patterns.mdc +492 -0
  92. package/rules/patterns/plans-patterns.mdc +237 -0
  93. package/rules/patterns/plans-templates.mdc +237 -0
  94. package/rules/patterns/pytest-patterns.mdc +467 -0
  95. package/rules/patterns/review-code-templates.mdc +315 -0
  96. package/rules/patterns/review-pr-patterns.mdc +370 -0
  97. package/rules/skills/_index.mdc +174 -0
  98. package/rules/skills/create-contract-skill.mdc +239 -0
  99. package/rules/skills/create-plan-skill.mdc +271 -0
  100. package/rules/skills/discovery-skill.mdc +295 -0
  101. package/rules/skills/execute-plan-skill.mdc +388 -0
  102. package/rules/skills/review-code-skill.mdc +308 -0
  103. package/rules/skills/review-pr-skill.mdc +496 -0
  104. package/rules/skills/setup-skill.mdc +923 -0
  105. package/rules/skills/write-tests-skill.mdc +294 -0
  106. package/rules/templates/index-template.mdc +126 -0
  107. package/rules/tools/_index.mdc +114 -0
  108. package/rules/tools/auth-pr-tool.mdc +362 -0
  109. package/rules/tools/interactive-questions-tool.mdc +337 -0
  110. package/rules/tools/jest-testing-tool.mdc +96 -0
  111. package/rules/tools/plan-mode-tool.mdc +229 -0
  112. package/rules/tools/pytest-testing-tool.mdc +144 -0
  113. package/rules/tools/reference-expansion-tool.mdc +338 -0
  114. package/skills/plan-flow/SKILL.md +109 -0
  115. package/skills/plan-flow/create-contract/SKILL.md +139 -0
  116. package/skills/plan-flow/create-plan/SKILL.md +93 -0
  117. package/skills/plan-flow/discovery/SKILL.md +85 -0
  118. package/skills/plan-flow/execute-plan/SKILL.md +89 -0
  119. package/skills/plan-flow/review-code/SKILL.md +100 -0
  120. package/skills/plan-flow/review-pr/SKILL.md +122 -0
  121. package/skills/plan-flow/setup/SKILL.md +73 -0
  122. package/skills/plan-flow/write-tests/SKILL.md +115 -0
  123. package/templates/shared/AGENTS.md.template +60 -0
  124. package/templates/shared/CLAUDE.md.template +62 -0
@@ -0,0 +1,305 @@
1
+
2
+ ## Output Format
3
+
4
+ The generated review document should follow this structure:
5
+
6
+ ```markdown
7
+ # Local Code Review: {Description}
8
+
9
+ ## Review Information
10
+
11
+ | Field | Value |
12
+ | -------------- | --------------------- |
13
+ | Date | {date} |
14
+ | Files Reviewed | {number_of_files} |
15
+ | Scope | {all/staged/unstaged} |
16
+ | Language(s) | {detected_languages} |
17
+
18
+ ---
19
+
20
+ ## Changed Files
21
+
22
+ | File | Status | Lines Changed |
23
+ | ------------- | ---------- | ------------- |
24
+ | `{file_path}` | {modified} | +{add}/-{del} |
25
+ | ... | ... | ... |
26
+
27
+ ---
28
+
29
+ ## Reference Implementations Found
30
+
31
+ For each changed file, similar implementations in the codebase:
32
+
33
+ ### {changed_file_path}
34
+
35
+ **Similar implementations found:**
36
+
37
+ | Reference File | Pattern Observed | Consistency |
38
+ | --------------------- | --------------------- | -------------- |
39
+ | `{similar_file_path}` | {pattern_description} | Match/Conflict |
40
+ | ... | ... | ... |
41
+
42
+ **Pattern Notes:**
43
+
44
+ - {observation about how similar code handles the same concern}
45
+
46
+ ---
47
+
48
+ ## Review Summary
49
+
50
+ | Metric | Value |
51
+ | --------------------- | ------------------ |
52
+ | **Total Findings** | {count} |
53
+ | Critical | {critical_count} |
54
+ | Major | {major_count} |
55
+ | Minor | {minor_count} |
56
+ | Suggestion | {suggestion_count} |
57
+ | **Pattern Conflicts** | {conflict_count} |
58
+ | **Total Fix Effort** | {sum_of_scores}/X |
59
+
60
+ ---
61
+
62
+ ## Findings
63
+
64
+ ### Finding 1: {Finding Name}
65
+
66
+ | Field | Value |
67
+ | -------------- | ------------------------------------------------ |
68
+ | File | `{file_path}` |
69
+ | Line | {line_number} |
70
+ | Severity | {Critical/Major/Minor/Suggestion} |
71
+ | Fix Complexity | {X/10} - {Level} |
72
+ | Pattern | {Reference to pattern from rules, if applicable} |
73
+
74
+ **Description**:
75
+ {Detailed explanation of the issue found}
76
+
77
+ **Reference Implementation**:
78
+ See `{reference_file_path}` for how this is handled elsewhere in the codebase.
79
+
80
+ **Suggested Fix**:
81
+ \`\`\`{language}
82
+ // Suggested code improvement
83
+ \`\`\`
84
+
85
+ ---
86
+
87
+ ## Pattern Conflicts
88
+
89
+ This section documents conflicts between the new code and existing codebase patterns.
90
+
91
+ ### Conflict 1: {Conflict Name}
92
+
93
+ | Field | Value |
94
+ | -------------- | -------------------------------------- |
95
+ | New Code File | `{changed_file_path}` |
96
+ | Reference File | `{existing_file_path}` |
97
+ | Pattern Type | {naming/structure/error-handling/etc} |
98
+ | Resolution | {Update new code/Update rules/Discuss} |
99
+
100
+ **New Code Pattern**:
101
+ \`\`\`{language}
102
+ // Pattern used in new code
103
+ \`\`\`
104
+
105
+ **Existing Pattern**:
106
+ \`\`\`{language}
107
+ // Pattern used in existing codebase
108
+ \`\`\`
109
+
110
+ **Recommendation**:
111
+ {Which pattern to use and why}
112
+
113
+ ---
114
+
115
+ ## Rule Update Recommendations
116
+
117
+ When pattern conflicts are found, recommend updates to prevent future inconsistencies.
118
+
119
+ ### Recommended Addition to `allowed-patterns.md`
120
+
121
+ If a good pattern is discovered that isn't documented:
122
+
123
+ \`\`\`markdown
124
+
125
+ ### {Pattern Name}
126
+
127
+ {Description of the pattern}
128
+
129
+ \`\`\`typescript
130
+ // Example of the pattern
131
+ \`\`\`
132
+
133
+ **Why**: {Explanation of benefit}
134
+ \`\`\`
135
+
136
+ ### Recommended Addition to `forbidden-patterns.md`
137
+
138
+ If an anti-pattern is found that should be avoided:
139
+
140
+ \`\`\`markdown
141
+
142
+ ### DON'T: {Pattern Name}
143
+
144
+ **Problem**: {Description of why this is problematic}
145
+
146
+ \`\`\`typescript
147
+ // BAD - Example of the anti-pattern
148
+ \`\`\`
149
+
150
+ **Why This is Wrong**:
151
+
152
+ - {Reason 1}
153
+ - {Reason 2}
154
+
155
+ **Fix**: {Description of the correct approach}
156
+ \`\`\`
157
+
158
+ ---
159
+
160
+ ## Positive Highlights
161
+
162
+ List any particularly well-written code or good practices observed:
163
+
164
+ - {Highlight 1}
165
+ - {Highlight 2}
166
+
167
+ ---
168
+
169
+ ## Commit Readiness
170
+
171
+ | Status | {Ready to Commit/Needs Changes/Needs Discussion} |
172
+ | ------ | ------------------------------------------------ |
173
+ | Reason | {Brief explanation} |
174
+
175
+ ### Before Committing
176
+
177
+ - [ ] Address all Critical findings
178
+ - [ ] Address all Major findings
179
+ - [ ] Review Pattern Conflicts and decide on resolution
180
+ - [ ] Update rules files if new patterns should be documented
181
+ ```
182
+
183
+ ---
184
+
185
+ ## Example Output
186
+
187
+ ### Pattern Conflict Example
188
+
189
+ ```markdown
190
+ ### Conflict 1: Error Handling Pattern
191
+
192
+ | Field | Value |
193
+ | -------------- | ------------------------------ |
194
+ | New Code File | `src/services/userService.ts` |
195
+ | Reference File | `src/services/orderService.ts` |
196
+ | Pattern Type | error-handling |
197
+ | Resolution | Update new code |
198
+
199
+ **New Code Pattern**:
200
+ \`\`\`typescript
201
+ try {
202
+ await saveUser(data);
203
+ } catch (e) {
204
+ console.log(e); // Silent console log
205
+ return null;
206
+ }
207
+ \`\`\`
208
+
209
+ **Existing Pattern**:
210
+ \`\`\`typescript
211
+ try {
212
+ await saveOrder(data);
213
+ } catch (error) {
214
+ logger.error('Failed to save order', { error, orderId: data.id });
215
+ throw new ServiceError('Unable to save order');
216
+ }
217
+ \`\`\`
218
+
219
+ **Recommendation**:
220
+ Update new code to follow the established error handling pattern from `orderService.ts`. The existing pattern properly logs errors with context and throws a meaningful error for the caller to handle.
221
+ ```
222
+
223
+ ### Rule Update Recommendation Example
224
+
225
+ ```markdown
226
+ ## Rule Update Recommendations
227
+
228
+ ### Recommended Addition to `allowed-patterns.md`
229
+
230
+ \`\`\`markdown
231
+
232
+ ### Service Layer Error Handling
233
+
234
+ All service layer functions should handle errors with proper logging and re-throw with meaningful error types.
235
+
236
+ \`\`\`typescript
237
+ // GOOD - Service layer error handling
238
+ try {
239
+ await performOperation(data);
240
+ } catch (error) {
241
+ logger.error('Operation failed', { error, context: data.id });
242
+ throw new ServiceError('Operation failed', { cause: error });
243
+ }
244
+ \`\`\`
245
+
246
+ **Why**: Ensures errors are traceable in logs while providing meaningful errors to callers.
247
+ \`\`\`
248
+
249
+ ### Recommended Addition to `forbidden-patterns.md`
250
+
251
+ \`\`\`markdown
252
+
253
+ ### DON'T: Silent Console Logging in Services
254
+
255
+ **Problem**: Using console.log for errors in service layer loses context and makes debugging difficult.
256
+
257
+ \`\`\`typescript
258
+ // BAD - Silent console log
259
+ catch (e) {
260
+ console.log(e);
261
+ return null;
262
+ }
263
+ \`\`\`
264
+
265
+ **Why This is Wrong**:
266
+
267
+ - console.log doesn't persist in production logging systems
268
+ - Returning null hides the error from callers
269
+ - No context about what operation failed
270
+
271
+ **Fix**: Use structured logger and throw meaningful errors.
272
+ \`\`\`
273
+ ```
274
+
275
+ ---
276
+
277
+ ## Finding Example
278
+
279
+ ```markdown
280
+ ### Finding 1: Silent Error Swallowing
281
+
282
+ | Field | Value |
283
+ | -------------- | ----------------------------- |
284
+ | File | `src/services/userService.ts` |
285
+ | Line | 45 |
286
+ | Severity | Major |
287
+ | Fix Complexity | 3/10 - Low |
288
+ | Pattern | forbidden-patterns.md |
289
+
290
+ **Description**:
291
+ The catch block catches an error but only logs it to console and returns null. This hides errors from callers and makes debugging difficult.
292
+
293
+ **Reference Implementation**:
294
+ See `src/services/orderService.ts` for proper error handling pattern.
295
+
296
+ **Suggested Fix**:
297
+ \`\`\`typescript
298
+ try {
299
+ await saveUser(data);
300
+ } catch (error) {
301
+ logger.error('Failed to save user', { error, userId: data.id });
302
+ throw new ServiceError('Unable to save user', { cause: error });
303
+ }
304
+ \`\`\`
305
+ ```
@@ -0,0 +1,360 @@
1
+
2
+ ## How to Use This File
3
+
4
+ 1. **Analyze the existing codebase** to understand the patterns, conventions, and architectural decisions already established in the project. Look at:
5
+ - Naming conventions used throughout the codebase
6
+ - Code organization and folder structure
7
+ - Error handling approaches
8
+ - Testing patterns and frameworks in use
9
+ - Existing abstractions and utilities
10
+ - Configuration and dependency management style
11
+ 2. **Identify the language(s)** in the PR being reviewed
12
+ 3. **Apply general review patterns** from this file
13
+ 4. **Reference language-specific patterns** based on the codebase:
14
+ - For TypeScript/JavaScript: See `.claude/rules/languages/typescript-patterns.md`
15
+ - For Python: See `.claude/rules/languages/python-patterns.md`
16
+ 5. **Cross-check against forbidden patterns** in `.claude/rules/core/forbidden-patterns.md`
17
+ 6. **Validate alignment with allowed patterns** in `.claude/rules/core/allowed-patterns.md`
18
+
19
+ > **Important:** The patterns already present in the project take precedence. New code should be consistent with the existing codebase style, even if it differs slightly from generic best practices.
20
+
21
+ ---
22
+
23
+ ## General PR Review Checklist
24
+
25
+ ### 1. Code Quality
26
+
27
+ Before approving any PR, verify the following:
28
+
29
+ - [ ] Code follows the patterns defined in `.claude/rules/core/allowed-patterns.md`
30
+ - [ ] Code avoids anti-patterns defined in `.claude/rules/core/forbidden-patterns.md`
31
+ - [ ] Code adheres to language-specific patterns (see Language-Specific Reviews section)
32
+ - [ ] No magic numbers or hardcoded values without context
33
+ - [ ] Error handling is explicit and meaningful
34
+ - [ ] Functions and components follow single responsibility principle
35
+
36
+ ### 2. Naming and Readability
37
+
38
+ - [ ] Variables, functions, and classes have descriptive names
39
+ - [ ] Code is self-documenting where possible
40
+ - [ ] Complex logic has appropriate comments explaining the "why"
41
+ - [ ] Consistent naming conventions throughout the PR
42
+
43
+ ### 3. Testing
44
+
45
+ - [ ] New functionality has corresponding tests
46
+ - [ ] Edge cases are covered
47
+ - [ ] Tests are readable and follow AAA pattern (Arrange, Act, Assert)
48
+ - [ ] No flaky or timing-dependent tests
49
+
50
+ ### 4. Security
51
+
52
+ - [ ] No hardcoded secrets, API keys, or credentials
53
+ - [ ] User inputs are validated and sanitized
54
+ - [ ] Authentication and authorization are properly checked
55
+ - [ ] Sensitive data is handled appropriately
56
+
57
+ ### 5. Performance
58
+
59
+ - [ ] No unnecessary loops or repeated computations
60
+ - [ ] Appropriate use of caching where applicable
61
+ - [ ] No N+1 query problems
62
+ - [ ] Large data sets are handled efficiently
63
+
64
+ ---
65
+
66
+ ## Language-Specific Reviews
67
+
68
+ ### TypeScript/JavaScript PRs
69
+
70
+ When reviewing TypeScript or JavaScript code, apply these additional checks from `.claude/rules/languages/typescript-patterns.md`:
71
+
72
+ **Type Safety:**
73
+
74
+ - [ ] Strict type-checking is enabled and followed
75
+ - [ ] No use of `any` type (use `unknown` with type guards instead)
76
+ - [ ] Interfaces are used for object shapes
77
+ - [ ] Discriminated unions for state management
78
+ - [ ] Proper use of generics for reusable components
79
+
80
+ **Patterns to Look For:**
81
+
82
+ ```typescript
83
+ // GOOD - Discriminated unions for state
84
+ type RequestState =
85
+ | { status: "idle" }
86
+ | { status: "loading" }
87
+ | { status: "success"; data: User }
88
+ | { status: "error"; error: Error };
89
+
90
+ // BAD - Loose typing with any
91
+ let value: any;
92
+ ```
93
+
94
+ **Null Safety:**
95
+
96
+ - [ ] Optional chaining is used appropriately (`?.`)
97
+ - [ ] Nullish coalescing is used (`??`)
98
+ - [ ] Type guards are implemented for runtime type checking
99
+
100
+ **Immutability:**
101
+
102
+ - [ ] `readonly` is used where mutation should be prevented
103
+ - [ ] Arrays are not mutated directly; spread operators or `.map()` are used
104
+
105
+ **Reference:** See `.claude/rules/languages/typescript-patterns.md` for the complete TypeScript best practices.
106
+
107
+ ---
108
+
109
+ ### Python PRs
110
+
111
+ When reviewing Python code, apply these additional checks from `.claude/rules/languages/python-patterns.md`:
112
+
113
+ **Type Hints:**
114
+
115
+ - [ ] Function signatures have type hints
116
+ - [ ] Return types are specified
117
+ - [ ] Complex types use `typing` module (e.g., `List`, `Dict`, `Optional`)
118
+
119
+ **Patterns to Look For:**
120
+
121
+ ```python
122
+ # GOOD - Type hints with docstrings
123
+ def fetch_user(user_id: str) -> Optional[User]:
124
+ """Fetch a user by their ID.
125
+
126
+ Args:
127
+ user_id: The unique identifier of the user.
128
+
129
+ Returns:
130
+ The user if found, None otherwise.
131
+ """
132
+ pass
133
+
134
+ # BAD - No type hints, unclear function signature
135
+ def fetch_user(user_id):
136
+ pass
137
+ ```
138
+
139
+ **Error Handling:**
140
+
141
+ - [ ] Specific exceptions are caught (not bare `except:`)
142
+ - [ ] Context managers are used for resources (`with` statement)
143
+ - [ ] Errors are logged with appropriate context
144
+
145
+ **Code Style:**
146
+
147
+ - [ ] PEP 8 compliance
148
+ - [ ] Meaningful variable and function names (snake_case)
149
+ - [ ] Docstrings for public functions and classes
150
+ - [ ] No circular imports
151
+
152
+ **Reference:** See `.claude/rules/languages/python-patterns.md` for the complete Python best practices.
153
+
154
+ ---
155
+
156
+ ## Forbidden Patterns to Catch in Reviews
157
+
158
+ Always flag these anti-patterns from `.claude/rules/core/forbidden-patterns.md`:
159
+
160
+ ### 1. Magic Numbers
161
+
162
+ ```typescript
163
+ // FLAG THIS
164
+ setTimeout(cleanup, 86400000)
165
+ if (retryCount > 5) { ... }
166
+
167
+ // SUGGEST THIS
168
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000
169
+ setTimeout(cleanup, ONE_DAY_MS)
170
+ ```
171
+
172
+ ### 2. Silent Error Swallowing
173
+
174
+ ```typescript
175
+ // FLAG THIS
176
+ try {
177
+ await saveData(data);
178
+ } catch (error) {
179
+ // Silent failure
180
+ }
181
+
182
+ // SUGGEST THIS
183
+ try {
184
+ await saveData(data);
185
+ } catch (error) {
186
+ logger.error("Failed to save data", { error, data });
187
+ throw new UserFacingError("Unable to save. Please try again.");
188
+ }
189
+ ```
190
+
191
+ ### 3. Nested Ternaries
192
+
193
+ ```typescript
194
+ // FLAG THIS
195
+ const status = isLoading
196
+ ? "loading"
197
+ : hasError
198
+ ? "error"
199
+ : isComplete
200
+ ? "complete"
201
+ : "idle";
202
+
203
+ // SUGGEST THIS
204
+ function getStatus(isLoading: boolean, hasError: boolean, isComplete: boolean) {
205
+ if (isLoading) return "loading";
206
+ if (hasError) return "error";
207
+ if (isComplete) return "complete";
208
+ return "idle";
209
+ }
210
+ ```
211
+
212
+ ### 4. Parameter Mutation
213
+
214
+ ```typescript
215
+ // FLAG THIS
216
+ function addItem(items: string[], newItem: string) {
217
+ items.push(newItem); // Mutates original!
218
+ return items;
219
+ }
220
+
221
+ // SUGGEST THIS
222
+ function addItem(items: string[], newItem: string) {
223
+ return [...items, newItem];
224
+ }
225
+ ```
226
+
227
+ ### 5. Mixed Async Patterns
228
+
229
+ ```typescript
230
+ // FLAG THIS
231
+ async function processData() {
232
+ const result = await fetchData();
233
+ return result.then((data) => transform(data));
234
+ }
235
+
236
+ // SUGGEST THIS
237
+ async function processData() {
238
+ const data = await fetchData();
239
+ return transform(data);
240
+ }
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Allowed Patterns to Encourage
246
+
247
+ Reference `.claude/rules/core/allowed-patterns.md` and encourage these practices:
248
+
249
+ ### 1. Descriptive Naming
250
+
251
+ ```typescript
252
+ // ENCOURAGE
253
+ function calculateOrderTotal(items: OrderItem[]): number;
254
+ function fetchUserProfile(userId: string): Promise<User>;
255
+ const isAuthenticated = checkAuthStatus();
256
+ ```
257
+
258
+ ### 2. Single Responsibility
259
+
260
+ ```typescript
261
+ // ENCOURAGE - Focused, testable functions
262
+ function formatCurrency(amount: number): string {
263
+ return new Intl.NumberFormat("en-US", {
264
+ style: "currency",
265
+ currency: "USD",
266
+ }).format(amount);
267
+ }
268
+ ```
269
+
270
+ ### 3. Explicit Error Handling
271
+
272
+ ```typescript
273
+ // ENCOURAGE
274
+ async function fetchData(url: string) {
275
+ try {
276
+ const response = await fetch(url);
277
+ if (!response.ok) {
278
+ throw new ApiError(`Request failed: ${response.status}`);
279
+ }
280
+ return response.json();
281
+ } catch (error) {
282
+ logger.error("Failed to fetch data", { url, error });
283
+ throw error;
284
+ }
285
+ }
286
+ ```
287
+
288
+ ### 4. Consistent Code Organization
289
+
290
+ ```
291
+ // ENCOURAGE this structure
292
+ src/
293
+ ├── components/ # UI components
294
+ ├── hooks/ # Custom React hooks
295
+ ├── utils/ # Utility functions
296
+ ├── types/ # TypeScript type definitions
297
+ ├── services/ # API and external service integrations
298
+ └── stores/ # State management
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Review Comment Templates
304
+
305
+ Use these templates for consistent review feedback:
306
+
307
+ ### Suggesting a Pattern Change
308
+
309
+ ```markdown
310
+ **Pattern Suggestion**: This code uses [anti-pattern name].
311
+
312
+ Consider refactoring to:
313
+ \`\`\`typescript
314
+ // Suggested improvement
315
+ \`\`\`
316
+
317
+ Reference: See `.claude/rules/core/forbidden-patterns.md` for details on why this pattern is problematic.
318
+ ```
319
+
320
+ ### Requesting Type Safety Improvements
321
+
322
+ ```markdown
323
+ **Type Safety**: The use of `any` here bypasses TypeScript's type checking.
324
+
325
+ Consider using `unknown` with a type guard, or define a specific interface.
326
+
327
+ Reference: See `.claude/rules/languages/typescript-patterns.md` section on "Avoid the `any` Type".
328
+ ```
329
+
330
+ ### Flagging Missing Error Handling
331
+
332
+ ```markdown
333
+ **Error Handling**: This error is being swallowed silently.
334
+
335
+ Please add appropriate logging and user feedback. See `.claude/rules/core/allowed-patterns.md` for error handling guidelines.
336
+ ```
337
+
338
+ ---
339
+
340
+ ## PR Approval Criteria
341
+
342
+ A PR should only be approved when:
343
+
344
+ 1. **No forbidden patterns** are present (or have been addressed)
345
+ 2. **Allowed patterns** are followed where applicable
346
+ 3. **Language-specific patterns** are adhered to
347
+ 4. **Tests** are present and passing
348
+ 5. **No security concerns** have been identified
349
+ 6. **Code is readable** and maintainable
350
+
351
+ ---
352
+
353
+ ## Quick Reference: Pattern Files
354
+
355
+ | File | Purpose | When to Reference |
356
+ | ------------------------- | ------------------------------ | ------------------------------ |
357
+ | `.claude/rules/core/forbidden-patterns.md` | Anti-patterns to avoid | When flagging problematic code |
358
+ | `.claude/rules/core/allowed-patterns.md` | Best practices to follow | When suggesting improvements |
359
+ | `.claude/rules/languages/typescript-patterns.md` | TypeScript-specific guidelines | When reviewing TS/JS code |
360
+ | `.claude/rules/languages/python-patterns.md` | Python-specific guidelines | When reviewing Python code |
@@ -0,0 +1,30 @@
1
+
2
+ ## Examples
3
+
4
+ For detailed error handling examples, see the Error Handling section above.
5
+
6
+ ### Correct Usage (GOOD)
7
+
8
+ ```bash
9
+ # Always load credentials from .plan.flow.env first
10
+ source .plan.flow.env
11
+
12
+ # Then authenticate using the loaded token
13
+ echo "$GITHUB_TOKEN" | gh auth login --with-token
14
+
15
+ # Verify access before proceeding
16
+ gh auth status
17
+ ```
18
+
19
+ ### Incorrect Usage (BAD - NEVER Do This)
20
+
21
+ ```bash
22
+ # BAD - Using interactive login
23
+ gh auth login # Never use interactive login in automated contexts
24
+
25
+ # BAD - Hardcoding tokens
26
+ GITHUB_TOKEN="ghp_hardcoded_token" # Never hardcode tokens
27
+
28
+ # BAD - Skipping .plan.flow.env
29
+ gh auth login --with-token <<< "ghp_token" # Always use .plan.flow.env
30
+ ```