api-and-interface-design

Designs stable REST APIs and TypeScript interfaces with consistent contracts and error semantics.

5|Updated Mar 5, 2024
One-click install
npx skills add https://github.com/TRAPZZY/God-Eyes --skill api-and-interface-design-trapzzy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/TRAPZZY/God-Eyes/tree/main/.skills/api-and-interface-design
Command: npx skills add https://github.com/TRAPZZY/God-Eyes --skill api-and-interface-design-trapzzy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed APIs and module boundaries create breaking changes, inconsistent error handling, and tight coupling between teams. This Skill guides the design of stable, hard-to-misuse interfaces before implementation begins. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, discriminated unions, and branded ID types before writing implementation code. - Consistent Error Semantics: Establish a single structured error format with proper HTTP status code mapping across all endpoints. - Boundary Validation: Enforce validation at system edges (API handlers, third-party responses) while trusting internal typed code. - Use Case: When building a new REST endpoint for a task management service, use this Skill to define the TaskAPI contract, pagination scheme, PATCH semantics, and error shapes so frontend and backend teams can work in parallel without breaking each other. ## Quick Start Use the api-and-interface-design skill to design a versioned REST API contract for a new tasks resource with pagination and consistent error responses.

Frequently Asked Questions about api-and-interface-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a REST API that won't break existing consumers?▼

Prefer addition over modification: add new fields as optional and never change existing field types or remove fields. Define the contract first with typed input and output schemas, and plan for deprecation at design time since users depend on all observable behavior.

What is the best error response format for REST APIs?▼

Use one consistent structured error body everywhere with a machine-readable code, human-readable message, and optional details. Map HTTP status codes predictably: 400 for invalid data, 401 for authentication, 404 for missing resources, 422 for validation failures, and 500 for server errors.

Should I use PATCH or PUT for updating resources?▼

Use PATCH for partial updates where only provided fields change, which is what clients actually want. PUT requires sending the full object every time, making it fragile for large resources and prone to overwriting concurrent changes.

Where should input validation happen in an API?▼

Validate at system boundaries only: API route handlers, form submissions, environment variables, and third-party API responses, which should always be treated as untrusted. Internal functions sharing type contracts should trust already-validated data.

When should I paginate list endpoints?▼

Paginate list endpoints from the start, not later. Once any user accumulates 100 or more items, unpaginated lists cause performance problems, and adding pagination afterward is a breaking response-shape change for existing consumers.