# API and Interface Design

Designs stable APIs, module boundaries and type contracts before implementation.

- Repository: https://github.com/addyosmani/agent-skills (112533 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add addyosmani/agent-skills --skill api-and-interface-design -g -a claude-code -y`
Codex: `npx skills add addyosmani/agent-skills --skill api-and-interface-design -g -a codex -y`
Cursor: `npx skills add addyosmani/agent-skills --skill api-and-interface-design -g -a cursor -y`
Gemini CLI: `npx skills add addyosmani/agent-skills --skill api-and-interface-design -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add addyosmani/agent-skills`

## Description

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# API and Interface Design

## Overview

Design stable, well-documented interfaces that are hard to misuse. Good interfaces make the right thing easy and the wrong thing hard. This applies to REST APIs, GraphQL schemas, module boundaries, component props, and any surface where one piece of code talks to another.

## When to Use

- Designing new API endpoints
- Defining module boundaries or contracts between teams
- Creating component prop interfaces
- Establishing database schema that informs API shape
- Changing existing public interfaces

## Core Principles

### Hyrum's Law

> With a sufficient number of users of an API, all observable behaviors of your system will be depended on by somebody, regardless of what you promise in the contract.

This means: every public behavior, including undocumented quirks, error message text, timing, and ordering, becomes a de facto contract once users depend on it. Design implications:

- **Be intentional about what you expose.** Every observable behavior is a potential commitment.
- **Don't leak implementation details.** If users can observe it, they will depend on it.
- **Plan for deprecation at design time.** See `deprecation-and-migration` for how to safely remove things users depend on.
- **Tests are not enough.** Even with perfect contract tests, Hyrum's Law means "safe" changes can break real users who depend on undocumented behavior.

### The One-Version Rule

Avoid forcing consumers to choose between multiple versions of the same dependency or API. Diamond dependency problems arise when different consumers need different versions of the same thing. Design for a world where only one version exists at a time, extend rather than fork.

### 1. Contract First

Define the interface before implementing it. The contract is the spec, implementation follows.

The rest: https://github.com/addyosmani/agent-skills/blob/HEAD/skills/api-and-interface-design/SKILL.md
