| name | code-review |
| description | Perform thorough code reviews of this FastAPI template — correctness, security, performance, and maintainability, plus adherence to project conventions. Use when user asks to review code, check for bugs, audit a codebase, or before committing changes.
|
Review code against the checklists below. Flag violations with file:line, state the
concrete failure scenario (not just "this is bad practice"), and suggest the fix.
Project-specific checks come first — they catch the mistakes this codebase actually
makes; the general checklist catches everything else.
Architecture Review
Project Security Review
Error Handling Review
Data Flow Review
Logging Review
Resilience Review (this codebase's most common latent bug)
Testing Review
General Review Checklist
Security
Correctness
Performance
Maintainability
Common Mistakes to Flag
- Service returning raw model: Must convert to Pydantic response schema
- Route importing DB session: Should use service dependency instead
- Service/repository raising
HTTPException: Should raise an AppException subclass, let the registered handler map it to an HTTP status
- Password/token in logs: verify sensitive field names actually match the logger's redaction keywords
- Missing
await on async calls
- Sync SQLAlchemy imports: must use
sqlalchemy.ext.asyncio.AsyncSession, never sync Session
- No
from_attributes=True on response schemas: without it, model_validate(orm_obj) fails
- Business logic in route: extract to a service method
- Blocking external call with no timeout on a request path (see Resilience Review above)
- Mutable default argument:
def f(x, lst=[]): shares state across calls — use None and default inside
Useful commands
git diff HEAD~5 --stat
git log --oneline -10
grep -rn "TODO\|FIXME\|HACK\|XXX" app/
grep -rn "password\|secret\|token" app/ --include="*.py"
uv run pip-audit
uv run radon cc app -a -nb
uv run pytest -q --timeout=30
Review Output Format
## Code Review: [file/component name]
### Summary
[1-2 sentence overview]
### Critical Issues
1. **[Issue]** (file:line): [Description]
- Impact: [concrete failure scenario — inputs/state that trigger it]
- Fix: [suggested solution]
### Improvements
1. **[Suggestion]** (file:line): [Description]
### Positive Notes
- [What was done well]
### Verdict
[ ] Ready to merge
[ ] Needs minor changes
[ ] Needs major revision