api-and-interface-design

Designs stable REST APIs, TypeScript contracts, and module boundaries with consistent error semantics.

Updated May 21, 2026
One-click install
npx skills add https://github.com/nicorevo/AI-SDLC-Template --skill api-and-interface-design-nicorevo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/nicorevo/AI-SDLC-Template/tree/main/.opencode/skills/api-and-interface-design
Command: npx skills add https://github.com/nicorevo/AI-SDLC-Template --skill api-and-interface-design-nicorevo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and hidden coupling that break consumers. This Skill guides the design of stable, hard-to-misuse APIs and module boundaries before implementation begins. ## Core Features & Use Cases - Contract-First Design: Define typed interfaces, input/output schemas, and error contracts before writing implementation code. - REST API Patterns: Apply conventions for resource naming, pagination, filtering, partial updates (PATCH), and consistent error response shapes. - TypeScript Interface Patterns: Use discriminated unions, input/output separation, and branded ID types to prevent misuse at compile time. - Use Case: When adding a new tasks endpoint to a web application, use this Skill to define the endpoint contract, pagination scheme, validation-at-boundary rules, and error format before writing any route handlers. ## Quick Start Ask the agent to design the API contract for a new resource, including endpoints, typed inputs and outputs, error responses, and pagination.

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?▼

Design REST APIs by preferring addition over modification: add new fields as optional, never change existing field types or remove fields. Use plural nouns for endpoints, PATCH for partial updates, and paginate all list endpoints from the start.

How to structure error responses in a REST API?▼

Structure error responses with one consistent shape: a machine-readable code, a human-readable message, and optional details. Map errors to standard HTTP status codes like 400, 401, 403, 404, 409, and 422, and never mix error patterns across endpoints.

Where should input validation happen in an application?▼

Input validation belongs at system boundaries: API route handlers, form submissions, external service responses, and environment variable loading. Internal functions that share type contracts should trust already-validated data instead of re-validating.

Should third-party API responses be validated before use?▼

Third-party API responses are untrusted data and must always be validated before use in logic, rendering, or decisions. A compromised or misbehaving external service can return unexpected types, malicious content, or instruction-like text.

When should I use PATCH instead of PUT for updates?▼

Use PATCH for partial updates where only provided fields change, which is what clients typically need. PUT requires sending the full object every time, making it cumbersome for consumers and prone to overwriting unintended fields.

What is Hyrum's Law and why does it matter for API design?▼

Hyrum's Law states that all observable behaviors of an API will be depended on by somebody, regardless of the documented contract. It means every public behavior is a commitment, so avoid leaking implementation details and plan for deprecation at design time.