Skip to content

Add comprehensive cursor rules for enhanced development experience#72

Merged
jaruesink merged 5 commits intomainfrom
codegen-bot/cursor-rules-implementation-1748117239
May 26, 2025
Merged

Add comprehensive cursor rules for enhanced development experience#72
jaruesink merged 5 commits intomainfrom
codegen-bot/cursor-rules-implementation-1748117239

Conversation

@codegen-sh
Copy link
Copy Markdown
Contributor

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

Overview

This PR adds four comprehensive cursor rules that complement the existing Storybook testing rules, providing AI-optimized guidance for consistent development patterns across the lambda-curry/forms component library.

🎯 New Cursor Rules Added

1. Form Component Integration Patterns (.cursor/rules/form-component-patterns.mdc)

  • Remix Hook Form + Zod integration patterns based on existing components
  • Component wrapper patterns (control prop handling, composition)
  • Validation error handling for both client and server-side
  • Form submission and fetcher patterns with proper async handling
  • Schema definition patterns with TypeScript inference

2. React + TypeScript Component Architecture (.cursor/rules/react-typescript-patterns.mdc)

  • Component structure patterns with consistent organization
  • TypeScript interface conventions for props and component APIs
  • Hook patterns and custom hook development
  • Performance optimization with memoization and refs
  • Event handler patterns and error boundaries

3. UI Component Patterns (.cursor/rules/ui-component-patterns.mdc)

  • Class Variance Authority (CVA) usage for component variants
  • Radix UI integration best practices and compound components
  • Tailwind CSS organization with responsive and state patterns
  • Accessibility patterns (ARIA, keyboard navigation, focus management)
  • Slot pattern for polymorphic components

4. Monorepo Organization (.cursor/rules/monorepo-organization.mdc)

  • Package import conventions (@lambdacurry/forms/remix-hook-form/ vs relative)
  • Cross-package dependency rules and workspace management
  • Export/import patterns for optimal tree-shaking
  • File naming and directory structure (kebab-case, component organization)
  • Build configuration and TypeScript path mapping

🔥 Key Benefits

Consistency Across Development

  • Standardized patterns for form component development
  • Consistent TypeScript usage with proper typing conventions
  • Unified component architecture following React 19 best practices
  • Organized import/export patterns across the monorepo

Enhanced Developer Experience

  • AI-guided development with context-aware suggestions
  • Reduced code review cycles through consistent patterns
  • Faster onboarding for new team members
  • Prevention of common mistakes through explicit guidance

Technical Excellence

  • Accessibility-first component development
  • Performance optimization patterns built-in
  • Type safety with comprehensive TypeScript patterns
  • Maintainable codebase with clear architectural guidelines

📚 Integration with Existing Patterns

These rules are designed to work seamlessly with:

🚀 Immediate Impact

Developers using Cursor IDE will now receive intelligent guidance for:

  1. Form component development following established patterns
  2. TypeScript interface design with proper conventions
  3. Radix UI + Tailwind CSS integration best practices
  4. Monorepo import/export organization

📁 File Structure

.cursor/rules/
├── storybook-testing.mdc          # Existing (PR #71)
├── form-component-patterns.mdc    # 🆕 Form integration patterns
├── react-typescript-patterns.mdc  # 🆕 Component architecture
├── ui-component-patterns.mdc      # 🆕 UI component patterns
└── monorepo-organization.mdc      # 🆕 Import/export conventions

🎨 Modern Cursor Rules Directory Pattern

Following the latest Cursor best practices:

  • .cursor/rules/ directory structure (Jan 2025 pattern)
  • MDC format with proper metadata (type: Always)
  • Focused and actionable guidance under 500 lines each
  • Concrete examples and verification steps
  • Version-controlled and team-shareable

This comprehensive set of cursor rules will significantly enhance the development experience and ensure consistent, high-quality code across the entire lambda-curry/forms component library! 🎯


Summary of Changes:


💻 View my workAbout Codegen

