From powerups
Use when building or refactoring FastAPI endpoints. Ensures endpoints have proper docstrings, response models, and request models so auto-generated docs (Swagger/ReDoc) are the single source of truth — no separate API reference file to maintain.
How this skill is triggered — by the user, by Claude, or both
Slash command
/powerups:self-documenting-apisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
FastAPI auto-generates OpenAPI docs at `/docs` (Swagger UI) and `/redoc` (ReDoc). When endpoints have proper docstrings and typed models, these docs are comprehensive enough to replace any hand-written API reference. The goal: **never maintain a separate api-reference.md** — the code IS the documentation.
FastAPI auto-generates OpenAPI docs at /docs (Swagger UI) and /redoc (ReDoc). When endpoints have proper docstrings and typed models, these docs are comprehensive enough to replace any hand-written API reference. The goal: never maintain a separate api-reference.md — the code IS the documentation.
Apply this skill when:
Skip when:
The docstring becomes the endpoint description in Swagger UI. Write it for the developer consuming your API.
@router.post("/v1/connections/oauth")
async def create_oauth_session(
body: OAuthSessionRequest,
developer: CurrentDeveloper,
):
"""Start OAuth flow for an end user.
Creates a Nango Connect Session and returns a URL to redirect the end user to.
The end user completes OAuth in their browser, then call POST /v1/connections/confirm.
"""
Rules:
Never return raw dicts. Define a Pydantic model so the response schema appears in docs.
# Bad — docs show no response schema
@router.get("/v1/connections/{id}")
async def get_connection(...):
return {"id": conn.id, "status": conn.status}
# Good — docs show full response schema with field descriptions
class ConnectionResponse(BaseModel):
id: str
end_user_id: str
provider: str
status: str = Field(description="Connection status: active, error, deleting")
created_at: datetime
@router.get("/v1/connections/{id}", response_model=ConnectionResponse)
async def get_connection(...) -> ConnectionResponse:
...
Key points:
response_model= on the decorator so FastAPI validates AND documents the responseField(description=...) for non-obvious fieldsresponse_model=list[ConnectionResponse]class SyncRequest(BaseModel):
connection_id: str = Field(description="UUID of the connection to sync")
resources: list[str] = Field(
description="Resources to sync (e.g., ['tickets', 'articles'])"
)
Use Field for:
ge=1, le=1000)Declare non-200 status codes so they appear in docs:
@router.post(
"/v1/syncs/{id}/trigger",
status_code=202,
responses={409: {"description": "Sync already running"}},
)
async def trigger_sync(...):
"""Trigger a sync run in the background."""
Group related endpoints with tags so Swagger UI organizes them into sections:
router = APIRouter(tags=["Connections"])
This replaces the need for section headers in a manual API reference.
For list endpoints, use a consistent wrapper:
class PaginatedResponse(BaseModel, Generic[T]):
items: list[T]
total: int
limit: int
offset: int
This documents the pagination contract once, consistently.
After creating or modifying endpoints, check the auto-docs:
/docs (Swagger UI) or /redocIf a consumer can't understand the endpoint from /docs alone, the docstring or model is missing something.
1. Docstring — what it does, context, side effects
2. Response — Pydantic model with Field(description=...)
3. Request — Pydantic model with Field(description=...)
4. Status — response_model=, status_code=, responses={}
5. Tags — APIRouter(tags=["Section"])
6. Verify — check /docs after changes
| Don't | Do |
|---|---|
| Return raw dicts | Define a response model |
| Write a separate api-reference.md | Let FastAPI generate docs from code |
| Document fields in the docstring | Use Field(description=...) on the model |
| Skip the docstring ("it's obvious") | Write it — /docs is your public contract |
Use Any or dict as response type | Define a typed model, even for simple responses |
| Maintain two sources of truth | Code is the docs — update the code, docs update automatically |
npx claudepluginhub jackyliang/powerups --plugin powerupsAudits FastAPI/REST API endpoints for documentation completeness and enhances docstrings, Pydantic models, response codes, and OpenAPI specs with realistic examples.
Generates developer-friendly API documentation from code, including endpoints, parameters, examples, and best practices. Supports REST, GraphQL, and WebSocket APIs.
Generates API documentation from code: endpoints, parameters, request/response examples, auth, errors, OpenAPI specs, and Postman collections for REST/GraphQL/WebSocket APIs.