Skillshub api-contract
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/jeremylongshore/claude-code-plugins-plus-skills/api-contract" ~/.claude/skills/comeonoliver-skillshub-api-contract && rm -rf "$T"
manifest:
skills/jeremylongshore/claude-code-plugins-plus-skills/api-contract/SKILL.mdsource content
API Contract
Overview
API Contract guides the creation of
api-contract.md files that serve as the shared interface between backend and frontend agents during sprint execution. The contract defines request/response schemas, endpoint routes, TypeScript interfaces, and error formats so that implementation agents build to an agreed specification without direct coordination.
Prerequisites
- Sprint directory initialized at
.claude/sprint/[N]/
with defined feature scope and endpoint requirementsspecs.md- Familiarity with RESTful API conventions (HTTP methods, status codes, JSON schemas)
- TypeScript knowledge for interface definitions (recommended)
Instructions
- Create
in the sprint directory (api-contract.md
). Define each endpoint using the standard format: HTTP method, route path, description, request body, response body with status code, and error codes. See.claude/sprint/[N]/api-contract.md
for the full template.${CLAUDE_SKILL_DIR}/references/writing-endpoints.md - Define TypeScript interfaces for all request and response types. Use explicit types instead of
, mark optional fields withany
, and use?
for nullable values. Referencestring | null
for canonical type patterns.${CLAUDE_SKILL_DIR}/references/typescript-interfaces.md - For list endpoints, include pagination parameters and the
wrapper. Standardize onPaginatedResponse<T>
,page
,limit
, andsort
query parameters as documented inorder
.${CLAUDE_SKILL_DIR}/references/pagination.md - Document all response states: success (200, 201, 204), client errors (400, 401, 403, 404, 422), and empty states. Use a consistent error response format with
,code
, and optionalmessage
fields.details - Follow best practices from
: be specific about field constraints (e.g., "string, required, valid email format"), include request/response examples, reference shared types instead of duplicating, and omit implementation details (no database columns, framework names, or file paths).${CLAUDE_SKILL_DIR}/references/best-practices.md - Share the contract file path in SPAWN REQUEST blocks so both backend and frontend agents read the same interface definition.
Output
containing all endpoint definitions with typed request/response schemasapi-contract.md- TypeScript interface declarations for
,User
,CreateUserRequest
,LoginRequest
,AuthResponse
, and domain-specific typesApiError - Paginated response wrappers for list endpoints
- Standardized error format across all endpoints
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Backend and frontend schemas diverge | Contract updated without notifying both agents | Always reference a single ; never duplicate endpoint definitions |
| Missing error response codes | Contract only documents the happy path | Document all status codes: 400, 401, 403, 404, 409, 422 per endpoint |
| Ambiguous field types | Using without constraints | Specify format, length, and validation rules (e.g., "string, required, min 8 chars") |
| Pagination inconsistency | List endpoints use different parameter names | Standardize on the interface for all list endpoints |
| Type mismatch between JSON and TypeScript | Dates serialized inconsistently | Use ISO 8601 datetime strings; document as |
Examples
Authentication endpoint contract:
#### POST /auth/register Create a new user account. **Request:** { "email": "string (required, valid email)", "password": "string (required, min 8 chars)", "name": "string (optional)" } **Response (201):** # HTTP 201 Created { "id": "uuid", "email": "string", "name": "string | null", "createdAt": "ISO 8601 datetime" # 8601 = configured value } **Errors:** - 400: Invalid request body # HTTP 400 Bad Request - 409: Email already exists # HTTP 409 Conflict - 422: Validation failed # HTTP 422 Unprocessable Entity
Paginated list endpoint:
#### GET /products List products with pagination. **Query Parameters:** | Param | Type | Default | Description | |-------|------|---------|-------------| | page | integer | 1 | Page number | | limit | integer | 20 | Items per page (max 100) | | sort | string | createdAt | Sort field | | order | string | desc | Sort order (asc/desc) | **Response (200):** # HTTP 200 OK { "data": [Product], "pagination": { "page": 1, "limit": 20, "total": 150, "totalPages": 8 } }
Shared TypeScript interface:
interface ApiError { code: string; message: string; details?: Record<string, string[]>; }
Resources
-- Endpoint definition template and key elements${CLAUDE_SKILL_DIR}/references/writing-endpoints.md
-- Canonical type definitions and guidelines${CLAUDE_SKILL_DIR}/references/typescript-interfaces.md
-- Pagination parameters and PaginatedResponse interface${CLAUDE_SKILL_DIR}/references/pagination.md
-- Contract authoring rules (specificity, DRY, no implementation details)${CLAUDE_SKILL_DIR}/references/best-practices.md