adding-api-docs — Claude Code skill: OpenAPI docs for your API
This skill writes OpenAPI/Swagger documentation for an API: endpoint schemas, request and response types, and an interactive docs page.
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a claude-codeWhat adding-api-docs does
The skill triggers when you ask for API docs, Swagger, an OpenAPI spec, or endpoint documentation. It starts by detecting the framework: Express, Fastify, Next.js API routes, Hono, Django REST Framework, FastAPI and others.
What happens next depends on the stack. On Node.js/Express it installs swagger-jsdoc and swagger-ui-express, then builds the spec from JSDoc annotations above your route handlers. For Next.js API routes it creates an openapi.json file or generates one from handlers with next-swagger-doc, served at /api/docs. FastAPI already ships docs at /docs and /redoc, so the skill makes sure Pydantic models cover request and response types and the schemas come out on their own.
Separate steps cover the interactive UI (Swagger UI, Scalar or Redoc), request and response schemas via Zod or JSON Schema, and the auth scheme in securitySchemes. The skill tells you to generate the spec from code rather than hand-maintaining a YAML file — drift from the real API is what breaks these docs most often.
What it helps with
- generate an OpenAPI spec from Express route handlers
- serve Swagger UI at a
/docsroute - define request and response schemas with Zod
- document Bearer token and OAuth2 in
securitySchemes - wire
next-swagger-docinto Next.js API routes
Example prompts for the agent
- add API docs for my Express routes
- generate an OpenAPI spec and serve Swagger UI at /docs
- document the request and response schemas and the auth scheme
How to install adding-api-docs
1Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a claude-code2Manually: put the files in place
~/.claude/skills/adding-api-docs/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/adding-api-docs/
1Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a codex2Manually: put the files in place
.agents/skills/adding-api-docs/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a cursor2Manually: put the files in place
.cursor/skills/adding-api-docs/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install spencerpauly/awesome-cursor-skills adding-api-docs2Manually: put the files in place
.github/skills/adding-api-docs/SKILL.md1Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a gemini-cli2Platform CLI
gemini skills install https://github.com/spencerpauly/awesome-cursor-skills --path resources/adding-api-docsManually: put the files in place
.devin/skills/adding-api-docs/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about adding-api-docs
How do I install adding-api-docs in Claude?
Run npx skills add spencerpauly/awesome-cursor-skills --skill adding-api-docs -a claude-code. The skill lands in ~/.claude/skills/adding-api-docs/SKILL.md.
What does adding-api-docs do?
It generates OpenAPI/Swagger documentation for an API: endpoint schemas, request and response types, and an interactive UI. It handles Express, Fastify, Next.js API routes, Hono, Django REST Framework and FastAPI.
Do I still need a separate YAML spec file?
The skill recommends generating the spec from code where possible so it stays in sync with the actual API. A separate YAML file has to be updated by hand.
Source text
SKILL.md · CC0-1.0
---
name: adding-api-docs
description: Generate OpenAPI/Swagger documentation for an API, including endpoint schemas, request/response types, and interactive docs UI.
---
# Add API Documentation (OpenAPI)
Use this skill when the user asks to add API docs, Swagger, OpenAPI spec, or generate endpoint documentation.
## Steps
1. **Detect the API framework** — check for Express, Fastify, Next.js API routes, Hono, Django REST Framework, FastAPI, etc.
2. **For Node.js/Express** — install `swagger-jsdoc` and `swagger-ui-express`:
```bash
npm install swagger-jsdoc swagger-ui-express
npm install -D @types/swagger-jsdoc @types/swagger-ui-express
```
Create the OpenAPI spec from JSDoc annotations on route handlers:
```ts
/**
* @openapi
* /api/users:
* get:
* summary: List all users
* responses:
* 200:
* description: A list of users
*/
```
3. **For Next.js API routes** — create an `openapi.json` file manually or use `next-swagger-doc` to generate from route handlers. Serve the spec at `/api/docs`.
4. **For FastAPI (Python)** — docs are built-in at `/docs` (Swagger UI) and `/redoc`. Ensure Pydantic models are used for request/response types so schemas are auto-generated.
5. **Add interactive docs UI** — serve Swagger UI at a `/docs` route, or use Scalar/Redoc for a modern alternative:
```bash
npm install @scalar/express-api-reference
```
6. **Define schemas** — create Zod schemas (or JSON Schema) for request bodies and responses, then reference them in the OpenAPI spec. For TypeScript projects, use `zod-to-openapi` to generate schemas from existing Zod validators.
7. **Add authentication documentation** — document the auth scheme (Bearer token, API key, OAuth2) in the OpenAPI `securitySchemes` section.
## Notes
- Keep the spec in sync with the actual API — generate from code when possible rather than maintaining a separate YAML file.
- Add example values to schemas for better developer experience.
- Version the API docs alongside the code.
© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills