From sentry-skills
Documents and types Sentry API endpoints with drf-spectacular: adds @extend_schema decorators, TypedDict responses, corrects type drift, and validates OpenAPI specs.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sentry-skills:document-api-endpointThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Add or fix OpenAPI docs for a Sentry endpoint with drf-spectacular. Full reference is at https://develop.sentry.dev/backend/api/public/, the most useful section to you will be https://develop.sentry.dev/backend/api/public/#5-method-decorator. This skill captures the non-obvious lessons on top of it. Most of the work is making the declared schema match what the endpoint actually returns. Before ...
Add or fix OpenAPI docs for a Sentry endpoint with drf-spectacular. Full reference is at https://develop.sentry.dev/backend/api/public/, the most useful section to you will be https://develop.sentry.dev/backend/api/public/#5-method-decorator. This skill captures the non-obvious lessons on top of it. Most of the work is making the declared schema match what the endpoint actually returns. Before documenting, identify which endpoint class serves the route and what it does; the MCP tool that calls it is usually the fastest way to confirm its behavior. Promoting a PRIVATE/EXPERIMENTAL endpoint to PUBLIC is one application (see below).
@extend_schema(tags=[...]) — use the closest existing OPENAPI_TAGS entry.@extend_schema(operation_id=..., parameters=[...], responses={...}, examples=...).src/sentry/apidocs/parameters.py and examples/*.py; ensure owner = ApiOwner.<TEAM> is set.api-docs/paths/**/*.json covers the path, remove it (see lesson 4).Ideally, hit the live endpoint with a real token and diff the keys and types against your TypedDict. Serializers are sometimes inaccurate. Look out for counts coming back as floats instead of integers, IDs declared int emitted as strings, nested types declaring the wrong number of fields. Correct the declared type to match runtime.
curl -s -H "Authorization: Bearer $TOKEN" "https://us.sentry.io/api/0/<endpoint>" | jq 'keys'
Match the codebase's XxxResponseOptional(TypedDict, total=False) mixin (main class declares required fields). Nullable-vs-absent: T | None = key always present, value may be null; NotRequired[T] = key only set under a condition (e.g. an expand query param). Reuse the existing canonical type instead of re-declaring a second or third copy in a *_types.py. If there's no clean canonical type to reuse (e.g. a payload proxied from another service like vroom/profiling), type it dict[str, Any] rather than inventing a new mirror, and confirm the shape from the owning service's repo, not just the serializer.
cast and # type: ignoreWhen a serializer returns a base type plus extra fields, refactor the producing code so the response type is inferred rather than forced.
Delete the api-docs/paths/**/*.json file AND its $ref in api-docs/openapi.json. drf-spectacular's APPEND_PATHS does not merge HTTP methods, so once any method on a path uses @extend_schema, all legacy methods on that path vanish — migrate every method on the path in one commit.
Do the workflow above, then on the concrete endpoint only (leave siblings PRIVATE):
publish_status[<METHOD>] → PUBLIC and set owner = ApiOwner.<TEAM>.API_OWNERSHIP_ALLOWLIST_DONT_MODIFY in the same change as the flip.event:read → event:{admin,read,write}) — that's drf-spectacular regenerating from permission_classes, documentation-only.The change reaches the @sentry/api SDK / MCP only after sentry-api-schema regenerates downstream.
make build-api-docs
pnpm run validate-api-examples
.venv/bin/pytest -q --reuse-db tests/apidocs/endpoints/<area>/test_<name>.py
.venv/bin/prek run -q --files <changed paths>
npx claudepluginhub getsentry/skills --plugin sentry-skillsAudits FastAPI/REST API endpoints for documentation completeness and enhances docstrings, Pydantic models, response codes, and OpenAPI specs with realistic examples.
Writes and improves API reference documentation, endpoint descriptions, and OpenAPI specifications following best practices from Stripe, Twilio, and GitHub.
Generates OpenAPI specs and interactive API docs with Swagger/Redoc. Handles spec-first contracts and code-first auto-generation from Express, FastAPI, NestJS, Spring Boot.