python-fastapilisted
Install: claude install-skill kouroshez/coding-os
REQUIRED BACKGROUND: You MUST also follow the clean-code skill (`.claude/skills/clean-code/SKILL.md`). That skill covers universal principles (fail-closed errors, typed exceptions, self-documenting code, edge cases, error path tests). This skill adds FastAPI-specific patterns on top of those foundations.
## Pre-Code Checklist
Before writing any backend Python code, verify:
- [ ] Read `docs/engineering/fastapi-rules.md` — the canonical backend policy
- [ ] If touching API routes: read `docs/playbooks/fastapi-service.md`
- [ ] Search the repo with Grep/Glob for existing code before creating any new file
- [ ] Confirm which Python version the project targets (≥ 3.11 recommended)
## 1. Project layout
```
src/backend/
├── app/
│ ├── main.py # FastAPI() entry point
│ ├── api/ # route modules, one file per resource
│ │ └── v1/
│ ├── models/ # SQLAlchemy declarative models
│ ├── schemas/ # Pydantic request/response schemas
│ ├── services/ # business logic — pure, no Request/Response types
│ ├── deps.py # dependency providers (DB session, current user)
│ └── core/
│ ├── config.py # Pydantic Settings
│ └── exceptions.py # typed domain errors
└── tests/
```
## 2. Route pattern
```python
@router.post("/items", response_model=ItemOut, status_code=201)
async def create_item(
payload: ItemIn,
session: AsyncSession = Depends(get_session),
current_user: User