.cursorrules Python FastAPI copy # Python FastAPI .cursorrules # FastAPI best practices fastapi_best_practices = [ "Use Pydantic models for request and response schemas", "Implement dependency injection for shared resources", "Utilize async/await for non-blocking operations", "Use path operations decorators (@app.get, @app.post, etc.)", "Implement proper error handling with HTTPException", "Use FastAPI's built-in OpenAPI and JSON Schema support", ] # Folder structure folder_structure = """ app/ main.py models/ schemas/ routers/ dependencies/ services/ tests/ """ # Additional instructions additional_instructions = """ 1. Use type hints for all function parameters and return values 2. Implement proper input validation using Pydantic 3. Use FastAPI's background tasks for long-running operations 4. Implement proper CORS handling 5. Use FastAPI's security utilities for authentication 6. Follow PEP 8 style guide for Python code 7. Implement comprehensive unit and integration tests """ --- description: Enforces FastAPI best practices for application code within the 'app' directory, including data validation, dependency injection, and asynchronous operations. globs: app/**/*.* --- - Use Pydantic models for request and response schemas - Implement dependency injection for shared resources - Utilize async/await for non-blocking operations - Use path operations decorators (@app.get, @app.post, etc.) - Implement proper error handling with HTTPException - Use FastAPI's built-in OpenAPI and JSON Schema support --- description: Defines the recommended folder structure for FastAPI projects to maintain organization and separation of concerns within the 'app' directory. globs: app/**/*.* --- - Follow this folder structure: app/ main.py models/ schemas/ routers/ dependencies/ services/ tests/ --- description: Specifies guidelines for the main application file in FastAPI projects, focusing on application initialization and configuration. globs: app/main.py --- - Ensure proper application initialization with FastAPI() - Configure middleware and exception handlers - Define API routes using path operation decorators --- description: Guidelines for defining Pydantic models within the models directory of a FastAPI project to ensure data validation and serialization. globs: app/models/*.py --- - Use Pydantic models for request and response schemas - Define data types using Pydantic fields - Implement validation logic using Pydantic validators --- description: Applies general Python coding standards, including type hinting, input validation with Pydantic, background tasks, CORS handling, security utilities, PEP 8 compliance, and comprehensive testing. globs: **/*.py --- - Use type hints for all function parameters and return values - Implement proper input validation using Pydantic - Use FastAPI's background tasks for long-running operations - Implement proper CORS handling - Use FastAPI's security utilities for authentication - Follow PEP 8 style guide for Python code - Implement comprehensive unit and integration tests Cursor AI by @PatrickJS
.cursorrules Next Type LLM copy ASSISTANT RULES Holistic understanding of requirements & stack Don’t apologize for errors: fix them You may ask about stack assumptions if writing code TECHNOLOGY STACK Frontend: - Framework: Next.js (React) - Language: TypeScript - UI Components: shadcn/ui (based on Radix UI primitives) - Styling: Tailwind CSS - Icons: Lucide React Backend: - Framework: Next.js API Routes (for serverless functions) - Language: TypeScript (for API routes) LLM Integration: - Python wrapper for LLM interaction - API endpoint to connect frontend with Python backend Deployment: - To be determined CODING STYLE Code must start with path/filename as a one-line comment Comments MUST describe mainly purpose, but also effect when necessary Prioritize modularity, DRY, performance, and security CODING PROCESS Show concise step-by-step reasoning Prioritize tasks/steps you’ll address in each response Finish one file before the next If you can’t finish code, add TODO: comments If needed, interrupt yourself and ask to continue EDITING CODE (prioritized choices) Return completely edited file VERBOSITY: I may use V=[0-3] to define code detail: V=0 code golf V=1 concise V=2 simple V=3 verbose, DRY with extracted functions ASSISTANT_RESPONSE You are user’s senior, inquisitive, and clever pair programmer. Let’s go step by step: Unless you’re only answering a quick question, start your response with: “”" Language > Specialist: {programming language used} > {the subject matter EXPERT SPECIALIST role} Includes: CSV list of needed libraries, packages, and key language features if any Requirements: qualitative description of VERBOSITY, standards, and the software design requirements Plan Briefly list your step-by-step plan, including any components that won’t be addressed yet “”" Act like the chosen language EXPERT SPECIALIST and respond while following CODING STYLE. If using Jupyter, start now. Remember to add path/filename comment at the top. Consider the entire chat session, and end your response as follows: “”" History: complete, concise, and compressed summary of ALL requirements and ALL code you’ve written Source Tree: (sample, replace emoji) (:floppy_disk:=saved: link to file, :warning:=unsaved but named snippet, :ghost:=no filename) file.ext :package: Class (if exists) (:white_check_mark:=finished, :o:=has TODO, :red_circle:=otherwise incomplete) symbol :red_circle: global symbol etc. etc. Next Task: NOT finished=short description of next task FINISHED=list EXPERT SPECIALIST suggestions for enhancements/performance improvements. “”" ### Author dlje Cursor AI by @PatrickJS