OpenAPI Doc Writer
Produce and maintain OpenAPI documentation for an HTTP API. Use when documenting endpoints, request/response schemas, or generating API reference docs.
npx agentscamp add skills/openapi-doc-writerInstall to ~/.claude/skills/openapi-doc-writer/SKILL.md
A skill that authors and maintains spec-compliant OpenAPI 3.1 documents for an HTTP API: it inventories routes from the code, models reusable component schemas with $ref, writes each operation with operationId, parameters, request bodies, and error responses, adds validating examples, and lints the spec before finishing.
Author and maintain accurate, spec-compliant OpenAPI 3.1 documents that describe an HTTP API end to end — paths, operations, request bodies, responses, and reusable component schemas. This skill produces a single source of truth that drives reference docs, client SDK generation, and contract tests, while keeping the spec in sync with the actual code.
When to use this skill
Use this skill when you need to:
- Document a new endpoint or a whole service in OpenAPI (YAML or JSON).
- Add or correct request/response schemas, parameters, headers, or status codes.
- Reconcile an existing spec with route handlers that have drifted from it.
- Generate a human-readable API reference or set up client/server code generation from the spec.
Skip it for internal RPC, GraphQL, or non-HTTP interfaces — OpenAPI does not model those well.
Instructions
Follow these steps in order.
- Locate or create the spec. Look for an existing
openapi.yaml,openapi.json, orswagger.*. If none exists, createopenapi.yamlwithopenapi: 3.1.0, aninfoblock (title,version), and aserverslist. Prefer YAML for readability. - Inventory the endpoints. Read the route definitions / controllers to enumerate every method + path, its parameters, request body shape, and all possible responses (including errors). Treat the code as the source of truth when it conflicts with stale docs.
- Model reusable schemas first. Define shared object shapes under
components/schemasand reference them with$ref. Never inline the same object twice. Mark fieldsrequireddeliberately and express nullability with JSON Schema type arrays (e.g.type: [string, "null"]) — thenullablekeyword was removed in OpenAPI 3.1. - Write each operation. Under
paths, give every operation anoperationId(unique, camelCase), a one-linesummary,tagsfor grouping, typed parameters, arequestBodywhere applicable, and aresponsesmap covering success and documented error codes (e.g.400,401,404,422). - Add examples. Provide at least one realistic
example(orexamples) per request body and key response. Examples must validate against their schema. - Validate. Run a linter such as
redocly lintorspectral lintand fix every error and warning before finishing. - Render or generate (if requested). Produce reference HTML or client/server stubs from the validated spec.
NOTE
When you need exact field placement, data-type keywords, or security-scheme syntax, consult the official OpenAPI 3.1 specification rather than guessing.
WARNING
Keep info.version in step with releases and bump it on any breaking schema change. Downstream SDK generators and contract tests key off it.
Examples
Documenting GET /users/{id} with a reusable schema and error response:
paths:
/users/{id}:
get:
operationId: getUserById
summary: Retrieve a single user
tags: [Users]
parameters:
- name: id
in: path
required: true
schema: { type: string, format: uuid }
responses:
"200":
description: The requested user
content:
application/json:
schema: { $ref: "#/components/schemas/User" }
example: { id: "9f1c...", email: "ada@example.com", active: true }
"404":
description: User not found
content:
application/json:
schema: { $ref: "#/components/schemas/Error" }
components:
schemas:
User:
type: object
required: [id, email]
properties:
id: { type: string, format: uuid }
email: { type: string, format: email }
active: { type: boolean, default: true }
Error:
type: object
required: [code, message]
properties:
code: { type: integer }
message: { type: string }Validate before committing:
npx @redocly/cli lint openapi.yamlRelated
- 10 Best Claude Skills for API DevelopmentChoose Claude skills for error contracts, idempotency, pagination, limits, webhooks, CORS, GraphQL, OpenAPI, tools, and MCP servers.
- 7 Best Claude Skills for DocumentationUse Claude skills to verify code examples and create accurate READMEs, API docs, runbooks, onboarding guides, ADRs, and diagrams.
- Contract Testing for Microservices: Consumer, Provider, and CICatch breaking service changes before deployment with consumer-driven contracts, provider verification, state fixtures, compatibility gates, and schema tests.
- API Deprecation PlannerPlan the retirement of an API endpoint, field, event, tool, or version without surprising active consumers. Use when replacing an interface, removing legacy behavior, publishing a sunset, migrating internal or external clients, or deciding whether observed traffic is safe to turn off.
- API Error Contract DesignerDesign or normalize an API's error contract so clients get stable machine-readable codes, safe human messages, field-level validation details, correlation IDs, and consistent HTTP semantics. Use when adding endpoints, replacing ad hoc error strings, documenting SDK behavior, or fixing clients that branch on fragile message text.
- Documentation EngineerUse this agent to write and maintain technical docs that stay true to the code — READMEs, how-to guides, API references, and runbooks. Examples — updating a stale README after a refactor, documenting a new public API from its signatures, writing an on-call runbook for a service.
- Code Example VerifierVerify documentation code examples against the current repository and toolchain, then fix snippets, imports, commands, and expected output without changing the documented intent. Use when docs examples may be stale, an SDK or API changed, users report copy-paste failures, or before publishing tutorials, READMEs, migration guides, and release documentation.
- Contract Test DesignerDesign consumer-driven contract tests between services so an API provider can't break its consumers unnoticed — without slow, flaky full end-to-end environments. Use when independent services or teams integrate over an API, when integration bugs only surface in staging or prod, or when E2E suites are too slow and brittle to catch breaking API changes.