$npx -y skills add girijashankarj/cursor-handbook --skill api-docsWorkflow for creating comprehensive API documentation. Use when the user needs to document API endpoints.
| 1 | # Skill: Create API Documentation |
| 2 | |
| 3 | ## Trigger |
| 4 | When the user needs to document API endpoints. |
| 5 | |
| 6 | ## Prerequisites |
| 7 | - [ ] API endpoints exist or are designed |
| 8 | - [ ] OpenAPI/Swagger tooling available (optional) |
| 9 | - [ ] Access to route definitions or handler files |
| 10 | |
| 11 | ## Steps |
| 12 | |
| 13 | ### Step 1: Inventory Endpoints |
| 14 | - [ ] List all API endpoints |
| 15 | - [ ] Group by resource/entity |
| 16 | - [ ] Note HTTP method and path for each |
| 17 | |
| 18 | ### Step 2: Document Each Endpoint |
| 19 | For each endpoint: |
| 20 | - [ ] HTTP method and URL |
| 21 | - [ ] Description and purpose |
| 22 | - [ ] Authentication requirements |
| 23 | - [ ] Request parameters (path, query, header) |
| 24 | - [ ] Request body schema |
| 25 | - [ ] Response schemas (success + errors) |
| 26 | - [ ] Example request and response |
| 27 | - [ ] Rate limiting details |
| 28 | |
| 29 | ### Step 3: Create OpenAPI Spec |
| 30 | - [ ] Define info, servers, security schemes |
| 31 | - [ ] Create component schemas (reusable) |
| 32 | - [ ] Define paths with all operations |
| 33 | - [ ] Add examples for all schemas |
| 34 | - [ ] Validate spec |
| 35 | |
| 36 | ### Step 4: Generate Documentation |
| 37 | - [ ] Use Swagger UI or Redoc for interactive docs |
| 38 | - [ ] Host at `/api/docs` or similar |
| 39 | - [ ] Include in CI/CD for auto-updates |
| 40 | |
| 41 | ### Step 5: Review |
| 42 | - [ ] All endpoints documented |
| 43 | - [ ] Examples are accurate and working |
| 44 | - [ ] Error responses documented |
| 45 | - [ ] Authentication flow documented |
| 46 | |
| 47 | ## Completion Checklist |
| 48 | - [ ] All endpoints have method, URL, params, body, response |
| 49 | - [ ] Error responses (4xx, 5xx) documented |
| 50 | - [ ] Examples validated against live API or schema |
| 51 | - [ ] OpenAPI spec validates (if used) |
| 52 | |
| 53 | ## If Step Fails |
| 54 | - **Step 1 (inventory)**: Search for route definitions: `**/*.route*.ts`, `**/routes/**`, `app.get|post|put|delete` |
| 55 | - **Step 3 (OpenAPI)**: Use minimal spec first; add complexity incrementally. Validate with `swagger-cli validate` |
| 56 | - **Step 4 (generate)**: Swagger UI needs valid spec; Redoc is more forgiving. Check CORS if hosted separately |
| 57 | |
| 58 | ## Example |
| 59 | Step 2 for `POST /api/v1/orders`: Method POST, URL `/api/v1/orders`, Body `{ customerId, items: [{ productId, quantity }] }`, Response 201 `{ data: { id, status } }`, Errors 400 validation, 404 customer not found. |