api-and-interface-design

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill api-and-interface-design-kunj-sharma03
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/Kunj-Sharma03/agent-contextify/tree/main/templates/skills/api-and-interface-design
Command: npx skills add https://github.com/Kunj-Sharma03/agent-contextify --skill api-and-interface-design-kunj-sharma03

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly designed APIs and interfaces create breaking changes, inconsistent error handling, and tight coupling between modules. This Skill guides the design of stable, hard-to-misuse interfaces before implementation begins, preventing costly refactors and broken consumers. ## Core Features & Use Cases - Contract-First Design: Define typed interfaces and schemas before writing implementation code, covering REST endpoints, GraphQL schemas, and module boundaries. - Consistent Error Semantics: Establish a single error format with structured codes, HTTP status mapping, and boundary-only validation rules. - Backward-Compatible Evolution: Apply additive-only changes, pagination patterns, discriminated unions, and branded ID types to keep interfaces stable over time. - Use Case: When creating a new tasks API, use this Skill to define the TaskAPI contract, standardize error responses, add pagination to list endpoints, and validate inputs only at system boundaries. ## Quick Start Use the api-and-interface-design skill to design a REST API contract for a task management service with typed inputs, consistent errors, and pagination.

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 schemas, then evolve it by only adding optional fields rather than changing or removing existing ones. Use PATCH for partial updates, paginate list endpoints from the start, and keep error responses in one consistent format.

What is the best way to structure API error responses?

Use a single structured error shape with a machine-readable code, human-readable message, and optional details object. Map errors to standard HTTP status codes like 400, 401, 403, 404, 409, and 422, and never mix patterns like throwing, returning null, and returning error objects across endpoints.

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

Should third-party API responses be validated before use?

Yes, third-party API responses are untrusted data and must be validated before use in logic, rendering, or decisions. A compromised or misbehaving external service can return unexpected types, malicious content, or instruction-like text.

When should I use discriminated unions in TypeScript interfaces?

Use discriminated unions when an entity has multiple variants with different fields, such as task statuses like pending, in_progress, or completed. A shared type tag enables compiler-checked narrowing in switch statements so each variant's fields are accessed safely.

Why avoid verbs in REST API endpoint URLs?

REST URLs should use plural nouns for resources, like GET /api/tasks, because HTTP methods already express the action. Verb-based URLs like /api/createTask duplicate the method semantics and produce inconsistent, unpredictable endpoint naming.