
API Contract
FreeDefine and manage API contracts with TypeScript interfaces.
Free · Opens the source repo
What API Contract does
API Contract is a skill designed to assist developers in creating and managing api-contract.md files, which serve as a shared interface between backend and frontend agents during sprint execution. This skill provides a structured approach to defining request and response schemas, endpoint routes, TypeScript interfaces, and error formats. By establishing a clear contract, teams can ensure that implementation agents build according to an agreed specification, minimizing the need for direct coordination and reducing the likelihood of discrepancies between backend and frontend implementations.
To effectively use this skill, users must have a sprint directory initialized and a specs.md file outlining the feature scope and endpoint requirements. Familiarity with RESTful API conventions and TypeScript is recommended, as the skill emphasizes the use of explicit types in interface definitions. The process involves creating an api-contract.md file, detailing each endpoint with the necessary specifications, and ensuring that all request and response types are well-defined and consistent.
The skill also emphasizes best practices for API contract authoring, such as specifying field constraints, providing examples for requests and responses, and standardizing pagination parameters. By following these guidelines, developers can create robust API contracts that facilitate smooth interactions between different components of their applications. This skill is particularly useful for teams working in agile environments where rapid iteration and clear communication are essential.
Overall, API Contract streamlines the process of designing and documenting API endpoints, making it an invaluable tool for developers looking to enhance their API development workflow.
When to use it
Use this skill when you need to create or modify API contracts during sprint execution, particularly when coordinating between backend and frontend teams.
When not to use it
This skill may not be suitable for projects that do not require strict API contracts or for teams unfamiliar with RESTful conventions and TypeScript.
What you can build with it
Creating a New API Endpoint
Use this skill to define a new API endpoint by generating an `api-contract.md` that specifies the request and response formats.
Updating Existing API Contracts
When modifying existing API contracts, this skill helps ensure that all changes are documented consistently across both frontend and backend.
Standardizing API Documentation
Leverage this skill to standardize API documentation practices across your team, ensuring all endpoints follow the same conventions.
How to install API Contract
View source1. Install with the skills CLI
npx skills add jeremylongshore/claude-code-plugins-plus-skills/api-contract --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by jeremylongshoreAPI 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]/ specs.mdwith defined feature scope and endpoint requirements- Familiarity with RESTful API conventions (HTTP methods, status codes, JSON schemas)
- TypeScript knowledge for interface definitions (recommended)
Instructions
- Create
api-contract.mdin the sprint directory (.claude/sprint/[N]/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_SKILL_DIR}/references/writing-endpoints.mdfor the full template. - Define TypeScript interfaces for all request and response types. Use explicit types instead of
any, mark optional fields with?, and usestring | nullfor nullable values. Reference${CLAUDE_SKILL_DIR}/references/typescript-interfaces.mdfor canonical type patterns. - For list endpoints, include pagination parameters and the
PaginatedResponse<T>wrapper. Standardize onpage,limit,sort, andorderquery parameters as documented in${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,message, and optionaldetailsfields. - Follow best practices from
${CLAUDE_SKILL_DIR}/references/best-practices.md: 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). - Share the contract file path in SPAWN REQUEST blocks so both backend and frontend agents read the same interface definition.
Output
api-contract.mdcontaining all endpoint definitions with typed request/response schemas- TypeScript interface declarations for
User,CreateUserRequest,LoginRequest,AuthResponse,ApiError, and domain-specific types - 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 api-contract.md; 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 string 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 PaginatedResponse<T> interface for all list endpoints |
| Type mismatch between JSON and TypeScript | Dates serialized inconsistently | Use ISO 8601 datetime strings; document as "createdAt": "ISO 8601 datetime" |
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
${CLAUDE_SKILL_DIR}/references/writing-endpoints.md-- Endpoint definition template and key elements${CLAUDE_SKILL_DIR}/references/typescript-interfaces.md-- Canonical type definitions and guidelines${CLAUDE_SKILL_DIR}/references/pagination.md-- Pagination parameters and PaginatedResponse interface${CLAUDE_SKILL_DIR}/references/best-practices.md-- Contract authoring rules (specificity, DRY, no implementation details)
Frequently asked questions about API Contract
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
