api-and-interface-design

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

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/jampissarandev/Expense-Tracker --skill api-and-interface-design-jampissarandev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/jampissarandev/Expense-Tracker/tree/main/.github/skills/api-and-interface-design
Command: npx skills add https://github.com/jampissarandev/Expense-Tracker --skill api-and-interface-design-jampissarandev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed interfaces create breaking changes, inconsistent error handling, and hidden coupling that break consumers. This Skill provides concrete principles and patterns for designing APIs and module boundaries that are hard to misuse and safe to evolve. ## Core Features & Use Cases - Contract-First Design: Define typed interfaces before implementation, with input/output separation, branded ID types, and discriminated unions for variants. - Consistent Error Semantics: Standardized error shapes with machine-readable codes and HTTP status mapping (400/401/403/404/409/422/500). - Boundary Validation: Validate external input at API edges and treat third-party responses as untrusted, while trusting internal typed code. - Use Case: When adding a new REST endpoint to an expense tracker backend, use this Skill to define the typed contract, pagination scheme, PATCH semantics, and error format before writing any handler code. ## Quick Start Use the api-and-interface-design skill to review my planned REST endpoints for the transactions resource and check them against the design checklist.

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 existing field types or remove fields. Use plural-noun resource URLs, PATCH for partial updates, and paginate all list endpoints from the start.

What is the best way to structure API error responses?

Use one consistent error shape everywhere: a machine-readable code, a human-readable message, and optional details. Map errors to standard HTTP status codes like 400, 401, 403, 404, 409, 422, and 500, and never mix patterns across endpoints.

Where should input validation happen in an API?

Validate 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 instead of re-validating.

Should I validate third-party API responses before using them?

Yes. Third-party responses are untrusted data and must be validated for shape and content before use in logic or rendering. A compromised or misbehaving external service can return unexpected types or malicious content.

When should I use PATCH instead of PUT for updates?

Use PATCH when clients should send only the fields they want to change. PUT requires the full object on every request, which is rarely what clients want and increases the risk of accidentally overwriting fields.

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 somebody, regardless of the documented contract. It means every public behavior is a commitment, so avoid leaking implementation details and plan for deprecation at design time.