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,235 @@
1
+ ---
2
+ description: "Core pattern for calculating task complexity scores for implementation planning and code review"
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Complexity Scoring
7
+
8
+ This document defines the scoring system for plan phases. These scores determine execution strategy and help estimate implementation effort.
9
+
10
+ ---
11
+
12
+ ## Complexity Scale
13
+
14
+ | Score | Level | Description | Examples |
15
+ | ----- | --------- | ------------------------------------------ | ---------------------------------------------------------------------- |
16
+ | 0-2 | Trivial | Simple, mechanical changes | Adding a type alias, renaming a variable, adding an import |
17
+ | 3-4 | Low | Straightforward implementation | Creating a simple Zod schema, adding a basic utility function |
18
+ | 5-6 | Medium | Moderate complexity, some decisions | Creating a new component with logic hook, adding a store action |
19
+ | 7-8 | High | Complex implementation, multiple concerns | API route with command pattern, complex state management |
20
+ | 9-10 | Very High | Highly complex, requires careful attention | Streaming implementation, complex algorithms, multi-system integration |
21
+
22
+ ---
23
+
24
+ ## Scoring Criteria
25
+
26
+ Use these modifiers to calculate the complexity score for each phase:
27
+
28
+ ### Positive Modifiers (Add Points)
29
+
30
+ | Modifier | Points |
31
+ | ------------------------------------ | ------ |
32
+ | Each new file to create | +1 |
33
+ | External API integration | +1 |
34
+ | Database operations | +1 |
35
+ | Complex state management | +1 |
36
+ | View/logic separation pattern | +1 |
37
+ | Streaming or real-time features | +2 |
38
+ | Complex business logic or algorithms | +2 |
39
+ | Multi-system integration | +2 |
40
+ | Authentication/authorization logic | +1 |
41
+ | Error handling with recovery | +1 |
42
+
43
+ ### Negative Modifiers (Subtract Points)
44
+
45
+ | Modifier | Points |
46
+ | ------------------------------------ | ------ |
47
+ | Purely mechanical/repetitive tasks | -1 |
48
+ | Small modifications to existing code | -1 |
49
+ | Following existing patterns exactly | -1 |
50
+ | Copy/paste with minor changes | -1 |
51
+
52
+ ---
53
+
54
+ ## Execution Strategy Based on Scores
55
+
56
+ | Total Adjacent Score | Execution Strategy |
57
+ | -------------------- | ------------------------------------------------------------------ |
58
+ | ≤ 6 | **Aggregate**: Execute multiple phases together in one pass |
59
+ | 7-10 | **Cautious**: Execute 1-2 phases, then verify |
60
+ | > 10 | **Sequential**: Execute one phase at a time with full verification |
61
+
62
+ ---
63
+
64
+ ## Aggregation Rules
65
+
66
+ 1. **Can aggregate** phases when their combined complexity ≤ 6
67
+ 2. **Never aggregate** across a phase with complexity ≥ 8
68
+ 3. **Always execute separately**: Tests phase (regardless of score)
69
+ 4. **Prefer aggregation** for trivial consecutive phases (0-2 each)
70
+
71
+ ---
72
+
73
+ ## Examples
74
+
75
+ ### Example 1: Aggregatable Phases (Combined ≤ 6)
76
+
77
+ ```markdown
78
+ ### Phase 1: Types and Schemas
79
+
80
+ **Complexity**: 3/10
81
+
82
+ - [ ] Create WorkflowStep type
83
+ - [ ] Create Zod schema
84
+
85
+ ### Phase 2: Utility Functions
86
+
87
+ **Complexity**: 2/10
88
+
89
+ - [ ] Create transformation helper
90
+
91
+ <!-- Combined complexity: 5 → Execute together -->
92
+ ```
93
+
94
+ ### Example 2: Must Execute Separately (Phase ≥ 8)
95
+
96
+ ```markdown
97
+ ### Phase 3: API Route with Streaming
98
+
99
+ **Complexity**: 9/10
100
+
101
+ - [ ] Create streaming endpoint
102
+ - [ ] Handle SSE events
103
+ - [ ] Implement error recovery
104
+
105
+ ### Phase 4: UI Components
106
+
107
+ **Complexity**: 6/10
108
+
109
+ - [ ] Create component with view/logic separation
110
+ - [ ] Integrate with store
111
+
112
+ <!-- Phase 3 is ≥ 8, execute separately. Phase 4 starts fresh. -->
113
+ ```
114
+
115
+ ### Example 3: Sequential Execution (Total > 10)
116
+
117
+ ```markdown
118
+ ### Phase 1: Database Schema
119
+
120
+ **Complexity**: 5/10
121
+
122
+ ### Phase 2: Backend API
123
+
124
+ **Complexity**: 7/10
125
+
126
+ ### Phase 3: Frontend Components
127
+
128
+ **Complexity**: 6/10
129
+
130
+ <!-- Adjacent totals exceed 10, execute one at a time -->
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Phase Format with Complexity
136
+
137
+ Every phase in a plan must include a complexity score:
138
+
139
+ ```markdown
140
+ ### Phase 1: [Phase Name]
141
+
142
+ **Scope**: [What this phase covers]
143
+ **Complexity**: X/10
144
+
145
+ - [ ] Task 1
146
+ - [ ] Task 2
147
+
148
+ **Build Verification**: Run `npm run build`
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Scoring Guidelines
154
+
155
+ ### When in Doubt, Score Higher
156
+
157
+ If uncertain about complexity, err on the side of a higher score. It's better to execute cautiously than to rush through a complex phase.
158
+
159
+ ### Re-evaluate During Execution
160
+
161
+ If a phase turns out to be more complex than estimated:
162
+
163
+ 1. Stop execution
164
+ 2. Update the complexity score in the plan
165
+ 3. Adjust execution strategy accordingly
166
+
167
+ ### Common Complexity Patterns
168
+
169
+ | Task Type | Typical Score |
170
+ | ------------------------------- | ------------- |
171
+ | Type definitions only | 2-3 |
172
+ | Simple utility function | 2-3 |
173
+ | Zod schema creation | 3-4 |
174
+ | Basic React component | 4-5 |
175
+ | Component with view/logic split | 5-6 |
176
+ | Zustand store actions | 4-5 |
177
+ | REST API route | 5-6 |
178
+ | API route with command pattern | 6-7 |
179
+ | Database operations | 5-7 |
180
+ | Streaming/SSE implementation | 8-9 |
181
+ | Complex algorithm | 7-9 |
182
+ | Multi-service integration | 8-10 |
183
+ | Unit tests | 3-5 |
184
+ | Integration tests | 5-6 |
185
+
186
+ ---
187
+
188
+ ## Real-World Scoring Examples
189
+
190
+ ### Example A: Add a New Form Field
191
+
192
+ **Scenario**: Add an email field to the user registration form.
193
+
194
+ | Modifier | Points | Reason |
195
+ |----------|--------|--------|
196
+ | Modify existing component | -1 | Small modification |
197
+ | Following existing patterns | -1 | Other fields already exist |
198
+ | Add Zod validation | +1 | Schema update |
199
+ | **Total** | **2/10** | Trivial |
200
+
201
+ **Execution**: Can be aggregated with other trivial phases.
202
+
203
+ ---
204
+
205
+ ### Example B: Create User Dashboard API
206
+
207
+ **Scenario**: Create an API endpoint that fetches user data with analytics.
208
+
209
+ | Modifier | Points | Reason |
210
+ |----------|--------|--------|
211
+ | New file (route.ts) | +1 | Creating API route |
212
+ | Database operations | +1 | Fetch user data |
213
+ | External API integration | +1 | Analytics service |
214
+ | Error handling with recovery | +1 | Handle service failures |
215
+ | Complex business logic | +2 | Aggregate multiple data sources |
216
+ | **Total** | **6/10** | Medium |
217
+
218
+ **Execution**: Can be aggregated if adjacent phase is ≤ 0.
219
+
220
+ ---
221
+
222
+ ### Example C: Implement Real-time Chat Feature
223
+
224
+ **Scenario**: Add WebSocket-based chat with message persistence.
225
+
226
+ | Modifier | Points | Reason |
227
+ |----------|--------|--------|
228
+ | New files (3 files) | +3 | Route, hook, component |
229
+ | Streaming/real-time | +2 | WebSocket handling |
230
+ | Database operations | +1 | Message persistence |
231
+ | Complex state management | +1 | Chat state with optimistic updates |
232
+ | Multi-system integration | +2 | WebSocket + DB + Auth |
233
+ | **Total** | **9/10** | Very High |
234
+
235
+ **Execution**: Must execute separately. Never aggregate with other phases.
@@ -0,0 +1,263 @@
1
+ ---
2
+ description: "Anti-patterns and practices to avoid in all code"
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Forbidden Patterns
7
+
8
+ This file defines **anti-patterns and practices to avoid** in your project. Add patterns that your team has identified as problematic and wants the AI to avoid during code generation.
9
+
10
+ ---
11
+
12
+ ## How to Use This File
13
+
14
+ 1. **Add anti-patterns** that cause problems in your codebase
15
+ 2. **Show examples** of the problematic code
16
+ 3. **Explain why** each pattern is harmful
17
+ 4. **Reference the fix** in `.cursor/rules/core/allowed-patterns.mdc` when applicable
18
+
19
+ ---
20
+
21
+ ## Example Pattern Structure
22
+
23
+ ### DON'T: Pattern Name
24
+
25
+ **Problem**: Brief description of why this is problematic.
26
+
27
+ ```typescript
28
+ // BAD - Example of the anti-pattern
29
+ const badExample = doThingWrong()
30
+ ```
31
+
32
+ **Why This is Wrong**:
33
+
34
+ - Reason 1
35
+ - Reason 2
36
+
37
+ **Fix**: Description of the correct approach or link to `.cursor/rules/core/allowed-patterns.mdc`.
38
+
39
+ ---
40
+
41
+ ## Example Anti-Patterns
42
+
43
+ ### 1. DON'T Use Magic Numbers
44
+
45
+ **Problem**: Hardcoded numbers without context make code hard to understand and maintain.
46
+
47
+ ```typescript
48
+ // BAD - What does 86400000 mean?
49
+ setTimeout(cleanup, 86400000)
50
+
51
+ // BAD - Why 5? What if it needs to change?
52
+ if (retryCount > 5) {
53
+ throw new Error('Too many retries')
54
+ }
55
+ ```
56
+
57
+ **Why This is Wrong**:
58
+
59
+ - No context for what the number represents
60
+ - Hard to find and update when requirements change
61
+ - Easy to introduce bugs with typos
62
+
63
+ **Fix**: Use named constants with descriptive names.
64
+
65
+ ```typescript
66
+ // GOOD
67
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000
68
+ setTimeout(cleanup, ONE_DAY_MS)
69
+
70
+ const MAX_RETRY_ATTEMPTS = 5
71
+ if (retryCount > MAX_RETRY_ATTEMPTS) {
72
+ throw new Error('Too many retries')
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ ### 2. DON'T Swallow Errors Silently
79
+
80
+ **Problem**: Catching errors without handling them hides bugs and makes debugging impossible.
81
+
82
+ ```typescript
83
+ // BAD - Error is completely ignored
84
+ try {
85
+ await saveData(data)
86
+ } catch (error) {
87
+ // Silent failure - no one knows something went wrong
88
+ }
89
+
90
+ // BAD - Generic catch that hides the real issue
91
+ try {
92
+ await complexOperation()
93
+ } catch {
94
+ return null
95
+ }
96
+ ```
97
+
98
+ **Why This is Wrong**:
99
+
100
+ - Bugs go unnoticed until they cause bigger problems
101
+ - Impossible to debug issues in production
102
+ - Users don't know their action failed
103
+
104
+ **Fix**: Always log errors and provide appropriate user feedback.
105
+
106
+ ```typescript
107
+ // GOOD
108
+ try {
109
+ await saveData(data)
110
+ } catch (error) {
111
+ logger.error('Failed to save data', { error, data })
112
+ throw new UserFacingError('Unable to save. Please try again.')
113
+ }
114
+ ```
115
+
116
+ ---
117
+
118
+ ### 3. DON'T Use Nested Ternaries
119
+
120
+ **Problem**: Deeply nested ternary operators are hard to read and maintain.
121
+
122
+ ```typescript
123
+ // BAD - Unreadable nested ternaries
124
+ const status = isLoading ? 'loading' : hasError ? 'error' : isComplete ? 'complete' : 'idle'
125
+
126
+ // BAD - Even worse with more nesting
127
+ const message = !user ? 'Not logged in' : !user.verified ? 'Please verify' : user.isPremium ? 'Welcome back, premium user!' : 'Welcome back!'
128
+ ```
129
+
130
+ **Why This is Wrong**:
131
+
132
+ - Extremely hard to read and understand
133
+ - Easy to introduce bugs when modifying
134
+ - Difficult to add new conditions
135
+
136
+ **Fix**: Use if/else statements, switch statements, or lookup objects.
137
+
138
+ ```typescript
139
+ // GOOD - Clear and maintainable
140
+ function getStatus(isLoading: boolean, hasError: boolean, isComplete: boolean) {
141
+ if (isLoading) return 'loading'
142
+ if (hasError) return 'error'
143
+ if (isComplete) return 'complete'
144
+ return 'idle'
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ### 4. DON'T Mutate Function Parameters
151
+
152
+ **Problem**: Mutating parameters causes unexpected side effects and makes code unpredictable.
153
+
154
+ ```typescript
155
+ // BAD - Mutating the input array
156
+ function addItem(items: string[], newItem: string) {
157
+ items.push(newItem) // Modifies the original array!
158
+ return items
159
+ }
160
+
161
+ // BAD - Mutating object properties
162
+ function updateUser(user: User) {
163
+ user.lastUpdated = new Date() // Modifies the original object!
164
+ return user
165
+ }
166
+ ```
167
+
168
+ **Why This is Wrong**:
169
+
170
+ - Caller doesn't expect their data to change
171
+ - Causes bugs that are hard to track down
172
+ - Breaks immutability expectations in React/Redux
173
+
174
+ **Fix**: Return new objects/arrays instead of mutating.
175
+
176
+ ```typescript
177
+ // GOOD - Returns new array
178
+ function addItem(items: string[], newItem: string) {
179
+ return [...items, newItem]
180
+ }
181
+
182
+ // GOOD - Returns new object
183
+ function updateUser(user: User) {
184
+ return { ...user, lastUpdated: new Date() }
185
+ }
186
+ ```
187
+
188
+ ---
189
+
190
+ ### 5. DON'T Mix Async Patterns
191
+
192
+ **Problem**: Mixing callbacks, promises, and async/await makes code confusing and error-prone.
193
+
194
+ ```typescript
195
+ // BAD - Mixing callbacks and promises
196
+ function fetchData(callback) {
197
+ fetch('/api/data')
198
+ .then(res => res.json())
199
+ .then(data => callback(null, data))
200
+ .catch(err => callback(err))
201
+ }
202
+
203
+ // BAD - Mixing .then() with async/await
204
+ async function processData() {
205
+ const result = await fetchData()
206
+ return result.then(data => transform(data)) // Mixing patterns!
207
+ }
208
+ ```
209
+
210
+ **Why This is Wrong**:
211
+
212
+ - Confusing control flow
213
+ - Error handling becomes inconsistent
214
+ - Harder to debug and maintain
215
+
216
+ **Fix**: Use async/await consistently throughout.
217
+
218
+ ```typescript
219
+ // GOOD - Consistent async/await
220
+ async function fetchData() {
221
+ const response = await fetch('/api/data')
222
+ return response.json()
223
+ }
224
+
225
+ async function processData() {
226
+ const data = await fetchData()
227
+ return transform(data)
228
+ }
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Adding Your Anti-Patterns
234
+
235
+ When adding new anti-patterns to this file:
236
+
237
+ 1. **Start with "DON'T"** followed by the pattern name
238
+ 2. **Describe the problem** briefly
239
+ 3. **Provide BAD examples** showing the anti-pattern
240
+ 4. **Explain why it's wrong** with a bullet list
241
+ 5. **Show the fix** or reference `.cursor/rules/core/allowed-patterns.mdc`
242
+
243
+ ---
244
+
245
+ ## Template for New Anti-Patterns
246
+
247
+ ```markdown
248
+ ### DON'T: Pattern Name
249
+
250
+ **Problem**: Brief description of why this is problematic.
251
+
252
+ \`\`\`typescript
253
+ // BAD - Example of the anti-pattern
254
+ const badExample = problematicCode()
255
+ \`\`\`
256
+
257
+ **Why This is Wrong**:
258
+
259
+ - Reason 1
260
+ - Reason 2
261
+
262
+ **Fix**: Description or link to `.cursor/rules/core/allowed-patterns.mdc`.
263
+ ```
@@ -0,0 +1,80 @@
1
+ ---
2
+ description: "Summary index for language patterns - load this to see available references"
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Languages Index
7
+
8
+ ## Overview
9
+
10
+ Language-specific patterns and best practices. These rules apply when working with TypeScript/JavaScript or Python files respectively.
11
+
12
+ **Total Files**: 2 files, ~316 lines
13
+ **Reference Codes**: LNG-TS-1 through LNG-PY-5
14
+
15
+ ---
16
+
17
+ ## Reference Codes
18
+
19
+ ### TypeScript Patterns (`typescript-patterns.mdc`)
20
+
21
+ | Code | Description | Source | Lines |
22
+ |------|-------------|--------|-------|
23
+ | LNG-TS-1 | Type definitions (interfaces, unions, generics) | typescript-patterns.mdc | 9-50 |
24
+ | LNG-TS-2 | Error handling and custom error types | typescript-patterns.mdc | 51-65 |
25
+ | LNG-TS-3 | Type safety (utility types, avoid any, null safety) | typescript-patterns.mdc | 66-86 |
26
+ | LNG-TS-4 | Advanced patterns (const assertions, type guards, immutability, satisfies) | typescript-patterns.mdc | 87-129 |
27
+
28
+ ### Python Patterns (`python-patterns.mdc`)
29
+
30
+ | Code | Description | Source | Lines |
31
+ |------|-------------|--------|-------|
32
+ | LNG-PY-1 | Style and typing (PEP 8, type hints, dataclasses) | python-patterns.mdc | 9-52 |
33
+ | LNG-PY-2 | Code organization (modular functions, enums, context managers) | python-patterns.mdc | 53-97 |
34
+ | LNG-PY-3 | Error handling and custom exceptions | python-patterns.mdc | 98-110 |
35
+ | LNG-PY-4 | Async and I/O patterns | python-patterns.mdc | 111-125 |
36
+ | LNG-PY-5 | Best practices (DI, logging, Pydantic, Pathlib) | python-patterns.mdc | 126-189 |
37
+
38
+ ---
39
+
40
+ ## When to Expand
41
+
42
+ | Code | Expand When |
43
+ |------|-------------|
44
+ | LNG-TS-1 | Defining TypeScript interfaces or unions |
45
+ | LNG-TS-2 | Implementing custom error classes in TS |
46
+ | LNG-TS-3 | Need examples of utility types or null safety |
47
+ | LNG-TS-4 | Using advanced TS features like satisfies or type guards |
48
+ | LNG-PY-1 | Setting up Python project structure or typing |
49
+ | LNG-PY-2 | Organizing Python modules and using enums |
50
+ | LNG-PY-3 | Creating custom Python exceptions |
51
+ | LNG-PY-4 | Implementing async/await in Python |
52
+ | LNG-PY-5 | Using Pydantic, logging, or dependency injection |
53
+
54
+ ---
55
+
56
+ ## Quick Reference
57
+
58
+ ### TypeScript Key Points
59
+ - **Strict mode**: Always enable `strict: true`
60
+ - **Interfaces**: Prefer for object shapes
61
+ - **Discriminated unions**: Model exclusive states
62
+ - **Generics**: Reusable, type-safe components
63
+ - **Avoid any**: Use `unknown` with type guards
64
+ - **Immutability**: Use `readonly` and `ReadonlyArray`
65
+
66
+ ### Python Key Points
67
+ - **PEP 8**: Follow naming conventions
68
+ - **Type hints**: Add annotations for clarity
69
+ - **Dataclasses**: Use for structured data
70
+ - **Enums**: Replace magic strings/numbers
71
+ - **Context managers**: Resource management
72
+ - **Logging**: Use logger, not print
73
+
74
+ ---
75
+
76
+ ## Notes
77
+
78
+ - Both files have `alwaysApply: false` - loaded based on file glob patterns
79
+ - TypeScript patterns apply to `**/*.ts` and `**/*.tsx` files
80
+ - Python patterns apply to `**/*.py` files