- Add form-component-patterns.mdc: Remix Hook Form + Zod integration patterns
- Add react-typescript-patterns.mdc: Component architecture and TypeScript best practices
- Add ui-component-patterns.mdc: Radix UI + Tailwind CSS + CVA patterns
- Add monorepo-organization.mdc: Import conventions and package structure

These rules complement the existing Storybook testing rules and provide
comprehensive guidance for consistent development patterns across the
lambda-curry/forms component library.
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 24, 2025

📝 Storybook Preview: View Storybook

This preview will be updated automatically when you push new changes to this PR.

Note: The preview will be available after the workflow completes and the PR is approved for deployment.

…ctices

- Update react-typescript-patterns.mdc: Remove forwardRef patterns, add React 19 ref handling, use() hook for async operations, and ref cleanup functions
- Update ui-component-patterns.mdc: Add Tailwind 4 features (CSS custom properties, container queries, modern CSS functions), ShadCN UI component architecture, and performance optimizations

These updates ensure the cursor rules reflect the latest best practices for React 19, Tailwind CSS 4, and ShadCN UI patterns.
Comment thread .cursor/rules/ui-component-patterns.mdc Outdated
Comment on lines +150 to +217
// Framer Motion integration
import { motion } from 'framer-motion';

const MotionCard = motion.div;

const cardAnimation = {
initial: { opacity: 0, y: 20 },
animate: { opacity: 1, y: 0 },
exit: { opacity: 0, y: -20 },
transition: { duration: 0.2 },
};
```

## Accessibility Patterns
```typescript
// ARIA patterns
const Button = ({ children, ...props }: ButtonProps) => (
<button
type="button"
role="button"
aria-pressed={pressed}
aria-expanded={expanded}
aria-describedby={describedBy}
{...props}
>
{children}
</button>
);

// Focus management
const useFocusTrap = (isOpen: boolean) => {
const containerRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (!isOpen) return;

const container = containerRef.current;
if (!container) return;

const focusableElements = container.querySelectorAll(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);

const firstElement = focusableElements[0] as HTMLElement;
const lastElement = focusableElements[focusableElements.length - 1] as HTMLElement;

firstElement?.focus();

const handleTabKey = (e: KeyboardEvent) => {
if (e.key !== 'Tab') return;

if (e.shiftKey) {
if (document.activeElement === firstElement) {
lastElement?.focus();
e.preventDefault();
}
} else {
if (document.activeElement === lastElement) {
firstElement?.focus();
e.preventDefault();
}
}
};

container.addEventListener('keydown', handleTabKey);
return () => container.removeEventListener('keydown', handleTabKey);
}, [isOpen]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codegen-sh Let's remove this, we don't have framer-motion in the project. We also utilize shadcn components (which radix-ui). Let's make sure we're not adding to much context for things that aren't already in our repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! I'll remove the framer-motion references and ensure we're only using shadcn/radix-ui components. 🧹

💻 View my work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Perfect! I've cleaned up the cursor rules to focus specifically on your project! 🧹

🎯 Removed Unnecessary Context

What I Removed:

  • Framer Motion references - not used in your project
  • Generic ShadCN UI examples - replaced with your actual component patterns
  • Unnecessary animation libraries - focused on CSS-only animations
  • Generic component examples - replaced with your actual components

What I Focused On:

  • Your actual Radix UI components - Alert Dialog, Avatar, Checkbox, Dialog, Dropdown Menu, Label, Popover, Radio Group, Scroll Area, Separator, Slot, Switch, Tooltip
  • Your existing UI components - Badge, Button, Checkbox Field, Command, Data Table, Date Picker, Form components, OTP Input, etc.
  • Your project architecture - Based on your actual button.tsx, form.tsx, table.tsx, dropdown-menu.tsx patterns
  • Your dependencies - Tailwind CSS 4, React 19, @tanstack/react-table, lucide-react, etc.

