api-contract
Skill18 starsChanged 11 months agoMITView on GitHub
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.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- gonimar/claude-web-studiotheir own version, first seen Sep 27, 2026
- ryktara/Foundrytheir own version, first seen Sep 25, 2026
- 1398281322-a11y/java-backend-guardrailstheir own version, first seen Aug 31, 2026
- PatriotAgenticLLC/better_claude_skillztheir own version, first seen Jul 1, 2026
- camilo-acevedo/claude-skillstheir own version, first seen May 14, 2026
- vndee/engineering-skillstheir own version, first seen Mar 22, 2026
Used with
Projects with it also use data-model.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Modular-Earth-LLCSkilldata-model
Design data models including entity-relationship schemas, vector database schemas, knowledge graphs, ontologies, and data governance policies. Use after architecture defines the data layer.
Also in 3 projects that use this
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- gonimar/claude-web-studio★ 5same name
- PatriotAgenticLLC/better_claude_skillz★ 3same name
- vndee/engineering-skills★ 3same name
- 1398281322-a11y/java-backend-guardrails★ 2same name
- camilo-acevedo/claude-skills★ 0same name
- ryktara/Foundry★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- docs/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agent-patternsSkill
- spec-writingSkill
- sprint-workflowSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 10 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 147
Use explicit types, not any
- Very specific: line 149
Use union types for nullable: string | null
- Distinctive: line 155
Document validation requirements explicitly:
- Distinctive: line 180
All agents have same understanding
- Distinctive: line 212
Use consistent error codes across all endpoints.
- Distinctive: line 268
Deviations: If agent must deviate, document in report
- Distinctive: line 274
When changing an existing contract:
- Distinctive: line 276
Consider versioning for major changes
- Distinctive: line 277
Update both request and response if affected
- Distinctive: line 322
Don't mention database columns
- Distinctive: line 323
Don't specify frameworks
- Distinctive: line 324
Don't include file paths
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Contract Design
The API contract (api-contract.md) is the shared interface between implementation agents. It defines what the backend provides and what the frontend consumes, ensuring both sides build compatible systems without direct communication.
Purpose
The contract serves as:
- Single source of truth for API shape
- Coordination mechanism between backend and frontend agents
- Validation reference for QA testing
- Documentation for the implemented API
Contract Structure
A complete api-contract.md contains:
# API Contract: [Feature Name]
## Base URL
[API base path, e.g., /api/v1]
## Authentication
[Auth requirements for endpoints]
## Endpoints
### [Endpoint Group]
#### [METHOD] [Route]
[Description]
**Request:**
[Request schema]
**Response:**
[Response schema]
**Errors:**
[Error codes and meanings]
## TypeScript Interfaces
[Shared type definitions]
## Validation Rules
[Input validation requirements]Writing Endpoints
Endpoint Definition
#### POST /auth/register
Create a new user account.
**Request:**
```json
{
"email": "string (required, valid email)",
"password": "string (required, min 8 chars)",
"name": "string (optional)"
}Response (201):
{
"id": "uuid",
"email": "string",
"name": "string | null",
"createdAt": "ISO 8601 datetime"
}Errors:
- 400: Invalid request body
- 409: Email already exists
- 422: Validation failed
### Key Elements
| Element | Purpose |
|---------|---------|
| Method + Route | HTTP verb and path |
| Description | What the endpoint does |
| Request | Input schema with types and constraints |
| Response | Output schema with status code |
| Errors | Possible error responses |
## TypeScript Interfaces
Define shared types for type safety across agents:
```markdown
## TypeScript Interfaces
```typescript
// User types
interface User {
id: string;
email: string;
name: string | null;
createdAt: string;
}
interface CreateUserRequest {
email: string;
password: string;
name?: string;
}
interface LoginRequest {
email: string;
password: string;
}
interface AuthResponse {
user: User;
token: string;
expiresAt: string;
}
// Error response
interface ApiError {
code: string;
message: string;
details?: Record<string, string[]>;
}
### Type Guidelines
- Use explicit types, not `any`
- Mark optional fields with `?`
- Use union types for nullable: `string | null`
- Include all possible response shapes
- Match types to JSON serialization
## Validation Rules
Document validation requirements explicitly:
```markdown
## Validation Rules
### User Registration
| Field | Rules |
|-------|-------|
| email | Required, valid email format, unique |
| password | Required, min 8 chars, 1 uppercase, 1 number |
| name | Optional, max 100 chars |
### Product Creation
| Field | Rules |
|-------|-------|
| title | Required, 3-200 chars |
| price | Required, positive number, max 2 decimals |
| category | Required, must exist in categories table |Why Document Validation
- Backend implements the rules
- Frontend can pre-validate before submit
- QA tests edge cases
- All agents have same understanding
Error Handling
Standard Error Format
## Error Response Format
All errors return:
```json
{
"code": "ERROR_CODE",
"message": "Human-readable message",
"details": {
"field": ["error1", "error2"]
}
}Error Codes
| Code | HTTP Status | Meaning |
| VALIDATION_ERROR | 422 | Input validation failed |
| NOT_FOUND | 404 | Resource doesn't exist |
| UNAUTHORIZED | 401 | Authentication required |
| FORBIDDEN | 403 | Permission denied |
| CONFLICT | 409 | Resource conflict |
### Error Consistency
Use consistent error codes across all endpoints. This helps:
- Frontend implement unified error handling
- QA test all error scenarios
- Users get predictable feedback
## Pagination
For list endpoints:
```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):**
```json
{
"data": [Product],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"totalPages": 8
}
}
### Pagination Interface
```typescript
interface PaginatedResponse<T> {
data: T[];
pagination: {
page: number;
limit: number;
total: number;
totalPages: number;
};
}Contract Evolution
During Sprint
- Initial: Architect creates contract based on specs
- Implementation: Agents follow contract exactly
- Deviations: If agent must deviate, document in report
- Update: Architect updates contract if deviation justified
- Final: Contract reflects implemented reality
Contract Changes
When changing an existing contract:
- Note breaking changes
- Consider versioning for major changes
- Update both request and response if affected
- Notify dependent agents via specs
Best Practices
Be Specific
// Good
"email": "string (required, valid email format)"
// Bad
"email": "string"Include Examples
**Request Example:**
```json
{
"email": "user@example.com",
"password": "SecurePass123"
}
### Document All States
Include responses for:
- Success (200, 201, 204)
- Client errors (400, 401, 403, 404, 422)
- Empty states (empty arrays, null values)
### Keep It DRY
Reference shared types instead of duplicating:
```markdown
**Response:** `User` (see TypeScript Interfaces)No Implementation Details
The contract defines WHAT, not HOW:
- Don't mention database columns
- Don't specify frameworks
- Don't include file paths
Common Patterns
CRUD Endpoints
### Products
| Method | Route | Description |
|--------|-------|-------------|
| GET | /products | List all products |
| GET | /products/:id | Get single product |
| POST | /products | Create product |
| PUT | /products/:id | Update product |
| DELETE | /products/:id | Delete product |Authentication Endpoints
### Authentication
| Method | Route | Auth | Description |
|--------|-------|------|-------------|
| POST | /auth/register | No | Create account |
| POST | /auth/login | No | Get token |
| POST | /auth/logout | Yes | Invalidate token |
| GET | /auth/me | Yes | Current user |
| POST | /auth/refresh | Yes | Refresh token |Additional Resources
For complete examples, examine the api-contract.md files generated in sprint directories after running /sprint.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

