Skip to content

Commit a5cf1b8

Browse files
authored
Merge pull request #65 from lambda-curry/post-section-apis
2 parents 1d58583 + 1af78db commit a5cf1b8

File tree

66 files changed

+3439
-837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3439
-837
lines changed

.cursor/rules/README.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Cursor Rules for Medusa2 Starter
2+
3+
This directory contains comprehensive cursor rules for the Medusa2 starter project, designed to ensure consistent code quality, architectural patterns, and development practices across the entire codebase.
4+
5+
## 📁 Rule Organization
6+
7+
Our cursor rules are organized following best practices for maintainability and clarity:
8+
9+
```
10+
.cursor/rules/
11+
├── medusa-backend.mdc # Backend API, modules, workflows
12+
├── medusa-admin.mdc # Admin UI components and patterns
13+
├── typescript-patterns.mdc # TypeScript conventions
14+
├── remix-hook-form-migration.mdc # Form migration patterns
15+
└── README.md # This file
16+
```
17+
18+
## 🎯 Rule Categories
19+
20+
### 1. **Medusa Backend** (`medusa-backend.mdc`)
21+
**Scope**: `apps/medusa/src/api/**/*`, `apps/medusa/src/modules/**/*`, `apps/medusa/src/workflows/**/*`
22+
23+
Covers:
24+
- API endpoint patterns and structure
25+
- Module development (models, services, migrations)
26+
- Workflow and step implementation
27+
- Database patterns and migrations
28+
- Type definitions for backend APIs
29+
- Security and validation patterns
30+
- Performance optimization
31+
- Testing strategies
32+
33+
**Key Patterns**:
34+
- Workflow-first architecture for business logic
35+
- Consistent API response structures
36+
- Proper error handling and rollback mechanisms
37+
- Type-safe service resolution from container
38+
39+
### 2. **Medusa Admin** (`medusa-admin.mdc`)
40+
**Scope**: `apps/medusa/src/admin/**/*`
41+
42+
Covers:
43+
- React component architecture and composition
44+
- Custom hooks with TanStack Query
45+
- Form handling with React Hook Form
46+
- State management patterns
47+
- UI component usage (Medusa UI)
48+
- Routing and navigation
49+
- Performance optimization
50+
- Accessibility best practices
51+
52+
**Key Patterns**:
53+
- Controlled form components with proper typing
54+
- Consistent list item and sidebar components
55+
- Declarative state management
56+
- Proper error handling with toast notifications
57+
58+
### 3. **TypeScript Patterns** (`typescript-patterns.mdc`)
59+
**Scope**: `**/*.ts`, `**/*.tsx`
60+
61+
Covers:
62+
- Strict type safety practices
63+
- Interface and type definitions
64+
- Generic patterns and constraints
65+
- Utility type usage
66+
- Error handling types
67+
- React component typing
68+
- Module declarations
69+
- Testing type utilities
70+
71+
**Key Patterns**:
72+
- Branded types for ID safety
73+
- Result pattern for error handling
74+
- Proper generic constraints
75+
- Type-only imports
76+
77+
### 4. **Form Migration** (`remix-hook-form-migration.mdc`)
78+
**Scope**: Form-related files during migration
79+
80+
Covers:
81+
- Migration from remix-validated-form to @lambdacurry/forms
82+
- Yup to Zod schema conversion
83+
- React Hook Form integration patterns
84+
- Error handling updates
85+
- Response structure changes
86+
87+
## 🚀 Usage Guidelines
88+
89+
### Automatic Application
90+
Most rules are set to `alwaysApply: true` and will automatically activate based on file patterns (globs). This ensures consistent application across the codebase.
91+
92+
### Manual Application
93+
For specific contexts or when working on particular features, you can manually attach rules using Cursor's rule selection interface.
94+
95+
### Rule Priority
96+
When multiple rules apply to the same file:
97+
1. More specific rules (narrower globs) take precedence
98+
2. Feature-specific rules override general patterns
99+
3. TypeScript patterns apply broadly but defer to framework-specific rules
100+
101+
## 🎨 Best Practices Enforced
102+
103+
### Code Quality
104+
- ✅ Strict TypeScript usage with no `any` types
105+
- ✅ Comprehensive error handling
106+
- ✅ Consistent naming conventions
107+
- ✅ Proper component composition
108+
- ✅ Type-safe API interactions
109+
110+
### Architecture
111+
- ✅ Workflow-based backend operations
112+
- ✅ Modular component design
113+
- ✅ Separation of concerns
114+
- ✅ Consistent state management
115+
- ✅ Proper abstraction layers
116+
117+
### Performance
118+
- ✅ Optimized React components with memo/useMemo
119+
- ✅ Efficient database queries
120+
- ✅ Proper caching strategies
121+
- ✅ Lazy loading and code splitting
122+
123+
### Security
124+
- ✅ Input validation with Zod schemas
125+
- ✅ Authenticated request handling
126+
- ✅ Proper error message sanitization
127+
- ✅ Type-safe API boundaries
128+
129+
## 🔧 Maintenance
130+
131+
### Regular Updates
132+
These rules should be updated when:
133+
- Framework versions change (Medusa, React, etc.)
134+
- New architectural patterns are established
135+
- Team conventions evolve
136+
- New best practices emerge
137+
138+
### Testing Rules
139+
Periodically test rules with:
140+
- Diverse code generation prompts
141+
- Edge case scenarios
142+
- New feature development
143+
- Refactoring operations
144+
145+
### Quality Assurance
146+
Monitor generated code for:
147+
- Adherence to established patterns
148+
- Proper error handling
149+
- Type safety compliance
150+
- Performance considerations
151+
152+
## 📚 Related Documentation
153+
154+
- [Medusa v2 Documentation](https://docs.medusajs.com/v2)
155+
- [React Hook Form Guide](https://react-hook-form.com/)
156+
- [TanStack Query Documentation](https://tanstack.com/query/latest)
157+
- [Medusa UI Components](https://ui.medusajs.com/)
158+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/)
159+
160+
## 🤝 Contributing
161+
162+
When adding or modifying rules:
163+
164+
1. **Follow the established structure** with proper YAML frontmatter
165+
2. **Include concrete examples** for both correct and incorrect patterns
166+
3. **Test thoroughly** with various prompts and scenarios
167+
4. **Update this README** when adding new rule categories
168+
5. **Consider rule interactions** and potential conflicts
169+
170+
### Rule Quality Checklist
171+
- [ ] Clear description and scope definition
172+
- [ ] Proper glob patterns for file targeting
173+
- [ ] Concrete code examples with explanations
174+
- [ ] Edge case handling
175+
- [ ] Integration with existing rules
176+
- [ ] Performance considerations
177+
- [ ] Security implications
178+
179+
## 🎯 Goals
180+
181+
These cursor rules aim to:
182+
183+
1. **Accelerate Development**: Reduce decision fatigue with clear patterns
184+
2. **Ensure Consistency**: Maintain uniform code quality across the team
185+
3. **Prevent Common Mistakes**: Catch anti-patterns before they enter the codebase
186+
4. **Facilitate Onboarding**: Help new team members understand established conventions
187+
5. **Support Scalability**: Ensure patterns work well as the codebase grows
188+
189+
## 📈 Success Metrics
190+
191+
Effective cursor rules should result in:
192+
- Faster feature development
193+
- Fewer code review comments on patterns/style
194+
- More consistent codebase architecture
195+
- Reduced debugging time
196+
- Improved code maintainability
197+
198+
---
199+
200+
*Last updated: May 29, 2025*
201+
*For questions or suggestions, please reach out to the development team.*
202+

0 commit comments

Comments
 (0)