@el-j/magic-helix-core 4.0.0-beta.1 → 4.0.0-beta.3
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.
- package/dist/index-B88j4AyE.js +13 -0
- package/dist/index-B88j4AyE.js.map +1 -0
- package/dist/index-CY-pQbuu.cjs +2 -0
- package/dist/index-CY-pQbuu.cjs.map +1 -0
- package/dist/index.cjs +75 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2234 -51
- package/dist/index.mjs.map +1 -1
- package/dist/pattern-combiner.d.ts +1 -1
- package/dist/plugin-loader.d.ts +7 -1
- package/package.json +4 -4
- package/dist/BasePlugin-6wv0hYJ9.js +0 -98
- package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
- package/dist/BasePlugin-odQJAKA-.cjs +0 -2
- package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
- package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
- package/dist/builtin-plugins/csharp/index.d.ts +0 -20
- package/dist/builtin-plugins/go/index.d.ts +0 -23
- package/dist/builtin-plugins/index.d.ts +0 -15
- package/dist/builtin-plugins/java/index.d.ts +0 -22
- package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
- package/dist/builtin-plugins/php/index.d.ts +0 -20
- package/dist/builtin-plugins/python/index.d.ts +0 -27
- package/dist/builtin-plugins/ruby/index.d.ts +0 -20
- package/dist/builtin-plugins/rust/index.d.ts +0 -53
- package/dist/builtin-plugins/swift/index.d.ts +0 -22
- package/dist/default_templates/angular/angular-core.md +0 -19
- package/dist/default_templates/architecture/codeowners.md +0 -123
- package/dist/default_templates/architecture/monorepo.md +0 -146
- package/dist/default_templates/architecture/nx.md +0 -122
- package/dist/default_templates/architecture/turborepo.md +0 -114
- package/dist/default_templates/ci/github-actions.md +0 -268
- package/dist/default_templates/ci/gitlab-ci.md +0 -330
- package/dist/default_templates/containers/docker-multistage.md +0 -120
- package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
- package/dist/default_templates/devops/docker-compose.md +0 -111
- package/dist/default_templates/devops/docker-dockerfile.md +0 -94
- package/dist/default_templates/devops/github-actions.md +0 -160
- package/dist/default_templates/devops/gitlab-ci.md +0 -210
- package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
- package/dist/default_templates/dotnet/framework-blazor.md +0 -271
- package/dist/default_templates/dotnet/lang-csharp.md +0 -162
- package/dist/default_templates/generic/lang-typescript.md +0 -11
- package/dist/default_templates/generic/state-redux.md +0 -21
- package/dist/default_templates/generic/state-rxjs.md +0 -6
- package/dist/default_templates/generic/style-mui.md +0 -23
- package/dist/default_templates/generic/style-tailwind.md +0 -6
- package/dist/default_templates/generic/test-cypress.md +0 -21
- package/dist/default_templates/generic/test-jest.md +0 -20
- package/dist/default_templates/generic/test-playwright.md +0 -21
- package/dist/default_templates/generic/test-vitest.md +0 -6
- package/dist/default_templates/go/lang-go.md +0 -571
- package/dist/default_templates/java/build-gradle.md +0 -102
- package/dist/default_templates/java/build-maven.md +0 -86
- package/dist/default_templates/java/framework-spring-boot.md +0 -179
- package/dist/default_templates/java/lang-java.md +0 -78
- package/dist/default_templates/java/lang-kotlin.md +0 -88
- package/dist/default_templates/meta/magic-helix-meta.md +0 -213
- package/dist/default_templates/meta/meta-debug.md +0 -459
- package/dist/default_templates/meta/meta-implement.md +0 -450
- package/dist/default_templates/meta/meta-roadmap.md +0 -265
- package/dist/default_templates/nestjs/nestjs-core.md +0 -7
- package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
- package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
- package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
- package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
- package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
- package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
- package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
- package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
- package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
- package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
- package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
- package/dist/default_templates/patterns/environment/ide-features.md +0 -17
- package/dist/default_templates/patterns/environment/os-commands.md +0 -17
- package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
- package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
- package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
- package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
- package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
- package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
- package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
- package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
- package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
- package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
- package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
- package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
- package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
- package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
- package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
- package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
- package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
- package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
- package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
- package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
- package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
- package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
- package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
- package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
- package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
- package/dist/default_templates/php/framework-laravel.md +0 -112
- package/dist/default_templates/php/lang-php.md +0 -94
- package/dist/default_templates/python/lang-python.md +0 -508
- package/dist/default_templates/react/react-core.md +0 -677
- package/dist/default_templates/react/react-zustand.md +0 -7
- package/dist/default_templates/ruby/framework-rails.md +0 -309
- package/dist/default_templates/ruby/framework-sinatra.md +0 -227
- package/dist/default_templates/ruby/lang-ruby.md +0 -216
- package/dist/default_templates/rust/lang-rust.md +0 -89
- package/dist/default_templates/swift/framework-vapor.md +0 -352
- package/dist/default_templates/swift/lang-swift.md +0 -291
- package/dist/default_templates/vue/style-primevue.md +0 -6
- package/dist/default_templates/vue/style-quasar.md +0 -22
- package/dist/default_templates/vue/vue-core.md +0 -28
- package/dist/default_templates/vue/vue-pinia.md +0 -5
- package/dist/index-AkVwRl-r.js +0 -92
- package/dist/index-AkVwRl-r.js.map +0 -1
- package/dist/index-B6BeG1yT.cjs +0 -68
- package/dist/index-B6BeG1yT.cjs.map +0 -1
- package/dist/index-B8pyjKdF.js +0 -94
- package/dist/index-B8pyjKdF.js.map +0 -1
- package/dist/index-B_6W_RnJ.cjs +0 -76
- package/dist/index-B_6W_RnJ.cjs.map +0 -1
- package/dist/index-Bg8DD8ku.js +0 -216
- package/dist/index-Bg8DD8ku.js.map +0 -1
- package/dist/index-BkJhe5Af.js +0 -1748
- package/dist/index-BkJhe5Af.js.map +0 -1
- package/dist/index-Bv4Q1Pr7.cjs +0 -33
- package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
- package/dist/index-CN8J45Nc.cjs +0 -24
- package/dist/index-CN8J45Nc.cjs.map +0 -1
- package/dist/index-CPbv2Od1.js +0 -62
- package/dist/index-CPbv2Od1.js.map +0 -1
- package/dist/index-Cf-MC6Al.js +0 -63
- package/dist/index-Cf-MC6Al.js.map +0 -1
- package/dist/index-DDPXXXDy.cjs +0 -19
- package/dist/index-DDPXXXDy.cjs.map +0 -1
- package/dist/index-DO30AzDe.cjs +0 -19
- package/dist/index-DO30AzDe.cjs.map +0 -1
- package/dist/index-Dm37u5ut.js +0 -2128
- package/dist/index-Dm37u5ut.js.map +0 -1
- package/dist/index-DqHvgoXJ.cjs +0 -19
- package/dist/index-DqHvgoXJ.cjs.map +0 -1
- package/dist/index-J1qAfsnO.cjs +0 -2
- package/dist/index-J1qAfsnO.cjs.map +0 -1
- package/dist/index-Jz0HYZ7B.js +0 -13
- package/dist/index-Jz0HYZ7B.js.map +0 -1
- package/dist/index-K39pdw94.cjs +0 -31
- package/dist/index-K39pdw94.cjs.map +0 -1
- package/dist/index-L3IVvhd1.cjs +0 -89
- package/dist/index-L3IVvhd1.cjs.map +0 -1
- package/dist/index-OT2XAJkc.js +0 -117
- package/dist/index-OT2XAJkc.js.map +0 -1
- package/dist/index-TPAX4XKg.cjs +0 -30
- package/dist/index-TPAX4XKg.cjs.map +0 -1
- package/dist/index-WmVSB57y.js +0 -107
- package/dist/index-WmVSB57y.js.map +0 -1
- package/dist/index-mYXvc3Fs.js +0 -68
- package/dist/index-mYXvc3Fs.js.map +0 -1
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
# 🔨 Implementation & Code Generation Mode
|
|
2
|
-
|
|
3
|
-
*This context-specific meta-instruction activates when you're implementing features, writing code, or making technical changes.*
|
|
4
|
-
|
|
5
|
-
## Implementation Mindset
|
|
6
|
-
|
|
7
|
-
You are in **code implementation mode**. Focus on:
|
|
8
|
-
- Writing clean, maintainable code
|
|
9
|
-
- Following existing patterns
|
|
10
|
-
- Ensuring test coverage
|
|
11
|
-
- Incremental, verifiable changes
|
|
12
|
-
|
|
13
|
-
## Implementation Workflow
|
|
14
|
-
|
|
15
|
-
### 1. Understand the Requirement
|
|
16
|
-
|
|
17
|
-
**Before writing any code:**
|
|
18
|
-
- Read the full requirement carefully
|
|
19
|
-
- Identify acceptance criteria
|
|
20
|
-
- Understand edge cases
|
|
21
|
-
- Know what success looks like
|
|
22
|
-
|
|
23
|
-
**Clarify ambiguities:**
|
|
24
|
-
- Ask about expected behavior in edge cases
|
|
25
|
-
- Confirm error handling approach
|
|
26
|
-
- Verify backwards compatibility requirements
|
|
27
|
-
- Check performance constraints
|
|
28
|
-
|
|
29
|
-
### 2. Research Existing Patterns
|
|
30
|
-
|
|
31
|
-
**Search for similar implementations:**
|
|
32
|
-
```
|
|
33
|
-
1. Semantic search: Find similar features
|
|
34
|
-
2. Read relevant files completely
|
|
35
|
-
3. Identify naming conventions
|
|
36
|
-
4. Note testing patterns
|
|
37
|
-
5. Check error handling approaches
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**Key questions:**
|
|
41
|
-
- How are similar features structured?
|
|
42
|
-
- What libraries/utilities already exist?
|
|
43
|
-
- What's the established pattern for this type of code?
|
|
44
|
-
- Are there helpers or abstractions I should use?
|
|
45
|
-
|
|
46
|
-
### 3. Plan Your Changes
|
|
47
|
-
|
|
48
|
-
**Create a logical implementation order:**
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
1. Types/Interfaces first
|
|
52
|
-
- Define data structures
|
|
53
|
-
- Create type definitions
|
|
54
|
-
- Update existing types
|
|
55
|
-
|
|
56
|
-
2. Core logic second
|
|
57
|
-
- Implement business logic
|
|
58
|
-
- Add validation
|
|
59
|
-
- Handle errors
|
|
60
|
-
|
|
61
|
-
3. Integration third
|
|
62
|
-
- Wire up dependencies
|
|
63
|
-
- Connect to existing code
|
|
64
|
-
- Add configuration
|
|
65
|
-
|
|
66
|
-
4. Tests fourth
|
|
67
|
-
- Unit tests for core logic
|
|
68
|
-
- Integration tests for workflows
|
|
69
|
-
- Edge case coverage
|
|
70
|
-
|
|
71
|
-
5. Documentation last
|
|
72
|
-
- Update README
|
|
73
|
-
- Add code comments
|
|
74
|
-
- Document public APIs
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 4. Make Incremental Changes
|
|
78
|
-
|
|
79
|
-
**Small, verifiable steps:**
|
|
80
|
-
- One logical change at a time
|
|
81
|
-
- Verify compilation after each step
|
|
82
|
-
- Run tests frequently
|
|
83
|
-
- Commit working code early
|
|
84
|
-
|
|
85
|
-
**Example incremental workflow:**
|
|
86
|
-
```
|
|
87
|
-
Step 1: Add interface definition → Verify compiles
|
|
88
|
-
Step 2: Create basic implementation → Verify compiles
|
|
89
|
-
Step 3: Add error handling → Run tests
|
|
90
|
-
Step 4: Add validation → Run tests
|
|
91
|
-
Step 5: Integrate with existing code → Run all tests
|
|
92
|
-
Step 6: Add documentation → Final verification
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### 5. Follow Code Quality Standards
|
|
96
|
-
|
|
97
|
-
**Every implementation should:**
|
|
98
|
-
|
|
99
|
-
✓ **Be properly typed** (if using TypeScript/typed language)
|
|
100
|
-
```typescript
|
|
101
|
-
// Good
|
|
102
|
-
function processUser(user: User): ProcessedUser {
|
|
103
|
-
return { ...user, processed: true };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Bad
|
|
107
|
-
function processUser(user: any) {
|
|
108
|
-
return { ...user, processed: true };
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
✓ **Have meaningful names**
|
|
113
|
-
```typescript
|
|
114
|
-
// Good
|
|
115
|
-
const activeUserCount = users.filter(u => u.isActive).length;
|
|
116
|
-
|
|
117
|
-
// Bad
|
|
118
|
-
const x = users.filter(u => u.isActive).length;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
✓ **Include error handling**
|
|
122
|
-
```typescript
|
|
123
|
-
// Good
|
|
124
|
-
try {
|
|
125
|
-
const data = await fetchData();
|
|
126
|
-
return processData(data);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
logger.error('Failed to fetch data', error);
|
|
129
|
-
throw new DataFetchError('Unable to load user data', { cause: error });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Bad
|
|
133
|
-
const data = await fetchData();
|
|
134
|
-
return processData(data);
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
✓ **Have appropriate comments**
|
|
138
|
-
```typescript
|
|
139
|
-
// Good: Explain WHY, not WHAT
|
|
140
|
-
// Using binary search because dataset can be > 10K items
|
|
141
|
-
const index = binarySearch(sortedArray, target);
|
|
142
|
-
|
|
143
|
-
// Bad: Obvious comment
|
|
144
|
-
// Increment counter
|
|
145
|
-
counter++;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
✓ **Follow existing style**
|
|
149
|
-
- Match indentation (tabs vs spaces)
|
|
150
|
-
- Match brace style
|
|
151
|
-
- Match naming conventions
|
|
152
|
-
- Use same patterns as similar code
|
|
153
|
-
|
|
154
|
-
### 6. Write Tests Alongside Code
|
|
155
|
-
|
|
156
|
-
**Test-driven approach:**
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
// 1. Write test first (TDD style)
|
|
160
|
-
test('should validate email format', () => {
|
|
161
|
-
expect(validateEmail('user@example.com')).toBe(true);
|
|
162
|
-
expect(validateEmail('invalid')).toBe(false);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// 2. Implement to make test pass
|
|
166
|
-
function validateEmail(email: string): boolean {
|
|
167
|
-
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// 3. Add edge cases
|
|
171
|
-
test('should handle edge cases', () => {
|
|
172
|
-
expect(validateEmail('')).toBe(false);
|
|
173
|
-
expect(validateEmail(' ')).toBe(false);
|
|
174
|
-
expect(validateEmail('user@')).toBe(false);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// 4. Update implementation
|
|
178
|
-
function validateEmail(email: string): boolean {
|
|
179
|
-
if (!email || !email.trim()) return false;
|
|
180
|
-
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Code Quality Checklist
|
|
185
|
-
|
|
186
|
-
Before marking implementation complete, verify:
|
|
187
|
-
|
|
188
|
-
### Functionality
|
|
189
|
-
- [ ] Feature works as specified
|
|
190
|
-
- [ ] Edge cases handled
|
|
191
|
-
- [ ] Error cases handled gracefully
|
|
192
|
-
- [ ] No obvious bugs
|
|
193
|
-
|
|
194
|
-
### Code Quality
|
|
195
|
-
- [ ] Follows existing patterns
|
|
196
|
-
- [ ] Properly typed (if applicable)
|
|
197
|
-
- [ ] Meaningful variable/function names
|
|
198
|
-
- [ ] No code duplication
|
|
199
|
-
- [ ] Appropriate abstraction level
|
|
200
|
-
|
|
201
|
-
### Testing
|
|
202
|
-
- [ ] Unit tests written
|
|
203
|
-
- [ ] Integration tests added (if needed)
|
|
204
|
-
- [ ] Tests cover edge cases
|
|
205
|
-
- [ ] All tests passing
|
|
206
|
-
- [ ] No test warnings
|
|
207
|
-
|
|
208
|
-
### Integration
|
|
209
|
-
- [ ] Integrates with existing code
|
|
210
|
-
- [ ] Backwards compatible (unless intentional break)
|
|
211
|
-
- [ ] Configuration added (if needed)
|
|
212
|
-
- [ ] Dependencies installed
|
|
213
|
-
|
|
214
|
-
### Documentation
|
|
215
|
-
- [ ] Public APIs documented
|
|
216
|
-
- [ ] Complex logic explained
|
|
217
|
-
- [ ] README updated (if needed)
|
|
218
|
-
- [ ] Migration guide (if breaking change)
|
|
219
|
-
|
|
220
|
-
### Performance
|
|
221
|
-
- [ ] No obvious performance issues
|
|
222
|
-
- [ ] Appropriate data structures used
|
|
223
|
-
- [ ] No unnecessary loops or computations
|
|
224
|
-
- [ ] Handles large datasets if applicable
|
|
225
|
-
|
|
226
|
-
## Common Implementation Patterns
|
|
227
|
-
|
|
228
|
-
### Error Handling Pattern
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
class CustomError extends Error {
|
|
232
|
-
constructor(message: string, public code: string, public details?: unknown) {
|
|
233
|
-
super(message);
|
|
234
|
-
this.name = 'CustomError';
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async function robustOperation() {
|
|
239
|
-
try {
|
|
240
|
-
const result = await riskyOperation();
|
|
241
|
-
return { success: true, data: result };
|
|
242
|
-
} catch (error) {
|
|
243
|
-
logger.error('Operation failed', { error });
|
|
244
|
-
|
|
245
|
-
if (error instanceof ValidationError) {
|
|
246
|
-
return { success: false, error: 'Invalid input' };
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
throw new CustomError(
|
|
250
|
-
'Operation failed',
|
|
251
|
-
'OPERATION_ERROR',
|
|
252
|
-
{ originalError: error }
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### Validation Pattern
|
|
259
|
-
|
|
260
|
-
```typescript
|
|
261
|
-
interface ValidationResult {
|
|
262
|
-
valid: boolean;
|
|
263
|
-
errors: string[];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function validateUser(user: unknown): ValidationResult {
|
|
267
|
-
const errors: string[] = [];
|
|
268
|
-
|
|
269
|
-
if (!user || typeof user !== 'object') {
|
|
270
|
-
return { valid: false, errors: ['User must be an object'] };
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const u = user as Record<string, unknown>;
|
|
274
|
-
|
|
275
|
-
if (!u.email || typeof u.email !== 'string') {
|
|
276
|
-
errors.push('Email is required');
|
|
277
|
-
} else if (!isValidEmail(u.email)) {
|
|
278
|
-
errors.push('Email format is invalid');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (!u.name || typeof u.name !== 'string') {
|
|
282
|
-
errors.push('Name is required');
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return {
|
|
286
|
-
valid: errors.length === 0,
|
|
287
|
-
errors
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Builder Pattern
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
class QueryBuilder {
|
|
296
|
-
private conditions: string[] = [];
|
|
297
|
-
private params: unknown[] = [];
|
|
298
|
-
|
|
299
|
-
where(condition: string, ...values: unknown[]): this {
|
|
300
|
-
this.conditions.push(condition);
|
|
301
|
-
this.params.push(...values);
|
|
302
|
-
return this;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
build(): { query: string; params: unknown[] } {
|
|
306
|
-
const query = `SELECT * FROM users WHERE ${this.conditions.join(' AND ')}`;
|
|
307
|
-
return { query, params: this.params };
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Usage
|
|
312
|
-
const query = new QueryBuilder()
|
|
313
|
-
.where('age > ?', 18)
|
|
314
|
-
.where('active = ?', true)
|
|
315
|
-
.build();
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
## Anti-Patterns to Avoid
|
|
319
|
-
|
|
320
|
-
❌ **Don't do this:**
|
|
321
|
-
|
|
322
|
-
```typescript
|
|
323
|
-
// Massive function doing everything
|
|
324
|
-
function handleUserRequest(req: any) {
|
|
325
|
-
// 200 lines of code...
|
|
326
|
-
// Parsing, validation, business logic, database, response
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Magic numbers
|
|
330
|
-
if (status === 3) { ... }
|
|
331
|
-
|
|
332
|
-
// Unclear variable names
|
|
333
|
-
const x = data.map(d => d.v * 2);
|
|
334
|
-
|
|
335
|
-
// Nested callbacks
|
|
336
|
-
getData((data) => {
|
|
337
|
-
processData(data, (result) => {
|
|
338
|
-
saveResult(result, (saved) => {
|
|
339
|
-
// Callback hell
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
// Swallowing errors
|
|
345
|
-
try {
|
|
346
|
-
riskyOperation();
|
|
347
|
-
} catch (e) {
|
|
348
|
-
// Silently ignore
|
|
349
|
-
}
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
✓ **Do this instead:**
|
|
353
|
-
|
|
354
|
-
```typescript
|
|
355
|
-
// Single Responsibility Principle
|
|
356
|
-
async function handleUserRequest(req: Request) {
|
|
357
|
-
const userData = parseRequest(req);
|
|
358
|
-
const validatedData = validateUser(userData);
|
|
359
|
-
const user = await createUser(validatedData);
|
|
360
|
-
return formatResponse(user);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Named constants
|
|
364
|
-
const STATUS_ACTIVE = 3;
|
|
365
|
-
if (status === STATUS_ACTIVE) { ... }
|
|
366
|
-
|
|
367
|
-
// Clear variable names
|
|
368
|
-
const doubledValues = data.map(item => item.value * 2);
|
|
369
|
-
|
|
370
|
-
// Async/await
|
|
371
|
-
const data = await getData();
|
|
372
|
-
const result = await processData(data);
|
|
373
|
-
const saved = await saveResult(result);
|
|
374
|
-
|
|
375
|
-
// Proper error handling
|
|
376
|
-
try {
|
|
377
|
-
await riskyOperation();
|
|
378
|
-
} catch (error) {
|
|
379
|
-
logger.error('Operation failed', { error });
|
|
380
|
-
throw new OperationError('Failed to complete', { cause: error });
|
|
381
|
-
}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
## Performance Considerations
|
|
385
|
-
|
|
386
|
-
### Choose Appropriate Data Structures
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
// Use Set for unique values
|
|
390
|
-
const uniqueIds = new Set(items.map(item => item.id));
|
|
391
|
-
|
|
392
|
-
// Use Map for key-value lookups
|
|
393
|
-
const userMap = new Map(users.map(u => [u.id, u]));
|
|
394
|
-
|
|
395
|
-
// Use Array for ordered collections
|
|
396
|
-
const sortedItems = items.sort((a, b) => a.priority - b.priority);
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### Avoid Unnecessary Iterations
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
// Bad: Multiple iterations
|
|
403
|
-
const active = users.filter(u => u.isActive);
|
|
404
|
-
const count = active.length;
|
|
405
|
-
const names = active.map(u => u.name);
|
|
406
|
-
|
|
407
|
-
// Good: Single iteration
|
|
408
|
-
const { count, names } = users.reduce(
|
|
409
|
-
(acc, user) => {
|
|
410
|
-
if (user.isActive) {
|
|
411
|
-
acc.count++;
|
|
412
|
-
acc.names.push(user.name);
|
|
413
|
-
}
|
|
414
|
-
return acc;
|
|
415
|
-
},
|
|
416
|
-
{ count: 0, names: [] as string[] }
|
|
417
|
-
);
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### Cache Expensive Computations
|
|
421
|
-
|
|
422
|
-
```typescript
|
|
423
|
-
class DataProcessor {
|
|
424
|
-
private cache = new Map<string, ProcessedData>();
|
|
425
|
-
|
|
426
|
-
process(key: string, data: RawData): ProcessedData {
|
|
427
|
-
if (this.cache.has(key)) {
|
|
428
|
-
return this.cache.get(key)!;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const result = expensiveComputation(data);
|
|
432
|
-
this.cache.set(key, result);
|
|
433
|
-
return result;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
## Final Implementation Checklist
|
|
439
|
-
|
|
440
|
-
Before submitting code:
|
|
441
|
-
|
|
442
|
-
1. **Verify it works**: Test manually and with automated tests
|
|
443
|
-
2. **Check code quality**: Run linter and formatter
|
|
444
|
-
3. **Review your own code**: Read it as if you're reviewing someone else's
|
|
445
|
-
4. **Update documentation**: Keep docs in sync with code
|
|
446
|
-
5. **Clean up**: Remove console.logs, commented code, debug statements
|
|
447
|
-
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
*This meta-instruction helps you implement features efficiently and correctly. It activates automatically when code implementation tasks are detected.*
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
# 🗺️ Strategic Planning & Roadmap Creation Mode
|
|
2
|
-
|
|
3
|
-
*This context-specific meta-instruction activates when you're planning features, creating roadmaps, or designing architecture.*
|
|
4
|
-
|
|
5
|
-
## Planning Mindset
|
|
6
|
-
|
|
7
|
-
You are in **strategic planning mode**. Focus on:
|
|
8
|
-
- High-level architecture and design decisions
|
|
9
|
-
- Breaking complex goals into phases
|
|
10
|
-
- Identifying dependencies and risks
|
|
11
|
-
- Creating actionable roadmaps
|
|
12
|
-
|
|
13
|
-
## Effective Roadmap Creation
|
|
14
|
-
|
|
15
|
-
### 1. Clarify the Vision
|
|
16
|
-
|
|
17
|
-
**Before creating any plan:**
|
|
18
|
-
- Rephrase the user's request in your own words
|
|
19
|
-
- Ask clarifying questions about scope, constraints, timeline
|
|
20
|
-
- Understand the "why" behind the request
|
|
21
|
-
- Identify success criteria
|
|
22
|
-
|
|
23
|
-
**Example:**
|
|
24
|
-
```
|
|
25
|
-
User: "We need to add authentication"
|
|
26
|
-
|
|
27
|
-
Agent clarifies:
|
|
28
|
-
- What type of auth? (OAuth, JWT, session-based?)
|
|
29
|
-
- Who are the users? (internal, external, both?)
|
|
30
|
-
- Security requirements? (2FA, SSO?)
|
|
31
|
-
- Timeline constraints?
|
|
32
|
-
- Integration points with existing system?
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2. Research Existing Architecture
|
|
36
|
-
|
|
37
|
-
**Investigate current state:**
|
|
38
|
-
- Search for similar features already implemented
|
|
39
|
-
- Understand current patterns and conventions
|
|
40
|
-
- Identify technical debt or constraints
|
|
41
|
-
- Find related configuration files
|
|
42
|
-
- Review existing documentation
|
|
43
|
-
|
|
44
|
-
**Use semantic search** to find:
|
|
45
|
-
- Authentication patterns: `auth OR authentication OR login OR session`
|
|
46
|
-
- API patterns: `API OR endpoint OR route OR controller`
|
|
47
|
-
- Database patterns: `model OR schema OR migration OR entity`
|
|
48
|
-
|
|
49
|
-
### 3. Break Into Logical Phases
|
|
50
|
-
|
|
51
|
-
**Create 3-7 high-level phases:**
|
|
52
|
-
- Each phase should be independently valuable
|
|
53
|
-
- Later phases can build on earlier ones
|
|
54
|
-
- Each phase should have clear entry/exit criteria
|
|
55
|
-
- Estimate complexity/time for each phase
|
|
56
|
-
|
|
57
|
-
**Good phase structure:**
|
|
58
|
-
```
|
|
59
|
-
Phase 1: Foundation (1-2 weeks)
|
|
60
|
-
- Core infrastructure
|
|
61
|
-
- Basic data models
|
|
62
|
-
- Essential utilities
|
|
63
|
-
|
|
64
|
-
Phase 2: Core Features (2-3 weeks)
|
|
65
|
-
- Main functionality
|
|
66
|
-
- API endpoints
|
|
67
|
-
- Business logic
|
|
68
|
-
|
|
69
|
-
Phase 3: Polish & Testing (1 week)
|
|
70
|
-
- Error handling
|
|
71
|
-
- Comprehensive tests
|
|
72
|
-
- Documentation
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### 4. Identify Dependencies & Risks
|
|
76
|
-
|
|
77
|
-
**For each phase, list:**
|
|
78
|
-
- **Prerequisites**: What must be done first?
|
|
79
|
-
- **Blockers**: What could prevent progress?
|
|
80
|
-
- **Technical risks**: What might not work as planned?
|
|
81
|
-
- **Dependencies**: External libraries, APIs, services
|
|
82
|
-
- **Unknowns**: What needs research/prototyping?
|
|
83
|
-
|
|
84
|
-
**Risk matrix:**
|
|
85
|
-
- High impact + High probability = Address immediately
|
|
86
|
-
- High impact + Low probability = Have mitigation plan
|
|
87
|
-
- Low impact + High probability = Monitor
|
|
88
|
-
- Low impact + Low probability = Accept
|
|
89
|
-
|
|
90
|
-
### 5. Define Success Metrics
|
|
91
|
-
|
|
92
|
-
**Each phase needs:**
|
|
93
|
-
- **Deliverables**: What will be built?
|
|
94
|
-
- **Success criteria**: How will we know it's done?
|
|
95
|
-
- **Test criteria**: How will we verify it works?
|
|
96
|
-
- **Documentation**: What needs documenting?
|
|
97
|
-
|
|
98
|
-
**Example success criteria:**
|
|
99
|
-
```
|
|
100
|
-
Phase 1 Complete When:
|
|
101
|
-
✓ Database schema migrated
|
|
102
|
-
✓ Core models implemented
|
|
103
|
-
✓ Unit tests passing
|
|
104
|
-
✓ API endpoints returning 200
|
|
105
|
-
✓ Documentation updated
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### 6. Consider Alternatives
|
|
109
|
-
|
|
110
|
-
**Don't lock into first solution:**
|
|
111
|
-
- List 2-3 different approaches
|
|
112
|
-
- Compare pros/cons of each
|
|
113
|
-
- Recommend one with justification
|
|
114
|
-
- Note trade-offs clearly
|
|
115
|
-
|
|
116
|
-
**Decision matrix:**
|
|
117
|
-
```
|
|
118
|
-
Option A (JWT):
|
|
119
|
-
✓ Stateless, scalable
|
|
120
|
-
✗ Complex refresh logic
|
|
121
|
-
|
|
122
|
-
Option B (Sessions):
|
|
123
|
-
✓ Simple, proven
|
|
124
|
-
✗ Server state, scaling complexity
|
|
125
|
-
|
|
126
|
-
Recommendation: Option A for microservices, Option B for monolith
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Strategic Thinking Patterns
|
|
130
|
-
|
|
131
|
-
### Top-Down Analysis
|
|
132
|
-
|
|
133
|
-
Start broad, then narrow:
|
|
134
|
-
1. **System level**: How does this fit in overall architecture?
|
|
135
|
-
2. **Component level**: Which parts are affected?
|
|
136
|
-
3. **Code level**: What specific files/functions change?
|
|
137
|
-
4. **Detail level**: Implementation specifics
|
|
138
|
-
|
|
139
|
-
### Dependency Mapping
|
|
140
|
-
|
|
141
|
-
**Create dependency graphs:**
|
|
142
|
-
```
|
|
143
|
-
User Model
|
|
144
|
-
↓
|
|
145
|
-
Auth Service
|
|
146
|
-
↓
|
|
147
|
-
Login Controller → Session Store
|
|
148
|
-
↓ ↓
|
|
149
|
-
API Routes Redis/Database
|
|
150
|
-
↓
|
|
151
|
-
Frontend
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Timeline Estimation
|
|
155
|
-
|
|
156
|
-
**Be realistic:**
|
|
157
|
-
- Buffer for unknowns (add 30-50%)
|
|
158
|
-
- Account for testing and review time
|
|
159
|
-
- Consider team capacity and velocity
|
|
160
|
-
- Note parallel vs. sequential work
|
|
161
|
-
|
|
162
|
-
## Common Planning Pitfalls to Avoid
|
|
163
|
-
|
|
164
|
-
❌ **Don't:**
|
|
165
|
-
- Jump straight to implementation details
|
|
166
|
-
- Create overly complex plans with 20+ phases
|
|
167
|
-
- Ignore existing code patterns
|
|
168
|
-
- Forget about testing and documentation
|
|
169
|
-
- Assume everything will go perfectly
|
|
170
|
-
|
|
171
|
-
✓ **Do:**
|
|
172
|
-
- Keep plans flexible and iterative
|
|
173
|
-
- Focus on value delivery per phase
|
|
174
|
-
- Build on existing patterns
|
|
175
|
-
- Plan for failures and edge cases
|
|
176
|
-
- Leave room for learning and adjustment
|
|
177
|
-
|
|
178
|
-
## Output Format for Roadmaps
|
|
179
|
-
|
|
180
|
-
**Use this structure:**
|
|
181
|
-
|
|
182
|
-
```markdown
|
|
183
|
-
# [Feature Name] Implementation Roadmap
|
|
184
|
-
|
|
185
|
-
## Vision
|
|
186
|
-
[One paragraph describing the goal]
|
|
187
|
-
|
|
188
|
-
## Success Criteria
|
|
189
|
-
- [What success looks like]
|
|
190
|
-
- [How we'll measure it]
|
|
191
|
-
|
|
192
|
-
## Approach
|
|
193
|
-
[2-3 paragraphs on the chosen approach and why]
|
|
194
|
-
|
|
195
|
-
## Phases
|
|
196
|
-
|
|
197
|
-
### Phase 1: [Name] (Timeline)
|
|
198
|
-
**Goal**: [What this phase achieves]
|
|
199
|
-
|
|
200
|
-
**Tasks**:
|
|
201
|
-
- [ ] Task 1
|
|
202
|
-
- [ ] Task 2
|
|
203
|
-
|
|
204
|
-
**Dependencies**: [What's needed before starting]
|
|
205
|
-
**Deliverables**: [What's produced]
|
|
206
|
-
**Success Criteria**: [How we know it's done]
|
|
207
|
-
|
|
208
|
-
[Repeat for each phase]
|
|
209
|
-
|
|
210
|
-
## Risks & Mitigation
|
|
211
|
-
- **Risk**: [Description] | **Mitigation**: [How to address]
|
|
212
|
-
|
|
213
|
-
## Alternatives Considered
|
|
214
|
-
- **Option A**: [Description] - [Pros/Cons]
|
|
215
|
-
- **Option B**: [Description] - [Pros/Cons]
|
|
216
|
-
|
|
217
|
-
## Open Questions
|
|
218
|
-
- [Question 1]
|
|
219
|
-
- [Question 2]
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Examples of Good Planning
|
|
223
|
-
|
|
224
|
-
### Example 1: Adding Search Feature
|
|
225
|
-
|
|
226
|
-
**Good approach:**
|
|
227
|
-
1. Research existing search implementations
|
|
228
|
-
2. Define search requirements (fuzzy, exact, faceted?)
|
|
229
|
-
3. Choose technology (Elasticsearch, PostgreSQL FTS, algolia?)
|
|
230
|
-
4. Phase 1: Basic text search in database
|
|
231
|
-
5. Phase 2: Advanced filters and sorting
|
|
232
|
-
6. Phase 3: Search analytics and optimization
|
|
233
|
-
7. Document tradeoffs and scaling considerations
|
|
234
|
-
|
|
235
|
-
### Example 2: Database Migration
|
|
236
|
-
|
|
237
|
-
**Good approach:**
|
|
238
|
-
1. Analyze current schema and data volume
|
|
239
|
-
2. Design new schema with migration path
|
|
240
|
-
3. Phase 1: Create new schema alongside old
|
|
241
|
-
4. Phase 2: Dual-write to both schemas
|
|
242
|
-
5. Phase 3: Migrate historical data
|
|
243
|
-
6. Phase 4: Switch reads to new schema
|
|
244
|
-
7. Phase 5: Deprecate old schema
|
|
245
|
-
8. Plan rollback strategy for each phase
|
|
246
|
-
|
|
247
|
-
## Collaboration in Planning
|
|
248
|
-
|
|
249
|
-
**Involve stakeholders:**
|
|
250
|
-
- Present multiple options
|
|
251
|
-
- Explain trade-offs clearly
|
|
252
|
-
- Ask for input on priorities
|
|
253
|
-
- Get buy-in on timeline
|
|
254
|
-
- Document decisions and rationale
|
|
255
|
-
|
|
256
|
-
**Questions to ask:**
|
|
257
|
-
- "Is this the right priority?"
|
|
258
|
-
- "Are we solving the right problem?"
|
|
259
|
-
- "What constraints am I missing?"
|
|
260
|
-
- "What's the simplest thing that could work?"
|
|
261
|
-
- "How will this evolve over time?"
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
*This meta-instruction helps you create better roadmaps and strategic plans. It activates automatically when planning tasks are detected.*
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Framework: NestJS
|
|
2
|
-
- **ALWAYS** follow the standard architecture: `Module` > `Controller` > `Service`.
|
|
3
|
-
- **CONTROLLERS** should *only* handle HTTP request/response logic and DTO validation.
|
|
4
|
-
- **SERVICES** should contain *all* business logic.
|
|
5
|
-
- **ALWAYS** use DTOs (Data Transfer Objects) for `POST`/`PUT` bodies and validate them with `class-validator`.
|
|
6
|
-
- **ALWAYS** use Dependency Injection. Never instantiate services manually.
|
|
7
|
-
- **MODULES**: Keep modules granular. Import only what is needed.
|