Comprehensive code review skill for FastAPI projects...
Perform comprehensive code reviews of FastAPI projects against industry best practices, identifying violations and generating actionable refactor plans.
Before reviewing, collect information about the project:
- Project structure (list_dir on root and key directories)
- Main application entry point (typically main.py or app.py)
- Router definitions and API endpoints
- Pydantic models/schemas
- Database models and connections
- Dependencies and middleware
- Configuration management
- Test files
Evaluate each category against the best practices in references/best-practices.md.
Review Categories:
For each violation found, document:
## Refactor Plan
### Critical Issues (Fix Immediately)
| Issue | Location | Best Practice Violated | Refactor Action |
|-------|----------|------------------------|-----------------|
| ... | ... | ... | ... |
### High Priority (Fix Soon)
| Issue | Location | Best Practice Violated | Refactor Action |
|-------|----------|------------------------|-----------------|
| ... | ... | ... | ... |
### Medium Priority (Plan for Refactor)
| Issue | Location | Best Practice Violated | Refactor Action |
|-------|----------|------------------------|-----------------|
| ... | ... | ... | ... |
### Low Priority (Nice to Have)
| Issue | Location | Best Practice Violated | Refactor Action |
|-------|----------|------------------------|-----------------|
| ... | ... | ... | ... |
time.sleep() in async routes → Use asyncio.sleep() or make route synchttpx.AsyncClientSELECT * queries → Select only needed columnsGenerate a comprehensive review report:
# FastAPI Code Review Report
## Executive Summary
- **Project**: [name]
- **Review Date**: [date]
- **Overall Health**: [Critical/Needs Work/Good/Excellent]
- **Total Issues Found**: [count]
## Metrics
| Category | Status | Issues |
|----------|--------|--------|
| Project Structure | ✅/⚠️/❌ | X |
| Async Patterns | ✅/⚠️/❌ | X |
| Pydantic Usage | ✅/⚠️/❌ | X |
| Dependencies | ✅/⚠️/❌ | X |
| API Design | ✅/⚠️/❌ | X |
| Database | ✅/⚠️/❌ | X |
| Testing | ✅/⚠️/❌ | X |
| Configuration | ✅/⚠️/❌ | X |
| Performance | ✅/⚠️/❌ | X |
| Documentation | ✅/⚠️/❌ | X |
## Detailed Findings
[Per-category breakdown with code examples]
## Refactor Plan
[Prioritized action items]
## Recommendations
[Strategic improvements beyond immediate fixes]
For detailed best practices and code examples, see references/best-practices.md.