api-and-interface-design

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

Updated Sep 5, 2026
One-click install
npx skills add https://github.com/nntoan/ultra-omp --skill api-and-interface-design-nntoan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/nntoan/ultra-omp/tree/main/packages/proflow/skills/api-and-interface-design
Command: npx skills add https://github.com/nntoan/ultra-omp --skill api-and-interface-design-nntoan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and duplicate side effects that erode consumer trust. This Skill guides the design of stable APIs and module boundaries that are hard to misuse and safe to evolve. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, discriminated unions, and branded ID types before implementation. - Consistent Error Semantics: Enforce a single structured error format with correct HTTP status code mapping across all endpoints. - Idempotency Implementation: Honour Idempotency-Key headers with atomic key claims, payload guards, and correct handling of in-flight duplicates. - Use Case: When adding a payments endpoint, use this Skill to design the endpoint contract, derive a stable idempotency key from the order ID, claim it atomically via a unique constraint, and reject reused keys with mismatched payloads. ## Quick Start Ask the AI to design a REST API for a new resource following the api-and-interface-design guidelines, including pagination, error format, and idempotency handling.

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

Define the contract first with typed input and output schemas, then evolve it by adding optional fields only. Never change existing field types or remove fields, and follow consistent naming conventions like plural nouns for endpoints and camelCase for fields.

How to implement idempotency keys for payment or POST endpoints?▼

Accept an Idempotency-Key header derived from an immutable identifier like an order ID, then claim it atomically with a unique database constraint before executing the side effect. Reject reused keys with different payloads and store the response for safe replay.

Should I use PATCH or PUT for updating resources?▼

Use PATCH for partial updates where only provided fields change, which matches what clients actually need. PUT requires sending the full object every time and increases the risk of accidentally overwriting fields.

Where should input validation happen in an API?▼

Validate only at system boundaries: API route handlers, form submissions, environment variables, and third-party API responses. Internal functions that share type contracts should trust already-validated data rather than re-validating.

Why do duplicate requests happen even with retry logic?▼

Retries spike exactly when dependencies are degraded, and a timeout leaves the outcome unknown. No queue guarantees exactly-once delivery across a consumer crash, so design for at-least-once delivery with idempotent processing.

When should I version an API instead of extending it?▼

Prefer the One-Version Rule: extend interfaces additively rather than forking versions, since multiple versions multiply maintenance cost and create diamond dependency problems. Plan deprecation at design time for anything you must eventually remove.