writing-skills
OBobra/superpowers298k近 7 天新增 2,631 个 star
Generate structured API reference documentation from source code, OpenAPI specs, or route definitions. Trigger phrases include "generate API docs", "document this API", "create API reference", "write endpoint docs", "scaffold API docs".
Generate clean, structured Markdown API reference docs from source code, OpenAPI/Swagger specs, or route definitions.
Before writing anything, determine:
https://api.example.com/v1. Default to https://api.example.com if unknown.single-file (default) — one Markdown file with all endpointsper-endpoint — one file per endpoint ({method}-{path-slug}.md) plus a README.md indexIf context is missing: In conversational mode, ask. In agent/inline mode, use sensible defaults and note your assumptions at the top of the output.
Read the file(s) and extract:
/// <summary>, @ApiOperation, @app.get(...), JSDoc @param/@returns, etc.)Framework detection hints:
| Signal | Framework |
|---|---|
[ApiController], [HttpGet] | ASP.NET Core |
@app.get(), @router.post() | FastAPI |
router.get(), app.use() | Express.js |
@GetMapping, @RestController | Spring Boot |
@Controller, @Get() | NestJS |
resources :users | Rails |
Parse the spec and map directly:
paths → endpointsparameters → params tablerequestBody → request body sectionresponses → response table + examplescomponents/schemas → inline the referenced modelssecurityDefinitions / securitySchemes → auth sectioninfo.title, info.version, servers[0].url → header metadataPrefer descriptions from the spec. Only infer descriptions when the spec omits them.
If the source references models, DTOs, or types defined in other files:
UserDto) and note that the full schema is defined elsewhere.# {API Name} — API Reference
> Base URL: `{base-url}`
> Authentication: {auth-method}
> Version: {version}
## Table of Contents
- [Authentication](#authentication)
- [{Resource Group}](#{resource-group-slug})
- [{METHOD} {path}](#{endpoint-anchor})
## Authentication
{How to authenticate: header format, token acquisition, expiration/refresh if known.}
**Header format:**
```
Authorization: Bearer {token}
```
---
## {Resource Group}
### {METHOD} `{path}`
{One-line description from doc comments or inferred from the code.}
**Parameters**
| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `id` | path | integer | ✅ | Resource ID |
| `limit` | query | integer | ❌ | Max results (default: 20) |
**Request Body** *(POST/PUT/PATCH only)*
```json
{
"email": "string — the user's email address",
"displayName": "string — display name"
}
```
**Responses**
| Status | Description |
|--------|-------------|
| `200 OK` | Returns the resource |
| `404 Not Found` | Resource not found |
```json
{
"id": 42,
"email": "[email protected]",
"displayName": "Jane Smith",
"createdAt": "2026-01-15T10:30:00Z"
}
```
**Example**
```bash
curl -X GET "{base-url}/{path}" \
-H "Authorization: Bearer eyJhbG..."
```
For per-endpoint format: one file per endpoint named {method}-{path-slug}.md (e.g., get-users-id.md), each using the endpoint section above, plus a README.md that links to all of them grouped by resource.
When you encounter these in the source, document them:
page, limit, offset, cursor. Note defaults and max values if visible.sort, filter, q, status. Document allowed values.X-RateLimit-* or decorators like @Throttle() are present, add a "Rate Limiting" section./v1/, /v2/) or header versioning, note it in the header.Do:
curl example for every endpoint[email protected], 42, "acme-corp" — not "string" or "value")Don't:
"string", "value", or "example" in response bodiesInput — ASP.NET Core controller:
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
/// <summary>Gets a user by their ID.</summary>
[HttpGet("{id}")]
public async Task<ActionResult<UserDto>> GetUser(int id) { }
/// <summary>Creates a new user.</summary>
[HttpPost]
public async Task<ActionResult<UserDto>> CreateUser([FromBody] CreateUserRequest request) { }
}
Output:
# Users API — API Reference
> Base URL: `https://api.example.com`
> Authentication: Bearer token
## Users
### GET `/api/users/{id}`
Gets a user by their ID.
**Parameters**
| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `id` | path | integer | ✅ | The user's unique ID |
**Responses**
| Status | Description |
|--------|-------------|
| `200 OK` | Returns the user |
| `404 Not Found` | User not found |
```json
{
"id": 42,
"email": "[email protected]",
"displayName": "Jane Smith",
"createdAt": "2026-01-15T10:30:00Z"
}
```
**Example**
```bash
curl -X GET "https://api.example.com/api/users/42" \
-H "Authorization: Bearer eyJhbG..."
```
---
### POST `/api/users`
Creates a new user.
**Request Body**
```json
{
"email": "string — the user's email address",
"displayName": "string — the user's display name",
"role": "string — user role (admin, member, viewer)"
}
```
**Responses**
| Status | Description |
|--------|-------------|
| `201 Created` | User created successfully |
| `400 Bad Request` | Invalid request body |
| `409 Conflict` | Email already exists |
```json
{
"id": 43,
"email": "[email protected]",
"displayName": "John Doe",
"createdAt": "2026-02-18T14:00:00Z"
}
```
**Example**
```bash
curl -X POST "https://api.example.com/api/users" \
-H "Authorization: Bearer eyJhbG..." \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "displayName": "John Doe", "role": "member"}'
```
path/query/header/body), type, and required statuscurl example with realistic dataOBobra/superpowers298k近 7 天新增 2,631 个 star
OBobra/superpowers298k近 7 天新增 2,631 个 star
MAmattpocock/skills288k近 7 天新增 10,178 个 star
MAmattpocock/skills288k近 7 天新增 10,178 个 star
MAmattpocock/skills288k近 7 天新增 10,178 个 star
MAmattpocock/skills288k近 7 天新增 10,178 个 star