architect/api-design/SKILL.md
--- name: api-design description: Use this skill whenever the architect subagent is asked to design an API, define endpoints, choose between REST/GraphQL/gRPC, establish API conventions, review an API contract, or set API versioning strategy. Triggers on: "design an API", "define the endpoints", "REST vs GraphQL", "API contract", "API versioning", "API standards", "how should our API work", "design the interface". Always use this skill before producing any API design output — it ensures APIs are
npx skillsauth add achreftlili/deep-dev-skills architect/api-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Produce consistent, well-structured API designs that are easy to consume, hard to misuse, and built to evolve.
Use this decision tree:
Need flexible querying by clients (mobile/web with varying data needs)?
→ GraphQL
Need high-performance internal service-to-service communication?
→ gRPC
Need a simple, widely-understood external API?
→ REST
Need real-time bidirectional communication?
→ WebSocket (+ REST for control plane)
Need async event-driven communication between services?
→ Message queue (Kafka, SQS, RabbitMQ) — not an API pattern per se
State the choice and justify it before designing anything else.
/users, not /getUsers/orders, not /order/users/{id}/orders/payment-methods, not /paymentMethods| Action | Method | Example |
|--------|--------|---------|
| List | GET | GET /users |
| Get one | GET | GET /users/{id} |
| Create | POST | POST /users |
| Full replace | PUT | PUT /users/{id} |
| Partial update | PATCH | PATCH /users/{id} |
| Delete | DELETE | DELETE /users/{id} |
200 OK, 201 Created, 204 No Content400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable Entity500 Internal Server Error, 503 Service UnavailableAlways define with examples:
// POST /users - Request
{
"email": "[email protected]",
"name": "Jane Doe",
"role": "admin"
}
// 201 Created - Response
{
"id": "usr_abc123",
"email": "[email protected]",
"name": "Jane Doe",
"role": "admin",
"createdAt": "2024-01-15T10:30:00Z"
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Email address is invalid",
"field": "email",
"requestId": "req_xyz789"
}
}
{
"data": [...],
"pagination": {
"page": 1,
"pageSize": 20,
"total": 143,
"nextCursor": "cursor_abc" // use cursor pagination for large datasets
}
}
| Strategy | When to use |
|----------|-------------|
| URL versioning (/v1/users) | Public APIs, simple versioning needs — recommended default |
| Header versioning (API-Version: 2024-01) | Internal APIs, clients you control |
| Query param (?version=2) | Avoid — messy caching, hard to route |
Rules:
.proto files as the source of truth — version control them// comments in .proto filesBefore finalizing any API design:
testing
Set up Vitest 2.x with TypeScript for unit and component testing using test/describe/it, vi.fn/vi.mock/vi.spyOn, component testing with Testing Library, coverage (v8/istanbul), workspace config, and snapshot testing.
testing
Set up pytest 8.x with Python for unit and integration testing using fixtures (scope, autouse, parametrize), async tests (pytest-asyncio), mocking (unittest.mock, pytest-mock), coverage (pytest-cov), conftest.py patterns, and markers.
testing
Set up Playwright 1.49+ with TypeScript for E2E testing using page object model, fixtures, test.describe/test blocks, assertions, selectors, network mocking, CI configuration, and trace viewer.
testing
Set up Jest 30+ with TypeScript for unit tests, integration tests, mocking (jest.fn, jest.mock, jest.spyOn), coverage configuration, custom matchers, snapshot testing, and setup/teardown patterns.