add-openapi-docs
Skill36 starsChanged 4 months agoMITView on GitHub
Add or update OpenAPI 3.1 documentation for API endpoints in src/docs/. Use when the user asks to document endpoints, add Swagger/OpenAPI docs, or when a new resource or route was added without docs.
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 6
When the user asks to document an endpoint or resource, follow this sequence.
- Distinctive: line 16
Add component schemas for the resource:
- Distinctive: line 36
All response codes actually produced: 200/201, 400 (validation), 401, 403 (CSRF or ownership), 404, 409 (conflict), 429
- Very specific: line 48
If the resource introduces a new tag, add it to the tags array with a description.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When the user asks to document an endpoint or resource, follow this sequence. The spec is assembled at import time in src/docs/index.ts and served by swagger-ui-express at /api-docs.
Variables
<Name>= PascalCase singular (e.g.Note)<name>= camelCase singular (e.g.note)<names>= camelCase plural (e.g.notes)
Step 1 — Schemas (src/docs/schemas.ts)
Add component schemas for the resource:
<Name>— the response entity shape (must match<Name>ResponseDTOinsrc/types/, never include password/token/internal fields)Create<Name>RequestandUpdate<Name>Request— must match the Zod schemas insrc/validations/<name>.validation.tsexactly (required fields, min/max lengths, formats)
Reuse the existing shared schemas: ErrorResponse, PaginatedResponse, SuccessResponse.
Step 2 — Paths (src/docs/paths/<name>.paths.ts)
Copy the structure of src/docs/paths/note.paths.ts. It defines reusable local constants — keep the same ones:
csrfHeader— requiredx-csrf-tokenheader parameter on every mutating operation (POST/PUT/PATCH/DELETE)rateLimitHeaders—X-RateLimit-*response headers with the route group's actual limitauthErrors— shared 401/403/429 responses referencing#/components/schemas/ErrorResponsepaginationParams—page/limitquery params on list endpoints
For every operation document:
tags,summary,description(mention auth + rate limit)- Request body referencing the component schema, with a realistic
example - All response codes actually produced: 200/201, 400 (validation), 401, 403 (CSRF or ownership), 404, 409 (conflict), 429
security: [{ bearerAuth: [] }, { cookieAuth: [] }]on protected endpoints
Export const <name>Paths = { ... } keyed by path (e.g. '/notes', '/notes/{id}' — no base URL prefix; src/docs/index.ts handles that).
Step 3 — Register (src/docs/index.ts)
import { <name>Paths } from './paths/<name>.paths';
// merge into the paths object alongside authPaths, notePaths, healthPathsIf the resource introduces a new tag, add it to the tags array with a description.
Step 4 — Verify
pnpm full-check
pnpm dev # then open http://localhost:3000/api-docs and confirm the new endpoints renderConfirm every documented request/response matches the actual controller and validation behavior — docs that drift from code are worse than no docs.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/architecture.mdcCursor rule
- .cursor/rules/conventions.mdcCursor rule
- add-middlewareSkill
- add-testSkill
- api-design-principlesSkill
- find-skillsSkill
- improveSkill
- multi-stage-dockerfileSkill
- new-resourceSkill
- nodejs-best-practicesSkill
- prisma-client-apiSkill
- prisma-database-setupSkill
- prisma-postgresSkill
- security-auditSkill
- typescript-magicianSkill
- update-schemaSkill
- vitestSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

