TypeScript Python FastAPI React Best Practices .cursorrules prompt file
About .cursorrules prompt file
What you can build
- React Component Library: Create a component library with highly reusable and optimized React components using TypeScript, MUI for styling, and adhering to best practices for performance and accessibility.
- TypeScript Linter: Develop a linter extension for TypeScript projects, enforcing rules such as the use of interfaces over types, avoiding enums, and enabling strict mode, focusing on maintainability and best practices.
- AI Code Optimizer for TypeScript/React: Offer a tool that automatically refactors and optimizes TypeScript and React codebases, focusing on functional programming, naming conventions, file structuring, and dynamic imports.
- State Management Pattern Generator: Provide a service that generates boilerplate code with different state management techniques (useContext, Redux, Recoil) based on project needs and complexity.
- React Error Monitoring Tool: Build a service that logs and tracks errors in React applications, giving insights on user-friendly messages and early error handling integration using hooks.
- FastAPI Endpoint Template Generator: Create a web tool that generates RESTful API endpoints using FastAPI and Pydantic models, including predefined error handling and request validation mechanisms.
- Database Migration Manager: Develop an app that aids in managing database migrations automatically using SQL Model and SQLAlchemy, with a focus on async database operations.
- Async Operation Analyzer: Construct a Python library that identifies potential async operations in code and suggests when to use async/await constructs for enhanced performance.
- Frontend/Backend Testing Suite: Launch a comprehensive testing suite that helps in writing unit tests for both frontend (React) and backend (FastAPI), aiming at high test coverage and mocking utilities.
- Accessibility Checker: Offer a tool that scans React applications for accessibility issues, suggesting improvements for keyboard navigation, semantic HTML elements, and alternative text for images.
Benefits
- Emphasizes TypeScript best practices and detailed structuring guidelines for React, promoting functional components and proper syntax while ensuring responsive design and efficient state management.
- Provides comprehensive backend guidance using Python, enforcing PEP 8 style, leveraging modern capabilities such as async/await, and advocating structured API design with FastAPI and SQLModel.
- Stresses overarching development practices with a focus on documentation, error handling, and maintaining security while applying DRY principles for concise, maintainable, and efficient codebases.
Synopsis
Developers creating modern full-stack applications with TypeScript/React and Python backend can use this prompt to build a scalable, high-performance, and maintainable application using best practices in structure, syntax, and design patterns.
Overview of .cursorrules prompt
The .cursorrules file specifies guidelines and best practices for developing a frontend application using TypeScript and React, and a backend using Python. For the frontend, it emphasizes the use of functional components, responsive design with Material-UI, React hooks for state management, and TypeScript with strict typing. The file outlines naming conventions, syntax preferences, and error handling strategies to ensure code clarity and maintainability. On the backend, it prescribes Python 3.8+ features, PEP 8 adherence, use of FastAPI for API development, and SQLModel for database interactions. It provides guidance on naming conventions, error handling, API design, and testing, alongside general principles such as DRY, error logging, and security measures. Additionally, it covers version control, testing best practices, performance optimization, accessibility, and documentation requirements to maintain a high standard in software development and ensure robust, efficient, and easily maintainable code.