| name | fastapi |
| description | Guides FastAPI backend implementation. Use this when working on main.py, routers, or any API endpoint. |
FastAPI Skill
Conventions
- Async-first: every endpoint and handler must be async
- Use APIRouter for grouping related endpoints
- WebSocket endpoints stream agent steps in real-time
WebSocket Message Protocol
Every agent step is streamed as a typed message:
{ "type": "think", "content": "..." }
{ "type": "act", "tool": "...", "args": {} }
{ "type": "observe", "output": "...", "target": "terminal|editor" }
{ "type": "finding", "severity": "critical|high|medium", "detail": "..." }
{ "type": "done", "summary": "..." }
Session Endpoints
POST /sessions → create new session
GET /sessions/{id} → get session state
DELETE /sessions/{id} → terminate session
WS /sessions/{id}/stream → real-time agent output
Error Handling
- Always return structured error responses
- Never expose internal stack traces
- Log all tool execution errors to workspace