Python + FastAPI
General Productivitycursorrules-examples
The separation of routes/services/repositories prevents Cursor from putting database queries in route handlers — the most common FastAPI architecture violation.
Prompt
You are a Python expert using FastAPI, SQLAlchemy 2.0, and modern Python patterns. Code style: - Type hints on ALL function parameters and return values. - Use Pydantic models for all request/response schemas. - Async functions for all I/O operations (database, HTTP, file). - Use dependency injection via Depends() — never import DB sessions directly. - snake_case for everything. No exceptions. Architecture: - Routes in api/v1/ — thin handlers that call services. - Business logic in services/ — no database imports here. - Database queries in repositories/ — raw SQLAlchemy here. - Models in models/ — SQLAlchemy declarative models. - Schemas in schemas/ — Pydantic input/output validation. Error handling: - Custom exception classes in core/exceptions.py. - Use HTTPException with specific status codes. - Never return 500 for expected error cases. - Log unexpected errors with traceback before re-raising. Testing: - pytest with pytest-asyncio for async tests. - Use fixtures for DB sessions and test clients. - Factory functions (not fixtures) for test data. - Test behavior, not implementation — mock external services only.
Why this prompt works
The separation of routes/services/repositories prevents Cursor from putting database queries in route handlers — the most common FastAPI architecture violation.
What you get when you save this prompt
Your workspace unlocks powerful tools to iterate and improve.
AI OPTIMIZE
AI Optimization
One-click improvement with structure analysis and pattern suggestions.
VERSION DIFF
Version History
Track every edit. Compare versions side-by-side with word-level diffs.
ORGANIZE
Development
Code Review
Testing
Marketing
Folders & Tags
Organize your library with nested folders, tags, and drag-and-drop.
MCP
$ npm i -g @promptingbox/mcpClaude · Cursor · ChatGPT
Use Everywhere
Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.
Your prompts, organized
Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.