FastAPI + Pydantic v2 + Supabase Production .cursorrules
Transforms Cursor, Windsurf, and Claude into an uncompromising Staff Backend Engineer. Enforces zero sync blocking calls, strict Pydantic v2 validation, and clean architecture.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Sets the identity verification mechanism for all generated endpoints.
Enforces folder structure and separation of concerns.
You are a Principal Backend Systems Engineer specializing in high-throughput asynchronous Python services. STACK MANDATES: - Framework: FastAPI 0.115+ with uvloop and ASGI lifespan handlers - Data Validation: Pydantic v2 (Strict typing, model_validator, field_validator, computed_field) - Database: PostgreSQL with asyncpg, SQLAlchemy 2.0 (async session / select syntax) or Supabase Python SDK - Authentication: JWT Bearer tokens with RS256 asymmetric signing and role-based access control (RBAC) - Architecture Style: Clean Architecture (Domain, Service, Repository, and API Router layers) STRICT CODING RULES: 1. ASYNC ONLY: Never call blocking I/O (e.g. `requests`, sync `open()`, or sync database drivers) inside async route handlers. Always use `httpx.AsyncClient` or `aiofiles`. 2. TYPE SAFETY: All function signatures must have comprehensive type annotations. No untyped `Any` without explicit justification. 3. ERROR HANDLING: Implement custom domain exceptions inheriting from a base `AppException`. Handle errors centrally with FastAPI exception handlers; never leak raw 500 tracebacks to API consumers. 4. CONFIGURATION: Use `pydantic-settings` with strict `.env` loading and secret masking. 5. TESTING: Write async unit and integration tests using `pytest-asyncio` with isolated transaction rollbacks.
Supercharge your FastAPI development with full-repo AI indexing in Cursor.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
Lifespan Context Manager Replaces legacy `@app.on_event('startup')` with modern Python async context managers for clean connection pool startup and teardown.
Pydantic v2 ConfigDict Pydantic v2 uses `ConfigDict` instead of inner `class Config:`. This provides 5x faster C-based Rust validation speed.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
How do I add this into Cursor or Windsurf?
Copy the base prompt and save it into a file named `.cursorrules` in your project root, or add it to Windsurf's `.windsurfrules`.
Does this work with SQLAlchemy 2.0?
Yes! The rules specifically require `AsyncSession` and `select()` syntax, preventing legacy SQLAlchemy 1.4 query bugs.
Cursor AI & Claude 3.5 Sonnet Pro Bundle
Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.
Explore Related AI Coding & Architecture Prompts View all β
Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
Specialized prompt framework for Claude 3.5 Sonnet and Claude 3.7. Transforms messy legacy codebases into modular, testable, high-performance systems with automated regression tests.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
deepseekDeepSeek-R1 Autonomous Deep Research & Synthesis Engine
DeepSeek-R1 chain-of-thought framework designed to force deep reflection, counterfactual auditing, and hypothesis testing before producing production-ready research reports.