FastAPI best practices and patterns for building modern Python web APIs
Add this skill
npx mdskills install PatrickJS/cursor-fastapiVague checklist lacking specific instructions, examples, or actionable guidance for agents
1---2description: FastAPI best practices and patterns for building modern Python web APIs3globs: **/*.py, app/**/*.py, api/**/*.py4---56# FastAPI Best Practices78## Project Structure9- Use proper directory structure10- Implement proper module organization11- Use proper dependency injection12- Keep routes organized by domain13- Implement proper middleware14- Use proper configuration management1516## API Design17- Use proper HTTP methods18- Implement proper status codes19- Use proper request/response models20- Implement proper validation21- Use proper error handling22- Document APIs with OpenAPI2324## Models25- Use Pydantic models26- Implement proper validation27- Use proper type hints28- Keep models organized29- Use proper inheritance30- Implement proper serialization3132## Database33- Use proper ORM (SQLAlchemy)34- Implement proper migrations35- Use proper connection pooling36- Implement proper transactions37- Use proper query optimization38- Handle database errors properly3940## Authentication41- Implement proper JWT authentication42- Use proper password hashing43- Implement proper role-based access44- Use proper session management45- Implement proper OAuth246- Handle authentication errors properly4748## Security49- Implement proper CORS50- Use proper rate limiting51- Implement proper input validation52- Use proper security headers53- Handle security errors properly54- Implement proper logging5556## Performance57- Use proper caching58- Implement proper async operations59- Use proper background tasks60- Implement proper connection pooling61- Use proper query optimization62- Monitor performance metrics6364## Testing65- Write proper unit tests66- Implement proper integration tests67- Use proper test fixtures68- Implement proper mocking69- Test error scenarios70- Use proper test coverage7172## Deployment73- Use proper Docker configuration74- Implement proper CI/CD75- Use proper environment variables76- Implement proper logging77- Use proper monitoring78- Handle deployment errors properly7980## Documentation81- Use proper docstrings82- Implement proper API documentation83- Use proper type hints84- Keep documentation updated85- Document error scenarios86- Use proper versioning
Full transparency — inspect the skill content before installing.