api-and-interface-design

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

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/Qiuyi-Hong/addyosmani-skills --skill api-and-interface-design-qiuyi-hong
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/Qiuyi-Hong/addyosmani-skills/tree/main/skills/api-and-interface-design
Command: npx skills add https://github.com/Qiuyi-Hong/addyosmani-skills --skill api-and-interface-design-qiuyi-hong

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and hidden dependencies that break consumers. This Skill guides the design of stable APIs and module boundaries that are hard to misuse, applying principles like Hyrum's Law, contract-first design, and the One-Version Rule. ## Core Features & Use Cases - Contract-First Design: Define typed interfaces before implementation, with input/output separation, discriminated unions, and branded ID types in TypeScript. - REST API Patterns: Resource naming conventions, pagination, filtering, partial updates via PATCH, and consistent error response shapes with proper HTTP status codes. - Idempotency Implementation: Correct handling of Idempotency-Key headers, including atomic key claiming via unique constraints, payload guarding, in-flight duplicate strategies, and retention planning. - Use Case: When designing a new tasks API, use this Skill to define the endpoint contracts, error format, pagination scheme, and idempotency behavior before writing any implementation code. ## Quick Start Ask the agent to design a REST API for a new resource, specifying the endpoints, error format, and pagination approach following the api-and-interface-design guidelines.

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 or remove existing field types. Define the contract first with typed input and output schemas, and treat every observable behavior as a commitment under Hyrum's Law.

How to implement idempotency keys for API endpoints?

Accept an Idempotency-Key header from the client and claim it atomically using a database unique constraint, not a check-then-insert. Guard the payload by rejecting the same key with a different request body, and set key retention longer than the longest retry path including dead-letter replays.

Where should input validation happen in an API?

Validate only 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 rather than re-validating.

Should I use PUT or PATCH for API updates?

Use PATCH for partial updates where only provided fields change, which is what clients typically want. PUT requires sending the full object every time and is appropriate only for complete resource replacement.

What are common REST API design mistakes to avoid?

Avoid verbs in URLs like /api/createTask, inconsistent error formats across endpoints, list endpoints without pagination, and using third-party API responses without validation. Also avoid deriving idempotency keys from UUIDs or timestamps regenerated per attempt.