Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Api Contract?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/sayeed1999-api-contract)
---
name: api-contract
description: Format for contracts/api.md, the single source of truth between frontend and backend. The architect writes it. Everyone else reads it.
---
# api-contract
Output: `contracts/api.md`. Used by the architect.
## Steps
### 1. Check an API is needed
- If no approved requirement needs an API, do not write the file. The architecture sets the backend root to `none`.
### 2. Write the header
- Use the Header format below. Naming follows `skills/stack-defaults` unless the architecture says otherwise.
### 3. Write the endpoints
- One block per endpoint, in the Endpoint format below.
- Every approved requirement that needs an API has at least one endpoint.
- For chat or AI endpoints: define the HTTP endpoint shape here (request body, response body). The LLM tool definitions and AI-specific behavior go in `contracts/ai.md`.
- Skip `[DEPRECATED]` requirements.
### 4. Check it
- Every endpoint lists its R-IDs.
- Every field has a type, required or optional, and rules.
- Every response has the exact JSON shape and status code.
- Every endpoint lists its error cases.
## Format: header
```
# API Contract
- Base URL: <from architecture>
- Auth: <for example: Bearer token in the Authorization header>
- Content type: application/json
- Naming: snake_case
- Version: v1
## Error format (all errors)
{ "error": { "code": "STRING_CODE", "message": "human text", "details": [] } }
## Common errors
- 400 VALIDATION_ERROR: request breaks the contract
- 401 UNAUTHENTICATED: missing or invalid token
- 403 FORBIDDEN: not allowed
- 404 NOT_FOUND
- 500 INTERNAL_ERROR
## GET /health
- Auth: none
- Success: 200 { "status": "ok" }
```
## Format: endpoint
```
### POST /v1/auth/signup
- R-IDs: R-01
- Auth: none
- Request body:
- email: string, required, valid email
- password: string, required, min 8 chars
- Success: 201
{ "id": "string", "email": "string", "token": "string" }
- Errors:
- 409 EMAIL_TAKEN: email already exists
- 400 VALIDATION_ERROR: invalid field
```
## Changing a contract
- Only the architect edits it.
- Under a changed endpoint add `Changed: <date> <reason>`.
- If the endpoint is built or being built, write a handoff to each affected engineer.
## MUST
- Use one naming style everywhere.
- Use the common error format for every error.
- Keep it plain markdown.
## NEVER
- Add an endpoint without an approved requirement.
- Use OpenAPI, unless the architecture says so.