api-contract — скилл для Claude Code: контракты API между агентами
Создаёт файл api-contract.md — общий интерфейс, по которому бэкенд- и фронтенд-агенты строят API без прямых согласований. Пригодится в спринтах, где несколько агентов пишут один сервис.
MIT 1 установок ★ 2 935 обновлён 2026-11-01
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-codeЧто делает api-contract
Скилл описывает, как оформить api-contract.md в директории спринта. В файле фиксируются эндпоинты, схемы запросов и ответов, TypeScript-интерфейсы и формат ошибок. Оба агента читают один и тот же контракт, поэтому схемы не расходятся.
Внутри — инструкции и референсы: шаблон описания эндпоинта, канонические паттерны типов, пагинация через PaginatedResponse<T>. Для списковых эндпоинтов стандартизируются параметры page, limit, sort, order.
Перед запуском нужна директория спринта .claude/sprint/[N]/ и specs.md с описанием фич. Скилл требует знания REST-конвенций, а TypeScript — на уровне рекомендации. Работает только на чтение: allowed-tools: Read.
Какие задачи решает
- согласовать схемы API между бэкенд- и фронтенд-агентом
- зафиксировать формат ошибок для всех эндпоинтов
- описать пагинацию единообразно для списков
- задать TypeScript-интерфейсы для запросов и ответов
- убрать дублирование определений эндпоинтов
Примеры запросов агенту
- Создай контракт API для спринта из
specs.md - Опиши эндпоинт регистрации пользователя по шаблону
- Добавь пагинацию в список продуктов и типизируй ответ
Как установить api-contract
1Через Skills CLI (Vercel)
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-code2Вручную: положить файлы
~/.claude/skills/api-contract/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/api-contract/
1Через Skills CLI (Vercel)
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a codex2Вручную: положить файлы
.agents/skills/api-contract/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a cursor2Вручную: положить файлы
.cursor/skills/api-contract/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install jeremylongshore/tons-of-skills-marketplace skills/.curated/api-contract2Вручную: положить файлы
.github/skills/api-contract/SKILL.md1Через Skills CLI (Vercel)
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a gemini-cli2Командой платформы
gemini skills install https://github.com/jeremylongshore/tons-of-skills-marketplace --path skills/.curated/api-contractВручную: положить файлы
.devin/skills/api-contract/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об api-contract
Как установить api-contract в Claude Code?
Выполни npx skills add jeremylongshore/tons-of-skills-marketplace --skill api-contract -a claude-code. Скилл появится в ~/.claude/skills/api-contract/SKILL.md.
Что делает api-contract?
Помогает составить api-contract.md — единый файл с маршрутами, схемами запросов и ответов, TypeScript-интерфейсами и кодами ошибок. Бэкенд- и фронтенд-агенты читают его и строят API по одной спецификации.
Что нужно для работы скилла?
Директория спринта .claude/sprint/[N]/ и specs.md с областью фич. Полезно знать REST-конвенции и TypeScript — без этого контракт получится неточным.
Исходный текст
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