一键导入
retro-api-contracts
Extracts API endpoints, function signatures, public interfaces, and type contracts from legacy code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extracts API endpoints, function signatures, public interfaces, and type contracts from legacy code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
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
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
基于 SOC 职业分类
| name | retro-api-contracts |
| description | Extracts API endpoints, function signatures, public interfaces, and type contracts from legacy code |
| argument-hint | Invoked by Retro-Spec Coordinator - do not call directly |
This skill is invoked by the Retro-Spec Coordinator as the third extraction skill. It analyzes the legacy codebase to extract all public APIs (HTTP endpoints, GraphQL operations, CLI commands, RPC definitions) and public function/class interfaces, producing Section 8 (API / Interface Design) and companion artifacts.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | accumulator_path | Path to the spec file being built |
| 3 | artifacts_dir | Path to companion artifacts directory |
| 4 | discovery_manifest_path | Path to the discovery manifest |
| 5 | source_path | Path to the legacy source code |
| 6 | target_language | Target language for artifacts |
| 7 | project_name | Name of the project |
| 8 | module_filter | Modules to analyze |
#tool:search/usages to trace API handler references and #tool:search/searchSubagent for broad endpoint discovery.api-contracts.<ext> and interfaces.<ext> in the artifacts directory[INFERRED: confidence] for every endpoint and interfaceBased on the discovery manifest's framework field, use the appropriate extraction strategy:
| Framework | Route Registration Pattern |
|---|---|
| Express.js | app.get|post|put|patch|delete\(, router.get|post|... |
| Fastify | fastify.get|post|..., route schema objects |
| Koa | router.get|post|... |
| NestJS | @Get|@Post|@Put|@Delete|@Patch, @Controller |
| Django | path\(, url\(, @api_view, viewset registration |
| Django REST | @action, ViewSet, Serializer, router registration |
| FastAPI | @app.get|post|..., @router.get|post|..., Pydantic models |
| Flask | @app.route, @blueprint.route |
| Spring | @GetMapping|@PostMapping|@RequestMapping |
| ASP.NET | [HttpGet]|[HttpPost]|[Route], controller conventions |
| Gin/Echo/Fiber (Go) | r.GET|POST|..., e.GET|POST|... |
| Actix/Axum (Rust) | web::get|post|..., handler functions |
| GraphQL | type Query, type Mutation, @Resolver |
| gRPC | .proto service definitions |
| CLI | commander, argparse, cobra, clap command definitions |
For each identified route:
Read the route registration to extract:
:id, {id}, <int:id>)Read the handler function to extract:
Read response construction to extract:
Read middleware to extract:
Read error handling to extract:
For each module identified in Section 9:
Identify exported symbols:
export / module.exports (Node.js)__all__ / public functions without _ prefix (Python)pub visibility (Rust)public access modifier (Java, C#)For each exported function/method:
For each exported class:
For each exported type/interface:
If OpenAPI or Swagger specs exist:
openapi.yaml, openapi.json, swagger.yaml, or swagger.json[INFERRED: HIGH] (it is documentation, not just code)[DISCREPANCY: openapi says X, code does Y]If GraphQL is detected:
.graphql/.gql schema filesIf CLI commands are detected:
## 8. API / Interface Design
### 8.1 HTTP API Endpoints
#### 8.1.1 GET /api/users
**Purpose**: List all users
[INFERRED: HIGH] Source: <routes file:line>
**Auth**: Bearer token required, role: admin
[INFERRED: MEDIUM] Source: <middleware file:line>
**Request**:
- **Query Parameters**:
| Param | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| page | integer | no | 1 | Page number |
| limit | integer | no | 20 | Items per page |
**Response** (200):
- **Body**: `User[]` (see Section 7.1)
**Errors**:
| Code | Error Key | Meaning | Source |
|------|-----------|---------|--------|
| 401 | UNAUTHORIZED | Missing auth token | <middleware:line> |
| 403 | FORBIDDEN | Insufficient role | <auth check:line> |
| 500 | INTERNAL_ERROR | Unhandled exception | <error handler:line> |
**Rate limit**: <extracted or "Not detected">
[INFERRED: confidence]
---
### 8.2 Public Module Interfaces
#### 8.2.1 UserService
Source: <file:line>
[INFERRED: HIGH]
| Method | Parameters | Return Type | Throws | Async | Description |
|--------|-----------|-------------|--------|-------|-------------|
| createUser | (data: CreateUserInput) | User | ValidationError, ConflictError | yes | Creates a new user |
| findById | (id: string) | User \| null | - | yes | Finds user by ID |
(Include interfaces for all public-facing modules)
// Generated by: retro-api-contracts skill (retro-spec)
// Source legacy code: <source_path>
// Target language: TypeScript
// Confidence: HIGH
// DO NOT EDIT MANUALLY -- regenerated on retro-spec re-run
// --- Request/Response Types ---
export interface ListUsersQuery {
page?: number; // default: 1
limit?: number; // default: 20, max: 100
}
export interface ListUsersResponse {
items: User[];
total: number;
page: number;
limit: number;
}
export interface CreateUserRequest {
email: string; // required, email format, max 255
name: string; // required, max 100
role?: UserRole; // default: "member"
}
// --- Error Types ---
export interface ApiError {
error: string; // machine-readable error key
message?: string; // human-readable description
details?: unknown[]; // field-level validation errors
}
// --- Endpoint Definitions ---
export type Endpoints = {
"GET /api/users": { query: ListUsersQuery; response: ListUsersResponse };
"POST /api/users": { body: CreateUserRequest; response: User };
"GET /api/users/:id": { params: { id: string }; response: User };
"PUT /api/users/:id": { params: { id: string }; body: UpdateUserRequest; response: User };
"DELETE /api/users/:id": { params: { id: string }; response: void };
};
// Generated by: retro-api-contracts skill (retro-spec)
// Source legacy code: <source_path>
// Target language: TypeScript
// Confidence: HIGH
// DO NOT EDIT MANUALLY -- regenerated on retro-spec re-run
export interface IUserService {
createUser(data: CreateUserRequest): Promise<User>;
findById(id: string): Promise<User | null>;
findByEmail(email: string): Promise<User | null>;
updateUser(id: string, data: UpdateUserRequest): Promise<User>;
deleteUser(id: string): Promise<void>;
listUsers(query: ListUsersQuery): Promise<ListUsersResponse>;
}
export interface IUserRepository {
create(data: Partial<User>): Promise<User>;
findById(id: string): Promise<User | null>;
findByEmail(email: string): Promise<User | null>;
update(id: string, data: Partial<User>): Promise<User>;
delete(id: string): Promise<void>;
findAll(options: { page: number; limit: number }): Promise<{ items: User[]; total: number }>;
}