Last active
          September 9, 2025 17:45 
        
      - 
      
 - 
        
Save arya-oss/ccad58ba7fdb9cc2b1a152a20ba0e5e6 to your computer and use it in GitHub Desktop.  
    Cursor Rules
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| alwaysApply: true | |
| --- | |
| You are an expert in TypeScript, React Native, Expo, NativeWind and Mobile UI development. | |
| Code Style and Structure | |
| - Write concise, technical TypeScript code with accurate examples. | |
| - Use functional and declarative programming patterns; avoid classes. | |
| - Prefer iteration and modularization over code duplication. | |
| - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError). | |
| - Structure files: exported component, subcomponents, helpers, static content, types. | |
| - Follow Expo's official documentation for setting up and configuring your projects: https://docs.expo.dev/ | |
| Naming Conventions | |
| - Use lowercase with dashes for directories (e.g., components/auth-wizard). | |
| - Favor named exports for components. | |
| TypeScript Usage | |
| - Use TypeScript for all code; prefer interfaces over types. | |
| - Avoid enums; use maps instead. | |
| - Use functional components with TypeScript interfaces. | |
| - Use strict mode in TypeScript for better type safety. | |
| Syntax and Formatting | |
| - Use the "function" keyword for pure functions. | |
| - Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements. | |
| - Use declarative JSX. | |
| - Use Prettier for consistent code formatting. | |
| UI and Styling | |
| - Use Expo's built-in components for common UI patterns and layouts. | |
| - Implement responsive design with Flexbox and Expo's `useWindowDimensions` for screen size adjustments. | |
| - Use Tailwind CSS for component styling. | |
| - Implement dark mode support using Expo's `useColorScheme`. | |
| - Leverage `react-native-reanimated` and `react-native-gesture-handler` for performant animations and gestures. | |
| Safe Area Management | |
| - Use SafeAreaProvider from react-native-safe-area-context to manage safe areas globally in your app. | |
| - Wrap top-level components with SafeAreaView to handle notches, status bars, and other screen insets on both iOS and Android. | |
| - Use SafeAreaScrollView for scrollable content to ensure it respects safe area boundaries. | |
| - Avoid hardcoding padding or margins for safe areas; rely on SafeAreaView and context hooks. | |
| Performance Optimization | |
| - Minimize the use of useState and useEffect; prefer context and reducers for state management. | |
| - Use Expo's AppLoading and SplashScreen for optimized app startup experience. | |
| - Optimize images: use WebP format where supported, include size data, implement lazy loading with expo-image. | |
| - Implement code splitting and lazy loading for non-critical components with React's Suspense and dynamic imports. | |
| - Profile and monitor performance using React Native's built-in tools and Expo's debugging features. | |
| - Avoid unnecessary re-renders by memoizing components and using useMemo and useCallback hooks appropriately. | |
| Navigation | |
| - Use `expo-router` for routing and navigation; follow its best practices for stack, tab, and drawer navigators. | |
| - Leverage deep linking and universal links for better user engagement and navigation flow. | |
| - Use dynamic routes with `expo-router` for better navigation handling. | |
| State Management | |
| - Use React Context and useReducer for managing global state. | |
| - Leverage @tanstack/react-query for data fetching and caching; avoid excessive API calls. | |
| - For complex state management, consider using Zustand or Redux Toolkit. | |
| - Handle URL search parameters using libraries like expo-linking. | |
| Error Handling and Validation | |
| - Use Zod for runtime validation and error handling. | |
| - Implement proper error logging using Sentry or a similar service. | |
| - Prioritize error handling and edge cases: | |
| - Handle errors at the beginning of functions. | |
| - Use early returns for error conditions to avoid deeply nested if statements. | |
| - Avoid unnecessary else statements; use if-return pattern instead. | |
| - Implement global error boundaries to catch and handle unexpected errors. | |
| - Use expo-error-reporter for logging and reporting errors in production. | |
| Testing | |
| - Write unit tests using Jest and React Native Testing Library. | |
| - Implement integration tests for critical user flows using Detox. | |
| - Use Expo's testing tools for running tests in different environments. | |
| - Consider snapshot testing for components to ensure UI consistency. | |
| Security | |
| - Sanitize user inputs to prevent XSS attacks. | |
| - Use react-native-encrypted-storage for secure storage of sensitive data. | |
| - Ensure secure communication with APIs using HTTPS and proper authentication. | |
| - Use Expo's Security guidelines to protect your app: https://docs.expo.dev/guides/security/ | |
| Key Conventions | |
| 1. Rely on Expo's managed workflow for streamlined development and deployment. | |
| 2. Prioritize Mobile Web Vitals (Load Time, Jank, and Responsiveness). | |
| 3. Use expo-constants for managing environment variables and configuration. | |
| 4. Use expo-permissions to handle device permissions gracefully. | |
| 5. Implement expo-updates for over-the-air (OTA) updates. | |
| 6. Follow Expo's best practices for app deployment and publishing: https://docs.expo.dev/distribution/introduction/ | |
| 7. Ensure compatibility with iOS and Android by testing extensively on both platforms. | |
| API Documentation | |
| - Use Expo's official documentation for setting up and configuring your projects: https://docs.expo.dev/ | |
| Refer to Expo's documentation for detailed information on Views, Blueprints, and Extensions for best practices. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| description: Helpful when writing backend code with python | |
| alwaysApply: false | |
| --- | |
| You are an expert in Python, FastAPI, SQLAlchemy, Celery and scalable API development. | |
| Key Principles | |
| - Write concise, technical responses with accurate Python examples. | |
| - Use functional, declarative programming; avoid classes where possible. | |
| - Prefer iteration and modularization over code duplication. | |
| - Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission). | |
| - Use lowercase with underscores for directories and files (e.g., routers/user_routes.py). | |
| - Favor named exports for routes and utility functions. | |
| - Use the Receive an Object, Return an Object (RORO) pattern. | |
| Python/FastAPI | |
| - Use def for pure functions and async def for asynchronous operations. | |
| - Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries for input validation. | |
| - File structure: exported router, sub-routes, utilities, static content, types (models, schemas). | |
| - Avoid unnecessary curly braces in conditional statements. | |
| - For single-line statements in conditionals, omit curly braces. | |
| - Use concise, one-line syntax for simple conditional statements (e.g., if condition: do_something()). | |
| Error Handling and Validation | |
| - Prioritize error handling and edge cases: | |
| - Handle errors and edge cases at the beginning of functions. | |
| - Use early returns for error conditions to avoid deeply nested if statements. | |
| - Place the happy path last in the function for improved readability. | |
| - Avoid unnecessary else statements; use the if-return pattern instead. | |
| - Use guard clauses to handle preconditions and invalid states early. | |
| - Implement proper error logging and user-friendly error messages. | |
| - Use custom error types or error factories for consistent error handling. | |
| Dependencies | |
| - FastAPI | |
| - Pydantic v2 | |
| - Async database libraries like asyncpg or aiomysql | |
| - SQLAlchemy 2.0 (if using ORM features) | |
| FastAPI-Specific Guidelines | |
| - Use functional components (plain functions) and Pydantic models for input validation and response schemas. | |
| - Use declarative route definitions with clear return type annotations. | |
| - Use def for synchronous operations and async def for asynchronous ones. | |
| - Minimize @app.on_event("startup") and @app.on_event("shutdown"); prefer lifespan context managers for managing startup and shutdown events. | |
| - Use middleware for logging, error monitoring, and performance optimization. | |
| - Optimize for performance using async functions for I/O-bound tasks, caching strategies, and lazy loading. | |
| - Use HTTPException for expected errors and model them as specific HTTP responses. | |
| - Use middleware for handling unexpected errors, logging, and error monitoring. | |
| - Use Pydantic's BaseModel for consistent input/output validation and response schemas. | |
| Performance Optimization | |
| - Minimize blocking I/O operations; use asynchronous operations for all database calls and external API requests. | |
| - Implement caching for static and frequently accessed data using tools like Redis or in-memory stores. | |
| - Optimize data serialization and deserialization with Pydantic. | |
| - Use lazy loading techniques for large datasets and substantial API responses. | |
| Key Conventions | |
| 1. Rely on FastAPI’s dependency injection system for managing state and shared resources. | |
| 2. Prioritize API performance metrics (response time, latency, throughput). | |
| 3. Limit blocking operations in routes: | |
| - Favor asynchronous and non-blocking flows. | |
| - Use dedicated async functions for database and external API operations. | |
| - Structure routes and dependencies clearly to optimize readability and maintainability. | |
| Refer to FastAPI documentation for Data Models, Path Operations, and Middleware for best practices. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| description: Helpful when writing frontend code with typescript | |
| alwaysApply: false | |
| --- | |
| This comprehensive guide outlines best practices, conventions, and standards for development with modern web technologies including ReactJS, React Router DOM, Zustand, TypeScript, TailwindCSS, HTML, CSS, and UI frameworks. | |
| Development Philosophy | |
| - Write clean, maintainable, and scalable code | |
| - Follow SOLID principles | |
| - Prefer functional and declarative programming patterns over imperative | |
| - Emphasize type safety and static analysis | |
| - Practice component-driven development | |
| Code Implementation Guidelines | |
| Planning Phase | |
| - Begin with step-by-step planning | |
| - Write detailed pseudocode before implementation | |
| - Document component architecture and data flow | |
| - Consider edge cases and error scenarios | |
| Code Style | |
| - Use tabs for indentation | |
| - Use single quotes for strings (except to avoid escaping) | |
| - Omit semicolons (unless required for disambiguation) | |
| - Eliminate unused variables | |
| - Add space after keywords | |
| - Add space before function declaration parentheses | |
| - Always use strict equality (===) instead of loose equality (==) | |
| - Space infix operators | |
| - Add space after commas | |
| - Keep else statements on the same line as closing curly braces | |
| - Use curly braces for multi-line if statements | |
| - Always handle error parameters in callbacks | |
| - Limit line length to 80 characters | |
| - Use trailing commas in multiline object/array literals | |
| Naming Conventions | |
| General Rules | |
| - Use PascalCase for: | |
| - Components | |
| - Type definitions | |
| - Interfaces | |
| - Use kebab-case for: | |
| - Directory names (e.g., components/auth-wizard) | |
| - File names (e.g., user-profile.tsx) | |
| - Use camelCase for: | |
| - Variables | |
| - Functions | |
| - Methods | |
| - Hooks | |
| - Properties | |
| - Props | |
| - Use UPPERCASE for: | |
| - Environment variables | |
| - Constants | |
| - Global configurations | |
| Specific Naming Patterns | |
| - Prefix event handlers with 'handle': handleClick, handleSubmit | |
| - Prefix boolean variables with verbs: isLoading, hasError, canSubmit | |
| - Prefix custom hooks with 'use': useAuth, useForm | |
| - Use complete words over abbreviations except for: | |
| - err (error) | |
| - req (request) | |
| - res (response) | |
| - props (properties) | |
| - ref (reference) | |
| React Best Practices | |
| Component Architecture | |
| - Use functional components with TypeScript interfaces | |
| - Define components using the function keyword | |
| - Extract reusable logic into custom hooks | |
| - Implement proper component composition | |
| - Use React.memo() strategically for performance | |
| - Implement proper cleanup in useEffect hooks | |
| React Performance Optimization | |
| - Use useCallback for memoizing callback functions | |
| - Implement useMemo for expensive computations | |
| - Avoid inline function definitions in JSX | |
| - Implement code splitting using dynamic imports | |
| - Implement proper key props in lists (avoid using index as key) | |
| React Router DOM Best Practices | |
| Core Concepts | |
| - Utilize React Router DOM for routing | |
| - Implement proper metadata management using React Helmet | |
| - Implement proper error boundaries | |
| TypeScript Implementation | |
| - Enable strict mode | |
| - Define clear interfaces for component props, state, and Redux state structure. | |
| - Use type guards to handle potential undefined or null values safely. | |
| - Apply generics to functions, actions, and slices where type flexibility is needed. | |
| - Utilize TypeScript utility types (Partial, Pick, Omit) for cleaner and reusable code. | |
| - Prefer interface over type for defining object structures, especially when extending. | |
| - Use mapped types for creating variations of existing types dynamically. | |
| UI and Styling | |
| Component Libraries | |
| - Use shadcn/ui for consistent, accessible component design. | |
| - Integrate Radix UI primitives for customizable, accessible UI elements. | |
| - Apply composition patterns to create modular, reusable components. | |
| Styling Guidelines | |
| - Use Tailwind CSS for utility-first, maintainable styling. | |
| - Design with mobile-first, responsive principles for flexibility across devices. | |
| - Implement dark mode using CSS variables or Tailwind’s dark mode features. | |
| - Ensure color contrast ratios meet accessibility standards for readability. | |
| - Maintain consistent spacing values to establish visual harmony. | |
| - Define CSS variables for theme colors and spacing to support easy theming and maintainability. | |
| State Management | |
| Local State | |
| - Use useState for component-level state | |
| - Implement useReducer for complex state | |
| - Use useContext for shared state | |
| - Implement proper state initialization | |
| Global State | |
| - Use `zustand` for global state management | |
| Error Handling and Validation | |
| Form Validation | |
| - Use `zod` for schema validation | |
| - Implement proper error messages | |
| - Use `react-hook-form` for form handling | |
| Error Boundaries | |
| - Use error boundaries to catch and handle errors in React component trees gracefully. | |
| - Log caught errors to an external service (e.g., Sentry) for tracking and debugging. | |
| - Design user-friendly fallback UIs to display when errors occur, keeping users informed without breaking the app. | |
| Testing | |
| Unit Testing | |
| - Write thorough unit tests to validate individual functions and components. | |
| - Use Jest and React Testing Library for reliable and efficient testing of React components. | |
| - Follow patterns like Arrange-Act-Assert to ensure clarity and consistency in tests. | |
| - Mock external dependencies and API calls to isolate unit tests. | |
| Integration Testing | |
| - Focus on user workflows to ensure app functionality. | |
| - Set up and tear down test environments properly to maintain test independence. | |
| - Use snapshot testing selectively to catch unintended UI changes without over-relying on it. | |
| - Leverage testing utilities (e.g., screen in RTL) for cleaner and more readable tests. | |
| Accessibility (a11y) | |
| Core Requirements | |
| - Use semantic HTML for meaningful structure. | |
| - Apply accurate ARIA attributes where needed. | |
| - Ensure full keyboard navigation support. | |
| - Manage focus order and visibility effectively. | |
| - Maintain accessible color contrast ratios. | |
| - Follow a logical heading hierarchy. | |
| - Make all interactive elements accessible. | |
| - Provide clear and accessible error feedback. | |
| Security | |
| - Implement input sanitization to prevent XSS attacks. | |
| - Use DOMPurify for sanitizing HTML content. | |
| - Use proper authentication methods. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| alwaysApply: true | |
| --- | |
| You are an expert in Java programming, Spring Boot, Spring Security, Gradle, JUnit, and related Java technologies. | |
| Code Style and Structure | |
| - Write clean, efficient, and well-documented Java code with accurate Spring Boot examples. | |
| - Use Spring Boot best practices and conventions throughout your code. | |
| - Implement RESTful API design patterns when creating web services. | |
| - Use descriptive method and variable names following camelCase convention. | |
| - Structure Spring Boot applications: controllers, services, repositories, models, configurations. | |
| Spring Boot Specifics | |
| - Use Spring Boot starters for quick project setup and dependency management. | |
| - Implement proper use of annotations (e.g., @SpringBootApplication, @RestController, @Service). | |
| - Utilize Spring Boot's auto-configuration features effectively. | |
| - Implement proper exception handling using @ControllerAdvice and @ExceptionHandler. | |
| Naming Conventions | |
| - Use PascalCase for class names (e.g., UserController, OrderService). | |
| - Use camelCase for method and variable names (e.g., findUserById, isOrderValid). | |
| - Use ALL_CAPS for constants (e.g., MAX_RETRY_ATTEMPTS, DEFAULT_PAGE_SIZE). | |
| Java and Spring Boot Usage | |
| - Use Java 17 or later features when applicable (e.g., records, sealed classes, pattern matching). | |
| - Leverage Spring Boot 3.x features and best practices. | |
| - Use Spring Data JPA for database operations when applicable. | |
| - Implement proper validation using Bean Validation (e.g., @Valid, custom validators). | |
| Configuration and Properties | |
| - Use application.properties or application.yml for configuration. | |
| - Implement environment-specific configurations using Spring Profiles. | |
| - Use @ConfigurationProperties for type-safe configuration properties. | |
| Dependency Injection and IoC | |
| - Use constructor injection over field injection for better testability. | |
| - Leverage Spring's IoC container for managing bean lifecycles. | |
| Testing | |
| - Write unit tests using JUnit 5 and Spring Boot Test. | |
| - Use MockMvc for testing web layers. | |
| - Implement integration tests using @SpringBootTest. | |
| - Use @DataJpaTest for repository layer tests. | |
| Performance and Scalability | |
| - Implement caching strategies using Spring Cache abstraction. | |
| - Use async processing with @Async for non-blocking operations. | |
| - Implement proper database indexing and query optimization. | |
| Security | |
| - Implement Spring Security for authentication and authorization. | |
| - Use proper password encoding (e.g., BCrypt). | |
| - Implement CORS configuration when necessary. | |
| Logging and Monitoring | |
| - Use SLF4J with Logback for logging. | |
| - Implement proper log levels (ERROR, WARN, INFO, DEBUG). | |
| - Use Spring Boot Actuator for application monitoring and metrics. | |
| API Documentation | |
| - Use Springdoc OpenAPI (formerly Swagger) for API documentation. | |
| Data Access and ORM | |
| - Use Spring Data JPA for database operations. | |
| - Implement proper entity relationships and cascading. | |
| - Use database migrations with tools like Flyway or Liquibase. | |
| Build and Deployment | |
| - Use Gradle for dependency management and build processes. | |
| - Implement proper profiles for different environments (dev, test, prod). | |
| - Use Docker for containerization if applicable. | |
| Follow best practices for: | |
| - RESTful API design (proper use of HTTP methods, status codes, etc.). | |
| - Microservices architecture (if applicable). | |
| - Asynchronous processing using Spring's @Async or reactive programming with Spring WebFlux. | |
| Adhere to SOLID principles and maintain high cohesion and low coupling in your Spring Boot application design. | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment