@aicgen/aicgen 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,622 +0,0 @@
1
- # Best Practices Rules
2
-
3
- # Planning Best Practices
4
-
5
- ## Plan Before Implementation
6
-
7
- **ALWAYS design and plan before writing code:**
8
-
9
- 1. **Understand Requirements**
10
- - Clarify the goal and scope
11
- - Identify constraints and dependencies
12
- - Ask questions about ambiguous requirements
13
-
14
- 2. **Break Down Into Phases**
15
- - Divide work into logical phases
16
- - Define deliverables for each phase
17
- - Prioritize phases by value and dependencies
18
-
19
- 3. **Design First**
20
- - Sketch architecture and data flow
21
- - Identify components and interfaces
22
- - Consider edge cases and error scenarios
23
-
24
- 4. **Get User Approval**
25
- - Present the plan to stakeholders
26
- - Explain trade-offs and alternatives
27
- - Wait for approval before implementation
28
-
29
- ## Never Make Assumptions
30
-
31
- **CRITICAL: When in doubt, ASK:**
32
-
33
- ```typescript
34
- // ❌ BAD: Assuming what user wants
35
- async function processOrder(orderId: string) {
36
- // Assuming we should send email, but maybe not?
37
- await sendConfirmationEmail(orderId);
38
- // Assuming payment is already captured?
39
- await fulfillOrder(orderId);
40
- }
41
-
42
- // ✅ GOOD: Clarify requirements first
43
- // Q: Should we send confirmation email at this stage?
44
- // Q: Is payment already captured or should we capture it here?
45
- // Q: What happens if fulfillment fails?
46
- ```
47
-
48
- **Ask about:**
49
- - Expected behavior in edge cases
50
- - Error handling strategy
51
- - Performance requirements
52
- - Security considerations
53
- - User experience preferences
54
-
55
- ## Plan in Phases
56
-
57
- **Structure work into clear phases:**
58
-
59
- ### Phase 1: Foundation
60
- - Set up project structure
61
- - Configure tooling and dependencies
62
- - Create basic types and interfaces
63
-
64
- ### Phase 2: Core Implementation
65
- - Implement main business logic
66
- - Add error handling
67
- - Write unit tests
68
-
69
- ### Phase 3: Integration
70
- - Connect components
71
- - Add integration tests
72
- - Handle edge cases
73
-
74
- ### Phase 4: Polish
75
- - Performance optimization
76
- - Documentation
77
- - Final review
78
-
79
- **Checkpoint after each phase:**
80
- - Demo functionality
81
- - Get feedback
82
- - Adjust plan if needed
83
-
84
- ## Planning Template
85
-
86
- ```markdown
87
- ## Goal
88
- [What are we building and why?]
89
-
90
- ## Requirements
91
- - [ ] Requirement 1
92
- - [ ] Requirement 2
93
- - [ ] Requirement 3
94
-
95
- ## Questions for Clarification
96
- 1. [Question about requirement X]
97
- 2. [Question about edge case Y]
98
- 3. [Question about preferred approach for Z]
99
-
100
- ## Proposed Approach
101
- [Describe the solution]
102
-
103
- ## Phases
104
- 1. **Phase 1**: [Description]
105
- - Task 1
106
- - Task 2
107
-
108
- 2. **Phase 2**: [Description]
109
- - Task 1
110
- - Task 2
111
-
112
- ## Risks & Mitigation
113
- - **Risk**: [Description]
114
- **Mitigation**: [How to handle]
115
-
116
- ## Alternatives Considered
117
- - **Option A**: [Pros/Cons]
118
- - **Option B**: [Pros/Cons]
119
- - **Chosen**: Option A because [reason]
120
- ```
121
-
122
- ## Communication Principles
123
-
124
- 1. **Ask Early**: Don't wait until you're stuck
125
- 2. **Be Specific**: "Should error X retry or fail immediately?"
126
- 3. **Propose Options**: "Would you prefer A or B?"
127
- 4. **Explain Trade-offs**: "Fast but risky vs. Slow but safe"
128
- 5. **Document Decisions**: Record what was decided and why
129
-
130
- ## Anti-Patterns
131
-
132
- ❌ **Don't:**
133
- - Start coding without understanding requirements
134
- - Assume you know what the user wants
135
- - Skip the planning phase to "save time"
136
- - Make architectural decisions without discussion
137
- - Proceed with unclear requirements
138
-
139
- ✅ **Do:**
140
- - Ask questions when requirements are vague
141
- - Create a plan and get it approved
142
- - Break work into reviewable phases
143
- - Document decisions and reasoning
144
- - Communicate early and often
145
-
146
-
147
- ---
148
-
149
- # Documentation Organization
150
-
151
- ## Keep Root Clean
152
-
153
- **RULE: Documentation must NOT clutter the project root.**
154
-
155
- ```
156
- ❌ BAD: Root folder mess
157
- project/
158
- ├── README.md
159
- ├── ARCHITECTURE.md
160
- ├── API_DOCS.md
161
- ├── DEPLOYMENT.md
162
- ├── TROUBLESHOOTING.md
163
- ├── USER_GUIDE.md
164
- ├── DATABASE_SCHEMA.md
165
- ├── TESTING_GUIDE.md
166
- └── ... (20 more .md files)
167
-
168
- ✅ GOOD: Organized structure
169
- project/
170
- ├── README.md (overview only)
171
- ├── docs/
172
- │ ├── architecture/
173
- │ ├── api/
174
- │ ├── deployment/
175
- │ └── guides/
176
- └── src/
177
- ```
178
-
179
- ## Documentation Structure
180
-
181
- **Standard documentation folder:**
182
-
183
- ```
184
- docs/
185
- ├── architecture/
186
- │ ├── overview.md
187
- │ ├── decisions/ # Architecture Decision Records
188
- │ │ ├── 001-database-choice.md
189
- │ │ └── 002-api-design.md
190
- │ └── diagrams/
191
-
192
- ├── api/
193
- │ ├── endpoints.md
194
- │ ├── authentication.md
195
- │ └── examples/
196
-
197
- ├── guides/
198
- │ ├── getting-started.md
199
- │ ├── development.md
200
- │ ├── deployment.md
201
- │ └── troubleshooting.md
202
-
203
- ├── features/ # Organize by feature
204
- │ ├── user-auth/
205
- │ │ ├── overview.md
206
- │ │ ├── implementation.md
207
- │ │ └── testing.md
208
- │ ├── payments/
209
- │ └── notifications/
210
-
211
- └── planning/ # Active work planning
212
- ├── memory-lane.md # Context preservation
213
- ├── current-phase.md # Active work
214
- └── next-steps.md # Backlog
215
- ```
216
-
217
- ## Memory Lane Document
218
-
219
- **CRITICAL: Maintain context across sessions**
220
-
221
- ### Purpose
222
- When AI context limit is reached, reload from memory lane to restore working context.
223
-
224
- ### Structure
225
-
226
- ```markdown
227
- # Memory Lane - Project Context
228
-
229
- ## Last Updated
230
- 2024-12-10 15:30
231
-
232
- ## Current Objective
233
- Implementing user authentication system with OAuth2 support
234
-
235
- ## Recent Progress
236
- - ✅ Set up database schema (2024-12-08)
237
- - ✅ Implemented user registration (2024-12-09)
238
- - 🔄 Working on: OAuth2 integration (2024-12-10)
239
- - ⏳ Next: Session management
240
-
241
- ## Key Decisions
242
- 1. **Database**: PostgreSQL chosen for ACID compliance
243
- 2. **Auth Strategy**: OAuth2 + JWT tokens
244
- 3. **Session Store**: Redis for performance
245
-
246
- ## Important Files
247
- - `src/auth/oauth.ts` - OAuth2 implementation (IN PROGRESS)
248
- - `src/models/user.ts` - User model and validation
249
- - `docs/architecture/decisions/003-auth-system.md` - Full context
250
-
251
- ## Active Questions
252
- 1. Should we support refresh tokens? (Pending user decision)
253
- 2. Token expiry: 1h or 24h? (Pending user decision)
254
-
255
- ## Technical Context
256
- - Using Passport.js for OAuth
257
- - Google and GitHub providers configured
258
- - Callback URLs: /auth/google/callback, /auth/github/callback
259
-
260
- ## Known Issues
261
- - OAuth redirect not working in development (investigating)
262
- - Need to add rate limiting to prevent abuse
263
-
264
- ## Next Session
265
- 1. Fix OAuth redirect issue
266
- 2. Implement refresh token rotation
267
- 3. Add comprehensive auth tests
268
- ```
269
-
270
- ### Update Frequency
271
- - Update after each significant milestone
272
- - Update before context limit is reached
273
- - Update when switching between features
274
-
275
- ## Context Reload Strategy
276
-
277
- **For AI Tools with Hooks:**
278
-
279
- Create a hook to reload memory lane on startup:
280
-
281
- ```json
282
- {
283
- "hooks": {
284
- "startup": {
285
- "command": "cat docs/planning/memory-lane.md"
286
- }
287
- }
288
- }
289
- ```
290
-
291
- **For AI Tools with Agents:**
292
-
293
- Create a context restoration agent:
294
-
295
- ```markdown
296
- # Context Restoration Agent
297
-
298
- Task: Read and summarize current project state
299
-
300
- Sources:
301
- 1. docs/planning/memory-lane.md
302
- 2. docs/architecture/decisions/ (recent ADRs)
303
- 3. git log --oneline -10 (recent commits)
304
-
305
- Output: Concise summary of where we are and what's next
306
- ```
307
-
308
- ## Feature Documentation
309
-
310
- **Organize by feature/scope, not by type:**
311
-
312
- ```
313
- ❌ BAD: Organized by document type
314
- docs/
315
- ├── specifications/
316
- │ ├── auth.md
317
- │ ├── payments.md
318
- │ └── notifications.md
319
- ├── implementations/
320
- │ ├── auth.md
321
- │ ├── payments.md
322
- │ └── notifications.md
323
- └── tests/
324
- ├── auth.md
325
- └── payments.md
326
-
327
- ✅ GOOD: Organized by feature
328
- docs/features/
329
- ├── auth/
330
- │ ├── specification.md
331
- │ ├── implementation.md
332
- │ ├── api.md
333
- │ └── testing.md
334
- ├── payments/
335
- │ ├── specification.md
336
- │ ├── implementation.md
337
- │ └── providers.md
338
- └── notifications/
339
- ├── specification.md
340
- └── channels.md
341
- ```
342
-
343
- **Benefits:**
344
- - All related docs in one place
345
- - Easy to find feature-specific information
346
- - Natural scope boundaries
347
- - Easier to maintain
348
-
349
- ## Planning Documents
350
-
351
- **Active planning should be in docs/planning/:**
352
-
353
- ```
354
- docs/planning/
355
- ├── memory-lane.md # Context preservation
356
- ├── current-sprint.md # Active work
357
- ├── backlog.md # Future work
358
- └── spike-results/ # Research findings
359
- ├── database-options.md
360
- └── auth-libraries.md
361
- ```
362
-
363
- ## Documentation Principles
364
-
365
- 1. **Separate folder**: All docs in `docs/` directory
366
- 2. **Organize by scope**: Group by feature, not document type
367
- 3. **Keep root clean**: Only README.md in project root
368
- 4. **Maintain memory lane**: Update regularly for context preservation
369
- 5. **Link related docs**: Use relative links between related documents
370
-
371
- ## README Guidelines
372
-
373
- **Root README should be concise:**
374
-
375
- ```markdown
376
- # Project Name
377
-
378
- Brief description
379
-
380
- ## Quick Start
381
- [Link to docs/guides/getting-started.md]
382
-
383
- ## Documentation
384
- - [Architecture](docs/architecture/overview.md)
385
- - [API Docs](docs/api/endpoints.md)
386
- - [Development Guide](docs/guides/development.md)
387
-
388
- ## Contributing
389
- [Link to CONTRIBUTING.md or docs/guides/contributing.md]
390
- ```
391
-
392
- **Keep it short, link to detailed docs.**
393
-
394
- ## Anti-Patterns
395
-
396
- ❌ **Don't:**
397
- - Put 10+ markdown files in project root
398
- - Mix documentation types in same folder
399
- - Forget to update memory lane before context expires
400
- - Create documentation without clear organization
401
- - Duplicate information across multiple docs
402
-
403
- ✅ **Do:**
404
- - Use `docs/` directory for all documentation
405
- - Organize by feature/scope
406
- - Maintain memory lane for context preservation
407
- - Link related documents together
408
- - Update docs as code evolves
409
-
410
-
411
- ---
412
-
413
- # Code Review Practices
414
-
415
- ## Review Checklist
416
-
417
- - [ ] Code follows project style guidelines
418
- - [ ] No obvious bugs or logic errors
419
- - [ ] Error handling is appropriate
420
- - [ ] Tests cover new functionality
421
- - [ ] No security vulnerabilities introduced
422
- - [ ] Performance implications considered
423
- - [ ] Documentation updated if needed
424
-
425
- ## Giving Feedback
426
-
427
- **Good:**
428
- ```
429
- Consider using `Array.find()` here instead of `filter()[0]` -
430
- it's more readable and stops at the first match.
431
- ```
432
-
433
- **Bad:**
434
- ```
435
- This is wrong.
436
- ```
437
-
438
- ## PR Description Template
439
-
440
- ```markdown
441
- ## Summary
442
- Brief description of changes
443
-
444
- ## Changes
445
- - Added X feature
446
- - Fixed Y bug
447
- - Refactored Z
448
-
449
- ## Testing
450
- - [ ] Unit tests added
451
- - [ ] Manual testing performed
452
-
453
- ## Screenshots (if UI changes)
454
- ```
455
-
456
- ## Best Practices
457
-
458
- - Review promptly (within 24 hours)
459
- - Focus on logic and design, not style (use linters)
460
- - Ask questions rather than make demands
461
- - Praise good solutions
462
- - Keep PRs small and focused
463
- - Use "nitpick:" prefix for minor suggestions
464
- - Approve with minor comments when appropriate
465
-
466
-
467
- ---
468
-
469
- # Refactoring Patterns
470
-
471
- ## Common Code Smells
472
-
473
- ### Long Method
474
- Split into smaller, focused functions.
475
-
476
- ```typescript
477
- // Before
478
- function processOrder(order: Order) {
479
- // 100 lines of code...
480
- }
481
-
482
- // After
483
- function processOrder(order: Order) {
484
- validateOrder(order);
485
- calculateTotals(order);
486
- applyDiscounts(order);
487
- saveOrder(order);
488
- }
489
- ```
490
-
491
- ### Duplicate Code
492
- Extract common logic.
493
-
494
- ```typescript
495
- // Before
496
- function getAdminUsers() {
497
- return users.filter(u => u.role === 'admin' && u.active);
498
- }
499
- function getModeratorUsers() {
500
- return users.filter(u => u.role === 'moderator' && u.active);
501
- }
502
-
503
- // After
504
- function getActiveUsersByRole(role: string) {
505
- return users.filter(u => u.role === role && u.active);
506
- }
507
- ```
508
-
509
- ### Primitive Obsession
510
- Use value objects.
511
-
512
- ```typescript
513
- // Before
514
- function sendEmail(email: string) { /* ... */ }
515
-
516
- // After
517
- class Email {
518
- constructor(private value: string) {
519
- if (!this.isValid(value)) throw new Error('Invalid email');
520
- }
521
- }
522
- function sendEmail(email: Email) { /* ... */ }
523
- ```
524
-
525
- ### Feature Envy
526
- Move method to class it uses most.
527
-
528
- ```typescript
529
- // Before - Order is accessing customer too much
530
- class Order {
531
- getDiscount() {
532
- return this.customer.isPremium() ?
533
- this.customer.premiumDiscount :
534
- this.customer.regularDiscount;
535
- }
536
- }
537
-
538
- // After
539
- class Customer {
540
- getDiscount(): number {
541
- return this.isPremium() ? this.premiumDiscount : this.regularDiscount;
542
- }
543
- }
544
- ```
545
-
546
- ## Safe Refactoring Steps
547
-
548
- 1. Ensure tests pass before refactoring
549
- 2. Make one small change at a time
550
- 3. Run tests after each change
551
- 4. Commit frequently
552
- 5. Refactor in separate commits from feature work
553
-
554
- ## Best Practices
555
-
556
- - Refactor when adding features, not separately
557
- - Keep refactoring commits separate
558
- - Use IDE refactoring tools when available
559
- - Write tests before refactoring if missing
560
-
561
-
562
- ---
563
-
564
- # Version Control Patterns
565
-
566
- ## Branching Strategies
567
-
568
- ### GitHub Flow
569
- Simple: main + feature branches.
570
-
571
- ```
572
- main ─────●─────●─────●─────●─────
573
- \ /
574
- feature ●───●───●
575
- ```
576
-
577
- ### Git Flow
578
- For scheduled releases: main, develop, feature, release, hotfix.
579
-
580
- ```
581
- main ─────●─────────────●─────
582
- \ /
583
- release ●─────────●
584
- \ /
585
- develop ●───●───●───●───●───●───
586
- \ /
587
- feature ●───●
588
- ```
589
-
590
- ## Commit Messages
591
-
592
- ```
593
- feat: add user authentication
594
-
595
- - Implement JWT-based auth
596
- - Add login/logout endpoints
597
- - Include password hashing
598
-
599
- Closes #123
600
- ```
601
-
602
- **Prefixes:**
603
- - `feat:` - New feature
604
- - `fix:` - Bug fix
605
- - `refactor:` - Code change that doesn't fix bug or add feature
606
- - `docs:` - Documentation only
607
- - `test:` - Adding tests
608
- - `chore:` - Maintenance tasks
609
-
610
- ## Best Practices
611
-
612
- - Keep commits atomic and focused
613
- - Write descriptive commit messages
614
- - Pull/rebase before pushing
615
- - Never force push to shared branches
616
- - Use pull requests for code review
617
- - Delete merged branches
618
- - Tag releases with semantic versions
619
-
620
-
621
- ---
622
- *Generated by aicgen*