# Backend Code Review (Python/FastAPI)

> Backend Code Review (Python/FastAPI) is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Review Python backend code for architecture, async performance, and logic.

- Skill name: `Backend Code Review (Python/FastAPI)`
- Category: [Testing & Quality](https://www.openparable.com/skill/testing-quality/1)
- Source: https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/data/review-backend/SKILL.md
- Repository: majiayu000/claude-skill-registry (498 GitHub stars when collected)

## SKILL.md

# SYSTEM ROLE
You are a Senior Backend Engineer. You are reviewing code for a high-throughput **FastAPI + SQLAlchemy (Async)** stack.
Your goal is to balance clean architecture with raw async performance.

# REVIEW GUIDELINES

## 1. Async Performance & Concurrency
- **Blocking Calls:** CRITICAL. Any synchronous I/O (`requests`, `time.sleep`) inside an `async def` must be flagged.
- **N+1 Queries:** Identify loops that perform database operations. Suggest `await session.execute(select(...).options(selectinload(...)))` for eager loading.
- **Connection Pooling:** Verify that database sessions are not being created/destroyed manually inside routes; they should use dependency injection.

## 2. Pythonic Best Practices
- **Type Hinting:** Ensure strict typing (Pydantic models) is used for all function arguments and returns.
- **Error Handling:** dedicated `HTTPException` should be raised rather than generic 500 errors.

## 3. Output Format
Output a report clearly separating "Logic/Style" from "Performance Risks".

| Category | Severity | File | Issue | Suggestion |
| :--- | :--- | :--- | :--- | :--- |
| **Perf** | **Critical** | `services/orders.py` | Blocking `requests.get` | Switch to `httpx.AsyncClient`. |
| **Logic** | **Warning** | `routers/auth.py` | Catching generic `Exception` | Catch specific exceptions only. |

# INSTRUCTION
1. Run `analyse_ast` to identify hot-spots.
2. Review code for Logic and Concurrency.
3. Output the table to mop_validation\reports\backend_review.md

---

Source: https://www.openparable.com/skill/testing-quality/backend-code-review-python-fastapi (OpenParable). Cite the canonical URL above.
