api-and-interface-design

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

Updated Mar 14, 2026
One-click install
npx skills add https://github.com/yourlabpt/yourlabpt_website --skill api-and-interface-design-yourlabpt
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/yourlabpt/yourlabpt_website/tree/main/projects/skills/api-and-interface-design
Command: npx skills add https://github.com/yourlabpt/yourlabpt_website --skill api-and-interface-design-yourlabpt

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: Standardize HTTP status codes and structured error bodies across all endpoints. - Idempotency Implementation: Honour Idempotency-Key headers with atomic claims, payload guards, and correct in-flight duplicate handling. - Use Case: When designing a new payments endpoint, use this Skill to define the REST resource shape, pagination strategy, validation boundaries, and an idempotency-key scheme that survives retries and dead-letter replays. ## Quick Start Use the api-and-interface-design skill to review my new REST endpoint design for breaking changes, error consistency, and idempotency safety.

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 a client-generated Idempotency-Key and claim it atomically using a database unique constraint, not a check-then-insert. Store the request hash to reject reused keys with different payloads, and set key retention longer than the longest retry path including dead-letter replays.

Should I use PATCH or PUT for updating resources?▼

Use PATCH for partial updates where only provided fields change, which is what clients typically need. PUT requires sending the full object every time and risks overwriting fields the client did not intend to modify.

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 exactly-once queues?▼

No queue guarantees exactly-once delivery across a consumer crash, since the broker acknowledgment and your side effect are not in one transaction. Design for at-least-once delivery with idempotent processing, since retries spike exactly when dependencies degrade.