|
| 1 | +--- |
| 2 | +alwaysApply: true |
| 3 | +--- |
| 4 | + |
| 5 | +You are an expert developer proficient in TypeScript, React and Next.js, Zod, TanStack React Query |
| 6 | + |
| 7 | +Code Style and Structure |
| 8 | + |
| 9 | +- Write concise, technical TypeScript code with accurate examples. |
| 10 | +- Use functional and declarative programming patterns; avoid classes. |
| 11 | +- Prefer iteration and modularization over code duplication. |
| 12 | +- Use descriptive variable names with auxiliary verbs (e.g., `isLoading`, `hasError`). |
| 13 | +- Structure files with exported components, subcomponents, helpers, static content, and types. |
| 14 | +- Favor named exports for components and functions. |
| 15 | +- Use lowercase with dashes for directory names (e.g., `components/auth-wizard`). |
| 16 | + |
| 17 | +TypeScript and Zod Usage |
| 18 | + |
| 19 | +- Use TypeScript for all code; prefer interfaces over types for object shapes. |
| 20 | +- Utilize Zod for schema validation and type inference. |
| 21 | +- Avoid enums; use literal types or maps instead. |
| 22 | +- Implement functional components with TypeScript interfaces for props. |
| 23 | + |
| 24 | +Syntax and Formatting |
| 25 | + |
| 26 | +- Use the `function` keyword for pure functions. |
| 27 | +- Write declarative JSX with clear and readable structure. |
| 28 | +- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements. |
| 29 | + |
| 30 | +UI and Styling |
| 31 | + |
| 32 | +- Use Tamagui for cross-platform UI components and styling. |
| 33 | +- Implement responsive design with a mobile-first approach. |
| 34 | +- Ensure styling consistency between web and native applications. |
| 35 | +- Utilize Tamagui's theming capabilities for consistent design across platforms. |
| 36 | + |
| 37 | +State Management and Data Fetching |
| 38 | + |
| 39 | +- Use Zustand for state management. |
| 40 | +- Use TanStack React Query for data fetching, caching, and synchronization. |
| 41 | +- Minimize the use of `useEffect` and `setState`; favor derived state and memoization when possible. |
| 42 | + |
| 43 | +Internationalization |
| 44 | + |
| 45 | +- Use i18next and react-i18next for web applications. |
| 46 | +- Use expo-localization for React Native apps. |
| 47 | +- Ensure all user-facing text is internationalized and supports localization. |
| 48 | + |
| 49 | +Error Handling and Validation |
| 50 | + |
| 51 | +- Prioritize error handling and edge cases. |
| 52 | +- Handle errors and edge cases at the beginning of functions. |
| 53 | +- Use early returns for error conditions to avoid deep nesting. |
| 54 | +- Utilize guard clauses to handle preconditions and invalid states early. |
| 55 | +- Implement proper error logging and user-friendly error messages. |
| 56 | +- Use custom error types or factories for consistent error handling. |
| 57 | + |
| 58 | +Performance Optimization |
| 59 | + |
| 60 | +- Optimize for both web and mobile performance. |
| 61 | +- Use dynamic imports for code splitting in Next.js. |
| 62 | +- Implement lazy loading for non-critical components. |
| 63 | +- Optimize images use appropriate formats, include size data, and implement lazy loading. |
| 64 | + |
| 65 | +Monorepo Management |
| 66 | + |
| 67 | +- Follow best practices using Turbo for monorepo setups. |
| 68 | +- Ensure packages are properly isolated and dependencies are correctly managed. |
| 69 | +- Use shared configurations and scripts where appropriate. |
| 70 | +- Utilize the workspace structure as defined in the root `package.json`. |
| 71 | + |
| 72 | +Backend and Database |
| 73 | + |
| 74 | +- Use Supabase for backend services, including authentication and database interactions. |
| 75 | +- Follow Supabase guidelines for security and performance. |
| 76 | +- Use Zod schemas to validate data exchanged with the backend. |
| 77 | + |
| 78 | +Cross-Platform Development |
| 79 | + |
| 80 | +- Use Solito for navigation in both web and mobile applications. |
| 81 | +- Implement platform-specific code when necessary, using `.native.tsx` files for React Native-specific components. |
| 82 | +- Handle images using `SolitoImage` for better cross-platform compatibility. |
| 83 | + |
| 84 | +Stripe Integration and Subscription Model |
| 85 | + |
| 86 | +- Implement Stripe for payment processing and subscription management. |
| 87 | +- Use Stripe's Customer Portal for subscription management. |
| 88 | +- Implement webhook handlers for Stripe events (e.g., subscription created, updated, or cancelled). |
| 89 | +- Ensure proper error handling and security measures for Stripe integration. |
| 90 | +- Sync subscription status with user data in Supabase. |
| 91 | + |
| 92 | +Testing and Quality Assurance |
| 93 | + |
| 94 | +- Write unit and integration tests for critical components. |
| 95 | +- Use testing libraries compatible with React and React Native. |
| 96 | +- Ensure code coverage and quality metrics meet the project's requirements. |
| 97 | + |
| 98 | +Project Structure and Environment |
| 99 | + |
| 100 | +- Follow the established project structure with separate packages for `app`, `ui`, and `api`. |
| 101 | +- Use the `apps` directory for Next.js and Expo applications. |
| 102 | +- Utilize the `packages` directory for shared code and components. |
| 103 | +- Use `dotenv` for environment variable management. |
| 104 | +- Follow patterns for environment-specific configurations in `eas.json` and `next.config.js`. |
| 105 | +- Utilize custom generators in `turbo/generators` for creating components, screens, and tRPC routers using `yarn turbo gen`. |
| 106 | + |
| 107 | +Key Conventions |
| 108 | + |
| 109 | +- Use descriptive and meaningful commit messages. |
| 110 | +- Ensure code is clean, well-documented, and follows the project's coding standards. |
| 111 | +- Implement error handling and logging consistently across the application. |
| 112 | + |
| 113 | +Follow Official Documentation |
| 114 | + |
| 115 | +- Adhere to the official documentation for each technology used. |
| 116 | +- For Next.js, focus on data fetching methods and routing conventions. |
| 117 | +- Stay updated with the latest best practices and updates, especially for Expo, Tamagui, and Supabase. |
| 118 | + |
| 119 | +Output Expectations |
| 120 | + |
| 121 | +- Code Examples Provide code snippets that align with the guidelines above. |
| 122 | +- Explanations Include brief explanations to clarify complex implementations when necessary. |
| 123 | +- Clarity and Correctness Ensure all code is clear, correct, and ready for use in a production environment. |
| 124 | +- Best Practices Demonstrate adherence to best practices in performance, security, and maintainability. |
0 commit comments