api-and-interface-design

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Public interfaces become hard to change once consumers depend on them, and inconsistent error handling, missing pagination, or unsafe retries create breaking changes and duplicate side effects. This Skill guides the design of stable APIs and module boundaries so contracts are defined before implementation and extended without breaking consumers. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, discriminated unions, and branded ID types before writing implementation code. - Consistent Error Semantics: Apply a single structured error format with correct HTTP status codes across all endpoints. - Idempotency Key Handling: Implement atomic key claiming via unique constraints, payload guards, and retention policies that outlive retry chains. - Use Case: When adding a new payments endpoint, use this Skill to define the request/response contract, choose PATCH semantics for partial updates, add pagination to list endpoints, and honour Idempotency-Key headers so client retries never double-charge. ## Quick Start Ask the AI to design a REST API for a new resource following the api-and-interface-design guidelines, including typed contracts, error format, pagination, 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 such as plural nouns for endpoints and camelCase for fields.

How to implement idempotency keys for payment or state-changing endpoints?▼

Accept an Idempotency-Key header derived from the client's intent, then claim it atomically using a database unique constraint rather than a check-then-insert. Reject the same key with a different payload, and set key retention longer than the longest possible retry path including dead-letter replays.

Should I use PUT or PATCH for updating resources in a REST API?▼

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 is appropriate only for complete resource replacement.

Where should input validation happen in an API architecture?▼

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

Why is a check-then-insert pattern unsafe for idempotency handling?▼

A SELECT followed by an INSERT is a time-of-check-to-time-of-use race: two concurrent retries can both read 'not seen' and both execute the side effect. The unique constraint must be the mechanism, claimed in a single atomic insert operation.

When should I avoid versioning an API and extend it instead?▼

Prefer the One-Version Rule: extend interfaces additively rather than maintaining parallel versions, which multiply maintenance cost and create diamond dependency problems. Version only when a genuinely breaking change is unavoidable, and plan deprecation at design time.