一键导入
doc-api-reference
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
Architecture documentation skill. Produces and updates architecture overview, component diagrams, technology stack, design decisions, and directory structure in .sdd/docs/architecture.md.
| name | doc-api-reference |
| description | API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md. |
| argument-hint | Invoked by Docs Agent Coordinator - do not call directly |
This skill is invoked by the Docs Agent Coordinator as a subagent. It produces and updates .sdd/docs/api-reference.md with endpoint documentation generated from contract files. API docs are generated from contract files (api-contracts.<ext>, error-catalog.<ext>), NOT from prose interpretation. Contract files are the source of truth.
This skill receives the following 7 inputs via the coordinator's subagent prompt, as defined in DOC-SKILL-CONTRACT.md:
| # | Input | Type | Description |
|---|---|---|---|
| 1 | skill_path | Path | Path to this SKILL.md file |
| 2 | wp_path | Path | Path to the approved WP file and its task list |
| 3 | spec_path | Path | Path to the spec file; includes contract files directory (.sdd/plans/contracts/<WP-slug>/) |
| 4 | source_files | List(Path) | Implementation source files modified by the WP |
| 5 | docs_dir | Path | Path to existing documentation directory (.sdd/docs/) for incremental updates |
| 6 | patterns | Text | Active doc-domain patterns to avoid (from .sdd/reviews/doc-patterns.md) |
| 7 | contracts_dir | Path | Path to contract files for this WP (.sdd/plans/contracts/<WP-slug>/) |
| Field | Value |
|---|---|
| Target file | .sdd/docs/api-reference.md |
| Action | Create if missing; update incrementally if existing |
| Content | One section per API endpoint with method, path, description, request/response schemas, error codes, auth requirements, and examples |
.sdd/docs/api-reference.md if it exists to understand current contentapi-contracts.<ext>, error-catalog.<ext>), WP file, and spec for context. Read multiple independent files in parallel via concurrent tool calls..sdd/docs/api-reference.md incrementally (do NOT recreate from scratch)Before generating API documentation, discover and validate the contract files for the current WP.
WP03-review-spec.md has slug review-spec).sdd/plans/contracts/<WP-slug>/api-contracts.<ext> -- API endpoint definitions (paths, methods, request/response types)error-catalog.<ext> -- Error codes, messages, HTTP status codesinterfaces.<ext> -- Function/method signatures (may contain endpoint handler signatures)data-schemas.<ext> -- Entity/model definitions (referenced by request/response types)<ext> matches the target language (e.g., .ts, .py, .go, .rs)If no contract files exist for the WP:
.sdd/plans/contracts/<WP-slug>/. Skipping API doc generation."api-reference.mdContract files may use different programming languages depending on the project. The skill must handle the target language's syntax for type and endpoint definitions.
Read TypeScript interfaces, types, and endpoint definitions:
// api-contracts.ts
export interface CreateUserInput {
email: string;
name: string;
role: "admin" | "user";
}
export interface CreateUserOutput {
id: string;
email: string;
name: string;
role: "admin" | "user";
createdAt: string;
}
// Endpoint: POST /api/users
// Input: CreateUserInput
// Output: CreateUserOutput
Extract: method (POST), path (/api/users), input type fields, output type fields, field types, union types as enums.
Read Python dataclasses, Pydantic models, or typed dicts:
# api_contracts.py
@dataclass
class CreateUserInput:
email: str
name: str
role: Literal["admin", "user"]
@dataclass
class CreateUserOutput:
id: str
email: str
name: str
role: Literal["admin", "user"]
created_at: str
Extract: class names, field names, types, Literal values as enums, Optional fields.
Read Go struct definitions:
// api_contracts.go
type CreateUserInput struct {
Email string `json:"email"`
Name string `json:"name"`
Role string `json:"role"` // "admin" | "user"
}
Extract: struct names, field names, JSON tags (for API field names), field types.
Read Rust struct definitions with serde:
// api_contracts.rs
#[derive(Serialize, Deserialize)]
pub struct CreateUserInput {
pub email: String,
pub name: String,
pub role: Role, // enum { Admin, User }
}
Extract: struct names, field names, types, enum variants.
Generate one section per API endpoint found in the contract files.
api-contracts.<ext> from the contracts directory/api/users, /api/users/:id)
c. Write a brief description of the endpoint's purpose (from type names and spec context)# API Reference
## POST /api/users
Create a new user account.
Document request parameters and body from contract type definitions.
:id in /users/:id)### Request
**Body** (`application/json`):
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `email` | string | Yes | User email address |
| `name` | string | Yes | User display name |
| `role` | string | Yes | One of: `admin`, `user` |
Document response schemas from contract type definitions.
application/json)### Response
**Success** (`200 OK`):
| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique user identifier |
| `email` | string | User email address |
| `name` | string | User display name |
| `role` | string | User role |
| `createdAt` | string | ISO 8601 creation timestamp |
Document error codes and meanings from the error catalog contract.
error-catalog.<ext> from the contracts directory### Errors
| Status | Code | Description |
|--------|------|-------------|
| 400 | `VALIDATION_ERROR` | Request body failed validation |
| 404 | `USER_NOT_FOUND` | No user exists with the given ID |
| 409 | `EMAIL_ALREADY_EXISTS` | A user with this email already exists |
Document authentication requirements for each endpoint.
### Authentication
Requires Bearer token in the `Authorization` header. User must have `admin` role.
Generate example request/response pairs from the contract schemas.
### Example
**Request**:
```http
POST /api/users HTTP/1.1
Content-Type: application/json
Authorization: Bearer <token>
{
"email": "jane@example.com",
"name": "Jane Doe",
"role": "admin"
}
```
**Response**:
```http
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "usr_abc123",
"email": "jane@example.com",
"name": "Jane Doe",
"role": "admin",
"createdAt": "2026-01-15T10:30:00Z"
}
```
API documentation SHALL be generated from contract files, NOT from prose interpretation. These rules enforce that contract files are the single source of truth.
api-contracts.<ext>, error-catalog.<ext>, data-schemas.<ext>, interfaces.<ext>)createdAt, the docs use createdAt, not created_at or dateCreatedemail: string, the docs show type string, not email address or varchar? (TypeScript), Optional (Python), or omitempty (Go), it is optional in the docsrole: "admin" | "user", the docs list exactly admin and user, not additional valueserror-catalog.<ext>, not inventedIf a discrepancy is detected between the spec prose and the contract files:
<!-- Note: spec describes <X> but contract defines <Y>. Using contract definition. -->When api-reference.md already exists with content from prior work packages:
api-reference.md content before making any changes## POST /api/users) to locate existing endpoint sectionsapi-reference.md into memory## endpoint headingsapi-reference.mdapi-reference.md does not exist, create it from scratch with an # API Reference heading and all endpoint sections<!-- Format note: this section uses non-standard formatting --> commentBefore completing, verify: