Skip to main content
skill CX Codex

api-contract — Claude Code skill for shared API contracts

Generates an api-contract.md file that backend and frontend agents read as one shared interface. No back-and-forth needed during a sprint.

MIT 1 installs ★ 2,935 updated 2026-11-01

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-code
Open on GitHub

What api-contract does

The skill walks through writing a contract file inside .claude/sprint/[N]/. Each endpoint gets an HTTP method, route, description, request body, response schema with status codes, and error codes. TypeScript interfaces cover request and response types, with optional fields marked by ? and nullable values typed as string | null.

List endpoints use a PaginatedResponse<T> wrapper and query parameters page, limit, sort, order. The error format stays consistent: code, message, and optional details. Reference files under ${CLAUDE_SKILL_DIR}/references/ hold the full templates.

You need a sprint directory and a specs.md with the feature scope first. The skill only reads — allowed-tools: Read — so it won't modify files on its own. TypeScript knowledge helps but isn't required to start.

What it helps with

  • keep backend and frontend schemas in sync
  • standardize error responses across endpoints
  • define pagination once for all list endpoints
  • type request and response payloads in TypeScript

Example prompts for the agent

  • Create an API contract for this sprint from specs.md
  • Define the registration endpoint with typed request and response
  • Add pagination to the products list endpoint

How to install api-contract

1Skills CLI (Vercel)

npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-code

2Manually: put the files in place

~/.claude/skills/api-contract/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/api-contract/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about api-contract

How do I install api-contract in Claude Code?

Run npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-code. The skill lands at ~/.claude/skills/api-contract/SKILL.md.

What does api-contract do?

It guides the creation of an api-contract.md file: endpoint definitions, request and response schemas, TypeScript interfaces, and a consistent error format. Backend and frontend agents read this one file instead of coordinating directly.

What do I need before using it?

A sprint directory at .claude/sprint/[N]/ and a specs.md with the feature scope. REST conventions and TypeScript are helpful, since the contract relies on typed schemas.

Source text

SKILL.md · MIT
---
name: api-contract
description: 'Configure this skill should be used when the user asks about "API contract",
  "api-contract.md", "shared interface", "TypeScript interfaces", "request response
  schemas", "endpoint design", or needs guidance on designing contracts that coordinate
  backend and frontend agents. Use when building or modifying API endpoints. Trigger
  with phrases like ''create API'', ''design endpoint'', or ''API scaffold''.

  '
allowed-tools: Read
version: 1.21.0
author: Damien Laine <[email protected]>
license: MIT
tags:
- community
- api
- typescript
compatibility: Designed for Claude Code
---
# 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

| 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:**

```markdown
#### 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:**

```markdown
#### 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:**

```typescript
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)

© Damien Laine · MIT · jeremylongshore/tons-of-skills-marketplace

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set139

The whole set →
openevidence-deploy-integration openevidence-deploy-integration plans an OpenEvidence rollout for a clinical workflow, covering the pilot, staff training, governance checks, and rollback conditions. CX Codex +1 1installs speak-install-auth speak-install-auth — a skill to integrate Speak, an AI language tutoring platform powered by GPT-4o and OpenAI Realtime. Configures API credentials, speech recognition, and prepares your environment to run lessons across 14+ languages. CX Codex +1 1installs speak-migration-deep-dive speak-migration-deep-dive migrates language learning platforms to Speak, imports student progress, and configures the @speak/language-sdk client. CX Codex +1 1installs lokalise-core-workflow-a lokalise-core-workflow-a — a Claude Code skill for the source-to-Lokalise direction: uploading translation files, creating and editing keys. Also runs in Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. CX Codex +1 1installs openrouter-cost-controls openrouter-cost-controls sets hard budget caps and tracks OpenRouter API spending across keys to prevent accidental balance drain. CX Codex +1 1installs instantly-cost-tuning The instantly-cost-tuning skill reviews Instantly usage and compares plan and account-capacity options. Use it when assessing workspace consumption before a capacity decision. CX Codex +1 1installs windsurf-license-management windsurf-license-management keeps track of Windsurf seats: builds a license inventory, sets who gets a seat, and turns usage into cost and audit reports. CX Codex +1 1installs windsurf-cost-tuning windsurf-cost-tuning audits Devin Desktop (formerly Windsurf) subscriptions by analyzing seat types, quota consumption, and extra on-demand usage limits. CX Codex +1 1installs

Project sponsors

Companies that keep this analytics open