api-and-interface-design

Guides design of stable REST APIs, TypeScript interfaces, and module contracts.

2|Updated Jul 1, 2026
One-click install
npx skills add https://github.com/Lazare-Panam/mars-api --skill api-and-interface-design-lazare-panam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/Lazare-Panam/mars-api/tree/main/Mars.API/.claude/skills/api-and-interface-design
Command: npx skills add https://github.com/Lazare-Panam/mars-api --skill api-and-interface-design-lazare-panam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing public interfaces that break consumers is a common source of production incidents. This Skill provides a structured checklist and principles for creating APIs and module boundaries that are consistent, backward-compatible, and hard to misuse. ## Core Features & Use Cases - Contract-First Design: Define typed input/output schemas, consistent error semantics, and boundary validation before implementation. - Idempotency Guidance: Covers atomic key claiming, payload guarding, in-flight duplicate handling, and retention windows for safe retries. - REST & TypeScript Patterns: Provides conventions for resource naming, pagination, filtering, PATCH semantics, discriminated unions, and branded ID types. - Use Case: When adding a new endpoint like POST /api/tasks, use this Skill to verify the endpoint has typed schemas, consistent error format, pagination on list routes, and an idempotency strategy before shipping. ## Quick Start Ask the AI to review your new REST endpoint design against the API and interface design checklist before implementing it.

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 extend interfaces only by adding optional fields. 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 POST endpoints?

Accept a client-generated Idempotency-Key and claim it atomically using a database unique constraint, not a check-then-insert. Reject the same key with a different payload, decide how in-flight duplicates are handled (409, wait, or 202), and retain keys longer than the longest retry path.

Where should input validation happen in an API?

Validation belongs 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 updating resources?

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 better reserved for complete resource replacement.

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

Hyrum's Law states that all observable behaviors of a system will be depended on by someone, regardless of the documented contract. This means undocumented quirks, error text, and ordering become de facto commitments, so be intentional about everything you expose.

When should I not add versioning to an API?

Prefer the One-Version Rule: extend rather than fork, since multiple versions multiply maintenance cost and create diamond dependency problems. Design for additive, backward-compatible changes from the start instead of planning parallel versions.