api-and-interface-design

api-and-interface-design is a skill for Claude Code from vinvcn/addyosmani-agent-skills-zh. It costs 51 tokens per session (2,458 once invoked), scanned A, original, MIT.

Guidance for designing stable, clearly documented interfaces between software parts, such as web APIs, GraphQL schemas, modules, and component properties. It covers defining the contract first, limiting accidental dependencies, and planning safe changes.

In plain words
What is it for?
Use it to create or change API endpoints, define module or team boundaries, design component properties, or shape database structures that affect a public interface.
Why use it?
It helps prevent users or other parts of a system from depending on undocumented behavior. It makes interfaces easier to use correctly and reduces breakage when they evolve.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the agent-skills plugin — 23 skills, 8 commands, 3 agents, 1 hook shipped together

Good fit Use it to create or change API endpoints, define module or team boundaries, design component properties, or shape database structures that affect a public interface.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add vinvcn/addyosmani-agent-skills-zh --skill api-and-interface-design
Clone the repo
git clone --depth 1 https://github.com/vinvcn/addyosmani-agent-skills-zh

Made for: Claude Code.

Or install agent-skills, the plugin that ships this one along with the rest of its 23 skills, 8 commands, 3 agents, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-and-interface-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design/github.svg)](https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design)
Your own site
<a href="https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design"><img src="https://agentmods.dev/badge/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for api-and-interface-design

Your own site · 80×15
<a href="https://agentmods.dev/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design"><img src="https://agentmods.dev/badge/skills/vinvcn/addyosmani-agent-skills-zh/api-and-interface-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,458 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00051 $0.02458
Opus 5 $0.00026 $0.01229
Sonnet 5 $0.00010 $0.00492
Haiku 4.5 $0.00005 $0.00246

Measured 11d ago against content hash 21a40f311c68, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

api-and-interface-design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/api-and-interface-design/SKILL.md · 295 lines

How it starts

The opening of the file, as written. The whole thing — 295 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API 与接口设计

概览

设计稳定、文档清晰且难以误用的接口。好的接口让正确的事情容易做,让错误的事情难做。这适用于 REST API、GraphQL schema、模块边界、组件 props,以及任何一段代码与另一段代码对话的表面。

何时使用

  • 设计新的 API endpoint
  • 定义模块边界或团队之间的契约
  • 创建组件 prop 接口
  • 建立会影响 API 形态的数据库 schema
  • 修改现有公共接口

核心原则

Hyrum's Law

只要 API 用户足够多,系统中所有可观察行为都会被某些人依赖,无论你在契约中承诺了什么。

这意味着:每个公共行为,包括未记录的怪癖、错误消息文本、时序和排序,一旦被用户依赖,就会成为事实契约。设计含义:

  • 有意识地决定暴露什么。 每个可观察行为都是潜在承诺。
  • 不要泄漏实现细节。 如果用户能观察到,他们就会依赖它。
  • 在设计时规划废弃。 如何安全移除用户依赖的内容,见 deprecation-and-migration
  • 测试还不够。 即使有完美的契约测试,Hyrum's Law 也意味着“安全”的改动仍会破坏依赖未记录行为的真实用户。

单版本规则

避免迫使消费者在同一个依赖或 API 的多个版本之间选择。当不同消费者需要同一事物的不同版本时,就会出现 diamond dependency 问题。为一次只存在一个版本的世界设计:扩展,而不是 fork。

1. 契约优先

先定义接口,再实现它。契约就是规格,实现随后而来。

// Define the contract first
interface TaskAPI {
  // Creates a task and returns the created task with server-generated fields
  createTask(input: CreateTaskInput): Promise<Task>;

  // Returns paginated tasks matching filters
  listTasks(params: ListTasksParams): Promise<PaginatedResult<Task>>;

  // Returns a single task or throws NotFoundError
  getTask(id: string): Promise<Task>;

  // Partial update — only provided fields change
  updateTask(id: string, input: UpdateTaskInput): Promise<Task>;

  // Idempotent delete — succeeds even if already deleted
  deleteTask(id: string): Promise<void>;
}

2. 一致的错误语义

选择一种错误策略,并在所有地方使用它:

// REST: HTTP status codes + structured error body
// Every error response follows the same shape
interface APIError {
  error: {
    code: string;        // Machine-readable: "VALIDATION_ERROR"
    message: string;     // Human-readable: "Email is required"
    details?: unknown;   // Additional context when helpful
  };
}

// Status code mapping
// 400 → Client sent invalid data
// 401 → Not authenticated
// 403 → Authenticated but not authorized
// 404 → Resource not found
// 409 → Conflict (duplicate, version mismatch)
// 422 → Validation failed (semantically invalid)
// 500 → Server error (never expose internal details)

Read the full file on GitHub · 295 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 295 lines · 51 tokens per session scan A 21a40f311c68

Subscribe to this mod's changes

api-and-interface-design is a skill published in the GitHub repository vinvcn/addyosmani-agent-skills-zh (31 stars, last pushed 4mo ago), licensed MIT. It adds 51 tokens to every session and 2,458 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

api-and-interface-design

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.

borhen68/SkillEngine · 49 tokens

api-and-interface-design

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.

addyosmani/agent-skills · 49 tokens

test-driven-development

Drives development with tests via Red-Green-Refactor and the Prove-It pattern, with hard rules against weakening assertions or faking green suites. Use when implementing any logic, fixing any bug, or changing any behavior. Triggers on "add a feature", "fix this bug", "write tests", or any task where done must be…

borhen68/SkillEngine · 79 tokens

context-engineering

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

borhen68/SkillEngine · 43 tokens

debugging-and-error-recovery

Guides systematic root-cause debugging with hard rules against guess-fixes and symptom suppression. Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Triggers on "this is broken", "tests are failing", "why doesn't this work", or any error output.

borhen68/SkillEngine · 69 tokens

ai-ops

Guides operational excellence for AI/ML systems in production. Use when deploying models, managing inference infrastructure, monitoring model drift, or maintaining AI-powered features. Use when you need reliable, observable, and governable machine learning systems.

borhen68/SkillEngine · 50 tokens