api-design

api-design is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 26 tokens per session (2,508 once invoked), scanned A, original, MIT.

Guidance for designing HTTP and REST interfaces: web endpoints that use standard HTTP methods to create, read, update, and delete resources.

In plain words
What is it for?
Use it when creating or changing endpoints, deciding whether a change is backward-incompatible, connecting frontend and backend work, or reviewing inconsistent API designs.
Why use it?
It helps keep URLs, status codes, versions, and error responses consistent, so clients and monitoring tools can interpret the API correctly.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when creating or changing endpoints, deciding whether a change is backward-incompatible, connecting frontend and backend work, or reviewing inconsistent API designs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/api-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 Wade-DevCode/awesome-coding-skills-cn --skill api-design
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

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-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/api-design/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/api-design)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/api-design"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/api-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-design

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/api-design"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/api-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,508 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.00026 $0.02508
Opus 5.5 $0.00010 $0.01003
Sonnet 5.5 $0.00005 $0.00502
Haiku 4.5 $0.00003 $0.00251

Measured 1mo ago against content hash 2ab6a1d119f5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

api-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 1mo 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-design/SKILL.md · 187 lines

How it starts

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

接口设计

何时用

  • 新增 HTTP/REST 接口,需要确定 URL 路径、请求体与响应结构时。
  • 修改已有接口,要评估是否属于破坏性变更、是否需要新版本时。
  • 联调阶段前端反馈"不知道错误含义"或"状态码对不上"时。
  • code review 发现接口风格混乱,需要统一约定时。

核心规则

1. 资源用名词复数,HTTP 方法表达动作

规则: URL 只描述资源,增删改查全靠 HTTP 方法(GET/POST/PUT/PATCH/DELETE)区分,禁止在路径里塞动词。

为什么: AI 生成代码时极容易把动作写进路径——POST /createUser、GET /getUserById、POST /deleteOrder。这样做破坏了 REST 的统一接口约束:客户端无法通过方法推断语义,反向代理的缓存/日志规则也按 HTTP 方法设计,动词 URL 会绕开这些设施。积累下来接口命名五花八门,新人一眼看不懂哪个是幂等的、哪个有副作用。

怎么做:

  • 集合资源用复数:/users、/orders、/products/{id}/reviews。
  • 子资源层级不超过三级:/users/{uid}/addresses/{aid} 可接受,再深就拍平。
  • 真正的「动作」(非 CRUD)用子资源或 action 后缀:POST /orders/{id}/cancel 或 POST /payments/{id}/refund,不要 POST /cancelOrder。

2. 状态码严格对应语义

规则: 按 HTTP 语义选状态码:2xx 成功、4xx 客户端的错、5xx 服务端的错;不用"一律 200 + { "code": 500 } "的私有协议。

为什么: AI 生成的服务端代码极常见"全部返回 200,用 body 里的 code 表示真实状态"——看起来简单,实则让所有上层基础设施失效:Nginx 的 5xx 告警触发不了,监控平台抓不到真实错误率,HTTP 客户端的重试/熔断逻辑按 2xx 判定成功而放行所有故障流量。出了事故查日志,全是绿的。

怎么做:

  • 200 成功返回资源,201 创建成功(带 Location 头),204 成功但无响应体(DELETE)。
  • 400 请求格式/参数错误,401 未认证,403 无权限(已认证但拒绝),404 资源不存在,409 冲突(重复创建),422 业务校验失败。
  • 500 服务内部错误,502/503 上游/服务不可用,504 超时。
  • 不要用 200 返回错误信息,也不要用 500 返回校验失败。

3. 错误响应结构统一,前端可程序化处理

规则: 所有错误响应用相同结构:code(机器可读的错误标识)、message(人类可读说明)、details(可选,字段级明细),不能每个接口各自为政。

为什么: AI 最容易犯的错是:有的接口报错返回 {"error": "invalid email"},有的返回 {"msg": "用户不存在"},有的直接丢出框架的原始异常 JSON。前端被迫为每个接口写专属错误解析逻辑,错误提示文案散落各处。哪天要做统一的错误埋点或国际化,根本没有抓手。

怎么做:

{
  "code": "VALIDATION_ERROR",
  "message": "请求参数不合法",
  "details": [
    { "field": "email", "message": "邮箱格式不正确" },
    { "field": "age",   "message": "年龄必须大于 0" }
  ]
}
  • code 用 SCREAMING_SNAKE_CASE 枚举值,前端可 switch/map 处理。
  • message 面向开发者,不直接作为用户提示(i18n 由前端按 code 查表)。
  • details 仅在有字段级信息时出现,表单校验必带。

4. 破坏性变更走版本号

规则: 接口路径加 /v1、/v2 前缀;不兼容的改动新开版本,旧版本保留至少一个过渡期,不在原路径上直接覆盖。

为什么: AI 修改接口时惯于"直接改字段名"或"删除旧字段"——测试环境跑通了,但已上线的移动端 App、第三方集成、还没发版的前端全部一起炸。破坏性变更无声地推出去,只有故障告警才会被发现,而此时回滚服务端又会打烂已经发版的新客户端。

Read the full file on GitHub · 187 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. 1mo ago First seen · 187 lines · 26 tokens per session scan A 2ab6a1d119f5

Subscribe to this mod's changes

api-design is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 4mo ago), licensed MIT. It adds 26 tokens to every session and 2,508 once invoked, about $0.0001 per session on Opus 5.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-31.

Related

Other skills, from other repositories

api-integration-architect

Design, implement, debug, and optimize API integrations with expert-level patterns for REST, GraphQL, webhooks, and authentication flows.

lingxling/awesome-skills-cn · 33 tokens

fastapi

Use when building, reviewing, testing, securing or shipping a FastAPI / async Python service — routers, Pydantic v2 schemas, dependency injection, async SQLAlchemy 2.0, OAuth2/JWT, ASGITransport tests, production wiring. NOT language-level Python or packaging (that is python), NOT engine-level SQL (that is…

ericrisco/rsc-harness · 94 tokens

api-design-expert

Expert-level API design principles, REST, GraphQL, versioning, and API best practices. Use when the user mentions REST, GraphQL, API versioning, or API security, or when the task involves API Design Principles, API Styles, or Documentation.

personamanagmentlayer/pcl · 57 tokens

api-endpoint-builder-v2

API Endpoint Builder workflow skill. Use this skill when the user needs Builds production-ready REST API endpoints with validation, error handling, authentication, and documentation. Follows best practices for security and scalability and the operator should preserve the upstream workflow, copied support files, and…

diegosouzapw/awesome-omni-skills · 66 tokens

api-design-principles-v2

API Design Principles workflow skill. Use this skill when the user needs Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers and stand the test of time and the operator should preserve the upstream workflow, copied support files, and provenance…

diegosouzapw/awesome-omni-skills · 69 tokens

api-patterns-v2

API Patterns workflow skill. Use this skill when the user needs API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.

diegosouzapw/awesome-omni-skills · 62 tokens