🔧 Now Provides Focused Guidance For:

  1. Component patterns that match your existing architecture
  2. Form integration with your actual form components
  3. Data table patterns based on your @tanstack/react-table usage
  4. Radix UI integration for only the components you actually use
  5. Tailwind 4 features without unnecessary complexity

The cursor rules are now laser-focused on the lambda-curry/forms component library and will provide AI assistance that's directly relevant to your actual codebase! 🎨

🔗 Updated PR #72 - Ready for review!

💻 View my work • React 👍 or 👎

- Remove framer-motion references (not used in project)
- Focus UI patterns on actual Radix UI components in use
- Base examples on existing components (button.tsx, form.tsx, table.tsx, etc.)
- Remove generic ShadCN references, focus on lambda-curry/forms architecture
- Streamline patterns to match actual project dependencies and structure

The cursor rules now provide focused guidance only for components and patterns that exist in the lambda-curry/forms repository.
@codegen-sh codegen-sh Bot force-pushed the codegen-bot/cursor-rules-implementation-1748117239 branch from b363975 to 644f914 Compare May 26, 2025 02:22
Comment thread .cursor/rules/ui-component-patterns.mdc Outdated
};
```

## Form Component Patterns (Based on Your form.tsx)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get rid of the "## Form Component Patterns (Based on Your form.tsx)" section in this ui-component-patterns file because we already have another form-components-patterns cursor rule file.

Comment thread .cursor/rules/ui-component-patterns.mdc Outdated
export { Form, FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage };
```

## Data Table Patterns (Based on Your data-table Components)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get rid of the "## Data Table Patterns (Based on Your data-table Components)" section because it's not needed in a cursor rule

Comment thread .cursor/rules/ui-component-patterns.mdc Outdated
});
```

## Testing Integration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get rid of our testing integration section in this file because we already have a testing rule

@codegen-sh
Copy link
Copy Markdown
Contributor Author

codegen-sh Bot commented May 26, 2025

Understood! I'll update the file to remove those sections. ✂️

💻 View my work

- Remove Form Component Patterns section (already covered in form-component-patterns.mdc)
- Remove Data Table Patterns section (not needed in cursor rules)
- Remove Testing Integration section (already covered in storybook-testing.mdc)

The UI component patterns file now focuses solely on UI-specific patterns:
- Radix UI integration patterns
- Tailwind CSS 4 features
- Component architecture
- Responsive design
- Animations
- Accessibility
- Performance optimization

This eliminates duplication and keeps each cursor rule file focused on its specific domain.
@codegen-sh
Copy link
Copy Markdown
Contributor Author

codegen-sh Bot commented May 26, 2025

✅ Perfect! I've cleaned up the UI component patterns file by removing all the duplicate sections! 🧹

🗑️ Removed Duplicate Sections:

Form Component Patterns

  • Already covered in form-component-patterns.mdc
  • No need to duplicate form logic in UI patterns

Data Table Patterns

  • Not needed in cursor rules (too implementation-specific)
  • Your existing data-table components already follow good patterns

Testing Integration

  • Already covered in storybook-testing.mdc
  • Keeps testing guidance centralized

UI Component Patterns Now Focuses On:

  1. Radix UI Integration - Dropdown menu patterns based on your components
  2. Tailwind CSS 4 Features - Modern CSS custom properties, container queries
  3. Component Architecture - CVA patterns, React 19 patterns
  4. Responsive Design - Container queries and fluid typography
  5. Animations - CSS-only animation patterns
  6. Accessibility - Keyboard navigation patterns
  7. Performance - Optimized class patterns and memoization

Each cursor rule file now has a clear, focused domain with no overlap! This will give you much cleaner AI assistance that doesn't repeat guidance across different files. 🎯

🔗 Updated PR #72 - Ready for review!

💻 View my work • React 👍 or 👎

@jaruesink jaruesink marked this pull request as ready for review May 26, 2025 02:38
@jaruesink jaruesink merged commit 8a9be4a into main May 26, 2025
3 of 4 checks passed
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.

1 participant