This skill should be used when the user asks to "design API", "map endpoints", "define schemas", or mentions "API", "endpoint", "REST", "OpenAPI", "schema", "contract", or "HTTP". Provides RESTful API design with endpoint mapping, request/response schemas, and comprehensive error handling.
View on GitHubdeepeshBodh/human-in-loop
humaninloop
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/deepeshBodh/human-in-loop/blob/main/plugins/humaninloop/skills/patterns-api-contracts/SKILL.md -a claude-code --skill patterns-api-contractsInstallation paths:
.claude/skills/patterns-api-contracts/# Designing API Contracts
## Purpose
Design RESTful API contracts that map user actions to endpoints with complete schema definitions and comprehensive error handling. This skill covers endpoint design, request/response schemas, and OpenAPI specification.
## Endpoint Mapping
### User Action to Endpoint Mapping
| User Action | HTTP Method | Endpoint Pattern |
|-------------|-------------|------------------|
| Create resource | POST | `/resources` |
| List resources | GET | `/resources` |
| Get single resource | GET | `/resources/{id}` |
| Update resource | PUT/PATCH | `/resources/{id}` |
| Delete resource | DELETE | `/resources/{id}` |
| Perform action | POST | `/resources/{id}/{action}` |
| Get nested resource | GET | `/resources/{id}/children` |
### Method Selection
| Scenario | Method | Idempotent? |
|----------|--------|-------------|
| Create new resource | POST | No |
| Full replacement | PUT | Yes |
| Partial update | PATCH | No |
| Read resource | GET | Yes |
| Remove resource | DELETE | Yes |
| Trigger action | POST | Usually No |
### Resource Naming Conventions
- Use plural nouns: `/users`, not `/user`
- Use kebab-case for multi-word: `/user-profiles`
- Use path params for IDs: `/users/{userId}`
- Use query params for filtering: `/users?role=admin`
- Use nested paths for relationships: `/users/{userId}/tasks`
## Endpoint Documentation Format
Document each endpoint with description, source requirements, request/response schemas, and error cases:
```markdown
## POST /api/auth/login
**Description**: Authenticate user with email and password
**Source Requirements**: FR-001, US#1
### Request
{JSON request body example}
### Response (200 OK)
{JSON response body example}
### Error Responses
| Status | Code | Description |
|--------|------|-------------|
| 400 | INVALID_INPUT | Missing or malformed fields |
| 401 | INVALID_CREDENTIALS | Wrong email or password |
```
## Schema Definition
### Request Schema Format
```yaml
LoginRequest:
type: obj