skills/council/architect/api-design/SKILL.md
Use when designing REST or RPC endpoint contracts with request/response types and error handling. Covers endpoint specification, TypeScript type definitions, authentication requirements, pagination, and caching strategies. Do not use for database schema changes (use schema-design) or codebase analysis (use codebase-context).
npx skillsauth add dtsong/my-claude-setup 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.
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.
No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.
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:
Compaction resilience: If context was lost during a long session, re-read the Inputs section to reconstruct what system is being analyzed, check the Progress Checklist for completed steps, then resume from the earliest incomplete step.
# 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 -->
testing
Use to convert a Word .docx file to PDF and/or verify its page count. Triggers on: converting docx to pdf, rendering a document, checking how many pages a docx produces, or asserting a page-count constraint (e.g. a resume must stay 2 pages). Wraps LibreOffice headless conversion.
development
Security audit checklist for web applications. Use when reviewing, auditing, or hardening a web app's security posture. Covers rate limiting, auth headers, IP blocking, CORS, security middleware, input validation, file upload limits, ORM usage, and password hashing. Triggers on requests like "review security", "harden this app", "security audit", "check for vulnerabilities", or when building/reviewing API endpoints.
development
Interactive wizard to craft effective prompts using Claude Code best practices
tools
Use when batch labeling, prioritizing, and assigning GitHub issues during triage sessions.