New to Claude Skills? Learn how to install them →

jeremylongshore on GitHub

API Contract

Free

Define and manage API contracts with TypeScript interfaces.

Get this skill

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 source

1. Install with the skills CLI

npx skills add jeremylongshore/claude-code-plugins-plus-skills/api-contract --agent claude-code

2. 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 jeremylongshore

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]/
  • specs.md with defined feature scope and endpoint requirements
  • Familiarity with RESTful API conventions (HTTP methods, status codes, JSON schemas)
  • TypeScript knowledge for interface definitions (recommended)

Instructions

  1. Create api-contract.md in 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.md for the full template.
  2. Define TypeScript interfaces for all request and response types. Use explicit types instead of any, mark optional fields with ?, and use string | null for nullable values. Reference ${CLAUDE_SKILL_DIR}/references/typescript-interfaces.md for canonical type patterns.
  3. For list endpoints, include pagination parameters and the PaginatedResponse<T> wrapper. Standardize on page, limit, sort, and order query parameters as documented in ${CLAUDE_SKILL_DIR}/references/pagination.md.
  4. 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 optional details fields.
  5. 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).
  6. Share the contract file path in SPAWN REQUEST blocks so both backend and frontend agents read the same interface definition.

Output

  • api-contract.md containing 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

ErrorCauseSolution
Backend and frontend schemas divergeContract updated without notifying both agentsAlways reference a single api-contract.md; never duplicate endpoint definitions
Missing error response codesContract only documents the happy pathDocument all status codes: 400, 401, 403, 404, 409, 422 per endpoint
Ambiguous field typesUsing string without constraintsSpecify format, length, and validation rules (e.g., "string, required, min 8 chars")
Pagination inconsistencyList endpoints use different parameter namesStandardize on the PaginatedResponse<T> interface for all list endpoints
Type mismatch between JSON and TypeScriptDates serialized inconsistentlyUse 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