Rule
0 installs · 0 said it worked
FastAPI best-practices rules for building Python web APIs
Cursor rules file guiding the assistant to follow FastAPI best practices across project structure, API design, Pydantic models, database, auth, security, performance, testing, deployment, and documentation.
People use this for
- fastapi best practices prompt
- cursor rules python api
- fastapi project structure guide
- write fastapi endpoints with pydantic models
- help me set up fastapi auth and security
- Name
fastapi-best-practices-rules-for-building-python-web-apis- Works with
- Cursor
- License
- CC0(as observed at the source)
- Version
- v1 · updated Nov 29, 2026
Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.
Are you the author?Claim this profileRequest removal
Use this rule
$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/fastapi-best-practices-rules-for-building-python-web-apis-ssa8/export/mdc" -o .cursor/rules/fastapi-best-practices-rules-for-building-python-web-apis.mdcThen open a new session; Cursor picks it up from .cursor/rules/.
Manual install
Save fastapi-best-practices-rules-for-building-python-web-apis.mdc as .cursor/rules/fastapi-best-practices-rules-for-building-python-web-apis.mdc for this project or ~/.cursor/rules/fastapi-best-practices-rules-for-building-python-web-apis.mdc for every project, then start a new session.
Rule
description: "FastAPI best practices and patterns for building modern Python web APIs" globs: /*.py, app//.py, api/**/.py alwaysApply: false
FastAPI Best Practices
Project Structure
- Use proper directory structure
- Implement proper module organization
- Use proper dependency injection
- Keep routes organized by domain
- Implement proper middleware
- Use proper configuration management
API Design
- Use proper HTTP methods
- Implement proper status codes
- Use proper request/response models
- Implement proper validation
- Use proper error handling
- Document APIs with OpenAPI
Models
- Use Pydantic models
- Implement proper validation
- Use proper type hints
- Keep models organized
- Use proper inheritance
- Implement proper serialization
Database
- Use proper ORM (SQLAlchemy)
- Implement proper migrations
- Use proper connection pooling
- Implement proper transactions
- Use proper query optimization
- Handle database errors properly
Authentication
- Implement proper JWT authentication
- Use proper password hashing
- Implement proper role-based access
- Use proper session management
- Implement proper OAuth2
- Handle authentication errors properly
Security
- Implement proper CORS
- Use proper rate limiting
- Implement proper input validation
- Use proper security headers
- Handle security errors properly
- Implement proper logging
Performance
- Use proper caching
- Implement proper async operations
- Use proper background tasks
- Implement proper connection pooling
- Use proper query optimization
- Monitor performance metrics
Testing
- Write proper unit tests
- Implement proper integration tests
- Use proper test fixtures
- Implement proper mocking
- Test error scenarios
- Use proper test coverage
Deployment
- Use proper Docker configuration
- Implement proper CI/CD
- Use proper environment variables
- Implement proper logging
- Use proper monitoring
- Handle deployment errors properly
Documentation
- Use proper docstrings
- Implement proper API documentation
- Use proper type hints
- Keep documentation updated
- Document error scenarios
- Use proper versioning
No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.
Tried it
Reports from people who added this rule to their editor. They roll up into the badges above.
No one has filed a report yet. Try the prompt and be the first.
Related rules
- Claude api: reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming,…
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any fo
Coding · @anthropic
- Autonomous coding agent that builds a verified app-builder harness
Master system prompt that directs an autonomous senior Python engineer to build a spec-driven, evidence-traced app-builder harness milestone by milestone without asking questions.
Coding · @mahfuzahmedog
- Quality engineering agent role for risk-based test strategy and CI quality gates
A senior quality engineering role prompt that guides an assistant through risk-based test strategy, test automation architecture, CI/CD quality gates, edge-case analysis, and defect management, writing results to a TODO checklist file.
Coding · @wkaandemir
- Build a native macOS music app with synced lyrics and cinematic modes
A phased engineering brief for a SwiftUI/AppKit macOS app called MusicLock, with the output being a phase-gated plan and implementation guidance across architecture, media integration, and distribution.
Coding · @nithish6111
- Scaffold a full production-ready project repository from a brief
A system-style prompt that makes the model act as an elite software engineer and product architect, filling a project brief to generate a complete, runnable repository with file tree, source files, setup commands, and an upgrade roadmap.
Coding · @handkllcservices
License: CC0v1 · published Nov 29, 2026
Comments
No comments yet. If you tried this prompt, say how it went.