api-design
REST/RPC endpoint contracts with request/response types and error handling
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
REST/RPC endpoint contracts with request/response types and error handling
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Fast codebase searches using grep/glob. Triggers on "find", "search", "where is", "grep for".
Use when working with dbt (data build tool) - creating models, writing tests, CI/CD pipelines, materializations, sources, staging/intermediate/marts layers, Snowflake/BigQuery warehouse configuration, incremental strategies, Jinja macros, data quality, semantic layer, or making analytics engineering decisions
Local git operations for syncing, branching, merging, and conflict resolution
GitHub interactions for issues, PRs, releases, and repository management
Interactive wizard to craft effective prompts using Claude Code best practices
Test-driven development reference for writing good tests, designing testable interfaces, mocking at system boundaries, and refactoring after green. Use when writing tests, reviewing test quality, or applying red-green-refactor workflow. Not for running test suites or CI configuration — use language-conventions or cicd-generation for those.
| name | API Design |
| department | architect |
| description | REST/RPC endpoint contracts with request/response types and error handling |
| version | 1 |
| triggers | ["API","endpoint","route","REST","RPC","server action","webhook","contract"] |
Design REST/RPC endpoint contracts with request/response types, error handling, and versioning strategy. Produces TypeScript type definitions and endpoint documentation that serve as the contract between frontend and backend.
Read current route handlers and list all existing paths, HTTP methods, request/response shapes, and auth requirements. Note naming conventions and patterns in use.
From the feature requirements and schema design output, determine what operations the frontend needs. Group by resource and map to CRUD operations where applicable.
For each endpoint, specify:
Write TypeScript interfaces for:
For each endpoint, define:
Design a consistent error response shape:
For list endpoints:
If applicable:
# API Design: [Feature Name]
## Endpoint Overview
| Method | Path | Auth | Description |
|--------|------|------|-------------|
| GET | /api/... | authenticated | ... |
| POST | /api/... | authenticated | ... |
## Type Definitions
```typescript
// Shared types
interface PaginatedResponse<T> {
data: T[];
cursor: string | null;
hasMore: boolean;
}
// Request types
interface CreateFooRequest {
name: string;
// ...
}
// Response types
interface FooResponse {
id: string;
name: string;
createdAt: string;
// ...
}
enum ErrorCode {
VALIDATION_ERROR = 'VALIDATION_ERROR',
NOT_FOUND = 'NOT_FOUND',
UNAUTHORIZED = 'UNAUTHORIZED',
FORBIDDEN = 'FORBIDDEN',
// ...
}
interface ApiError {
code: ErrorCode;
message: string;
details?: Record<string, string[]>; // field-level errors
}
| Error Code | HTTP Status | When |
|---|---|---|
| VALIDATION_ERROR | 400 | Request body fails validation |
| NOT_FOUND | 404 | Resource does not exist |
| UNAUTHORIZED | 401 | Missing or invalid auth |
| FORBIDDEN | 403 | Authenticated but lacking permission |
Auth: [requirement]
Request:
// params / body / query
Response (200):
// success shape
Errors:
Example:
curl -X POST /api/foo \
-H "Authorization: Bearer ..." \
-d '{"name": "bar"}'
| Endpoint Pattern | Cache-Control | Notes |
|---|---|---|
| GET /api/... | ... | ... |
## Quality Checks
- [ ] Every endpoint has defined auth requirements
- [ ] Error cases are enumerated for each endpoint
- [ ] Request and response types are fully specified (no `any` types)
- [ ] Naming follows existing project conventions (REST or RPC, plural vs singular)
- [ ] List endpoints include pagination strategy
- [ ] Shared types are extracted (no duplication across endpoints)
- [ ] Error contract is consistent across all endpoints
- [ ] Examples include realistic request/response payloads
## Evolution Notes
<!-- Observations appended after each use -->