Skip to content

feat: comprehensive cursor rules for medusa backend and admin development#68

Closed
codegen-sh[bot] wants to merge 17 commits intomainfrom
post-section-apis
Closed

feat: comprehensive cursor rules for medusa backend and admin development#68
codegen-sh[bot] wants to merge 17 commits intomainfrom
post-section-apis

Conversation

@codegen-sh
Copy link
Copy Markdown
Contributor

@codegen-sh codegen-sh Bot commented May 29, 2025

Overview

This PR adds comprehensive cursor rules for Medusa v2 development, separating backend and admin development concerns as requested. The rules are based on the architecture patterns demonstrated in PR #65 and follow the Lambda Curry cursor rules best practices guide.

📁 New Cursor Rules Structure

.cursor/rules/
├── medusa-backend.mdc          # Backend API, modules, workflows
├── medusa-admin.mdc            # Admin UI components and patterns  
├── typescript-patterns.mdc     # TypeScript conventions (updated)
├── remix-hook-form-migration.mdc # Form migration patterns (existing)
└── README.md                   # Comprehensive documentation

🎯 Key Features

Medusa Backend Rules (medusa-backend.mdc)

  • Workflow-first architecture patterns for business logic
  • API endpoint structure following Medusa v2 conventions
  • Module development patterns (models, services, migrations)
  • Type-safe service resolution from container
  • Database patterns and migration best practices
  • Security and validation with Zod schemas
  • Performance optimization guidelines
  • Testing strategies for workflows and services

Medusa Admin Rules (medusa-admin.mdc)

  • React component architecture with proper composition
  • Custom hooks with TanStack Query for server state
  • Form handling with React Hook Form and controlled components
  • UI patterns using Medusa UI components consistently
  • State management with context providers
  • Performance optimization with memo/useMemo
  • Accessibility best practices
  • Testing patterns for components and hooks

TypeScript Patterns (typescript-patterns.mdc)

  • Strict type safety practices
  • Generic patterns for reusable components
  • Utility types for type transformations
  • Error handling types with Result pattern
  • Branded types for ID safety
  • React component typing best practices
  • Configuration types for environment variables

🏗️ Architecture Patterns Enforced

Based on Derek's implementation in PR #65, these rules enforce:

  1. Separation of Concerns: Clear boundaries between backend and admin code
  2. Type Safety: Strict TypeScript usage throughout
  3. Consistent API Patterns: Standardized endpoint structure and responses
  4. Modern React Patterns: Hooks, composition, and declarative state management
  5. Performance Best Practices: Optimized queries, caching, and component rendering
  6. Security First: Input validation, authentication, and error handling

📚 Documentation

The comprehensive README.md provides:

  • Rule organization and usage guidelines
  • Best practices enforced by each rule set
  • Maintenance and quality assurance procedures
  • Success metrics and goals
  • Contributing guidelines for future rule updates

🔄 Migration Support

Maintains existing remix-hook-form-migration.mdc for ongoing form migration work while adding the new comprehensive rule structure.

✅ Benefits

  • Faster Development: Clear patterns reduce decision fatigue
  • Consistent Code Quality: Uniform standards across the team
  • Better Onboarding: New developers understand conventions quickly
  • Reduced Review Time: Fewer style/pattern discussions in PRs
  • Scalable Architecture: Patterns that grow with the codebase

This implementation follows the blog post recommendations for rule organization, includes concrete examples, and provides clear separation between backend and admin development concerns as requested.


💻 View my workAbout Codegen

antony-lambdacurry and others added 17 commits May 21, 2025 09:01
- Introduced a new Page Builder module with models for posts, authors, tags, and templates.
- Added CRUD workflows for creating, updating, deleting, and duplicating posts.
- Integrated the module with the Medusa SDK for seamless API interactions.
- Created a custom SDK for the Page Builder, enhancing admin and storefront functionalities.
- Updated dependencies and added TypeScript definitions for improved type safety.

These changes provide a robust foundation for managing content within the Medusa framework, enabling users to create and manage posts effectively.
…ment

- Add medusa-backend.mdc with API, module, and workflow patterns
- Add medusa-admin.mdc with React component and UI patterns
- Update typescript-patterns.mdc with comprehensive type safety rules
- Add comprehensive README.md for cursor rules organization
- Separate backend and admin development concerns as requested
- Follow Lambda Curry cursor rules best practices guide
- Based on architecture patterns from PR #65
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jaruesink jaruesink closed this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants