원클릭으로
plan-api-contracts
Request/response types, endpoint definitions per WP
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Request/response types, endpoint definitions per WP
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | plan-api-contracts |
| description | Request/response types, endpoint definitions per WP |
| argument-hint | Invoked by Planner Coordinator - do not call directly |
Phase: 2 (Contract Generation) Common contract:
.github/skills/PLAN-SKILL-CONTRACT.mdSpec refs: FR-043, FR-044, FR-045, FR-039
This skill is dispatched by the Planner Coordinator during Phase 2. It reads the plan accumulator and generates language-specific API contract files scoped per work package.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | plan_dir | Path to .sdd/plans/ directory |
| 3 | contracts_dir | Path to .sdd/plans/contracts/ directory |
| 4 | spec_path | Path to the source spec file |
| 5 | spec_artifacts_dir | Path to spec companion artifacts |
| 6 | research_summary | Key findings from the research phase |
| 7 | target_language | Programming language for contract generation |
| 8 | patterns | Active plan-domain patterns to avoid |
| 9 | phase | Phase indicator (always 2 for this skill) |
api-contracts.<ext> from spec_artifacts_dir. Read spec and artifact files in parallel.api-contracts.<ext> to contracts_dir/<WP-slug>/ per applicable WPRead the plan accumulator. For each WP, determine if it:
Skip WPs that:
Check if spec_artifacts_dir contains an api-contracts.<ext> file. If it exists:
If the spec artifact does NOT exist:
For each applicable WP, generate <contracts_dir>/<WP-slug>/api-contracts.<ext>:
// Generated by: plan-api-contracts skill
// Source spec: <spec_path>
// Work package: WP<NN>-<slug>
// Target language: <target_language>
// DO NOT EDIT MANUALLY -- regenerated on plan revision
// TypeScript example
export const API_PATHS = {
GET_USERS: '/api/v1/users',
GET_USER_BY_ID: '/api/v1/users/:id',
CREATE_USER: '/api/v1/users',
UPDATE_USER: '/api/v1/users/:id',
DELETE_USER: '/api/v1/users/:id',
} as const;
# Python example
class ApiPaths:
GET_USERS = '/api/v1/users'
GET_USER_BY_ID = '/api/v1/users/{id}'
CREATE_USER = '/api/v1/users'
UPDATE_USER = '/api/v1/users/{id}'
DELETE_USER = '/api/v1/users/{id}'
For each endpoint that accepts a request body:
export interface CreateUserRequest {
email: string;
name: string;
password: string;
role?: 'admin' | 'user';
}
export interface UpdateUserRequest {
email?: string;
name?: string;
role?: 'admin' | 'user';
}
Requirements:
For each endpoint:
export interface UserResponse {
id: string;
email: string;
name: string;
role: 'admin' | 'user';
createdAt: string; // ISO 8601
}
export interface UserListResponse {
data: UserResponse[];
pagination: PaginationMeta;
}
Annotate each endpoint with its auth mechanism:
export const AUTH_REQUIREMENTS = {
[API_PATHS.GET_USERS]: { type: 'bearer', roles: ['admin'] },
[API_PATHS.GET_USER_BY_ID]: { type: 'bearer', roles: ['admin', 'user'] },
[API_PATHS.CREATE_USER]: { type: 'none' },
[API_PATHS.UPDATE_USER]: { type: 'bearer', roles: ['admin', 'self'] },
[API_PATHS.DELETE_USER]: { type: 'bearer', roles: ['admin'] },
} as const;
For each endpoint, include all applicable error response types:
// Common error response shape
export interface ApiErrorResponse {
error: {
code: string; // Domain error code (e.g., 'USER_NOT_FOUND')
message: string; // User-facing message
details?: unknown; // Optional structured details
};
status: number; // HTTP status code
}
// Per-endpoint error mapping
export const ENDPOINT_ERRORS = {
[API_PATHS.CREATE_USER]: {
400: 'VALIDATION_ERROR', // Invalid request body
401: 'AUTH_REQUIRED', // Missing auth token
403: 'FORBIDDEN', // Insufficient permissions
409: 'USER_ALREADY_EXISTS', // Duplicate email
422: 'UNPROCESSABLE_ENTITY', // Valid JSON, invalid semantics
500: 'INTERNAL_ERROR', // Unexpected server error
},
[API_PATHS.GET_USER_BY_ID]: {
401: 'AUTH_REQUIRED',
403: 'FORBIDDEN',
404: 'USER_NOT_FOUND',
500: 'INTERNAL_ERROR',
},
} as const;
Applicability rules (not all codes apply to every endpoint):
If a WP's API contract file exceeds 800 lines, split generation across multiple writes.
<contracts_dir>/<WP-slug>/api-contracts.<ext>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.