api-and-interface-design

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

4|Updated Jun 19, 2026
One-click install
npx skills add https://github.com/douglance/sdlc-plugin --skill api-and-interface-design-douglance
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/douglance/sdlc-plugin/tree/main/.rulesync/skills/api-and-interface-design
Command: npx skills add https://github.com/douglance/sdlc-plugin --skill api-and-interface-design-douglance

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Public APIs and module boundaries become hard to change once consumers depend on them, and inconsistent error handling, naming, or breaking changes erode consumer trust. This Skill provides a contract-first methodology for designing interfaces that stay backward compatible and predictable. ## Core Features & Use Cases - Contract-First Design: Define typed interfaces (e.g., TypeScript TaskAPI) before implementation, with input/output separation and branded ID types. - Consistent Error Semantics: Standardize on one error strategy with structured error bodies and HTTP status code mapping (400, 401, 403, 404, 409, 422, 500). - Boundary Validation: Validate external input at API edges with schema parsing while trusting internal typed code, treating third-party responses as untrusted. - Use Case: When adding a new labels field to a task creation endpoint, follow the additive-change rule to make it optional so existing consumers keep working without modification. ## Quick Start Ask the AI to design a REST API contract for a new resource, including typed inputs, error responses, and pagination, following the api-and-interface-design conventions.

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 stays backward compatible?▼

Design backward compatible REST APIs by preferring addition over modification: add new fields as optional rather than changing types or removing fields. Define the contract first, keep naming conventions consistent, and plan deprecation before removing anything consumers depend on.

How should REST API errors be structured?▼

Use one consistent error strategy everywhere: a structured body with a machine-readable code, human-readable message, and optional details, mapped to HTTP status codes like 400, 404, 409, and 422. Never mix patterns such as throwing, returning null, and returning error objects across endpoints.

Where should input validation happen in an API?▼

Validate at system boundaries where external input enters: route handlers, form submissions, environment variables, and third-party API responses. Do not re-validate between internal functions that share type contracts or on data from your own database.

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

Hyrum's Law states that with enough users, every observable behavior of your API becomes depended upon, including undocumented quirks. It means you should expose behavior intentionally, hide implementation details, and plan deprecation at design time.

When should I use discriminated unions in TypeScript interfaces?▼

Use discriminated unions when a value has distinct variants with different fields, such as task statuses like pending, in_progress, or completed. A shared type tag enables compiler-checked narrowing in switch statements so each variant is handled explicitly.