api-design

api-design is a skill for Claude Code, Codex from xu-xiang/everything-claude-code-zh. It costs 34 tokens per session (3,866 once invoked), scanned A, original, MIT.

Guidance for designing REST APIs, which are web interfaces that let programs access and change data through HTTP requests.

In plain words
What is it for?
Use it when creating or reviewing endpoints, adding pagination, filtering, or sorting, handling errors, publishing an API, or planning versions and rate limits.
Why use it?
It reduces inconsistent URLs, incorrect status codes, unclear errors, and other contract problems that make APIs harder to use and maintain.

Skill for Claude CodeCodex

Part of the everything-claude-code-zh plugin — 17 skills, 26 commands, 13 agents shipped together

About the project

everything-claude-code-zh is a Chinese translation of a collection of configurations for Claude Code and other AI coding agents. It provides agents, skills, hooks, commands, rules, and MCP configurations intended to support development workflows such as memory persistence, security scanning, evaluation, and research-first work. The catalogue includes commands, skills, agents, instructions, and a plugin from this configuration set.

xu-xiang/everything-claude-code-zh · 1,929 stars · on GitHub · oneskill.one

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.

agentmods
npx agentmods add skills/xu-xiang/everything-claude-code-zh/api-design
Any agent
npx skills add xu-xiang/everything-claude-code-zh --skill api-design
Clone the repo
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh

Made for: Claude Code, Codex.

Or install everything-claude-code-zh, the plugin that ships this one along with the rest of its 17 skills, 26 commands, 13 agents.

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/xu-xiang/everything-claude-code-zh/api-design.svg)](https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/api-design)
Your own site
<a href="https://agentmods.dev/skills/xu-xiang/everything-claude-code-zh/api-design"><img src="https://agentmods.dev/badge/skills/xu-xiang/everything-claude-code-zh/api-design.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,866 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00034 $0.03866
Opus 5 $0.00017 $0.01933
Sonnet 5 $0.00007 $0.00773
Haiku 4.5 $0.00003 $0.00387

Measured 6d ago against content hash 06b029abfdab, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, 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 6d 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.

.agents/skills/api-design/SKILL.md · 524 lines

How it starts

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

API 设计模式(API Design Patterns)

用于设计一致且开发者友好的 REST API 的约定与最佳实践。

何时激活(When to Activate)

  • 设计新的 API 端点(Endpoint)
  • 审查现有的 API 合约
  • 添加分页、过滤或排序功能
  • 为 API 实现错误处理
  • 规划 API 版本化策略
  • 构建公开或面向合作伙伴的 API

资源设计(Resource Design)

URL 结构

# 资源应为名词、复数、小写、短横线命名法(kebab-case)
GET    /api/v1/users
GET    /api/v1/users/:id
POST   /api/v1/users
PUT    /api/v1/users/:id
PATCH  /api/v1/users/:id
DELETE /api/v1/users/:id

# 关系的子资源
GET    /api/v1/users/:id/orders
POST   /api/v1/users/:id/orders

# 不符合 CRUD 的操作(谨慎使用动词)
POST   /api/v1/orders/:id/cancel
POST   /api/v1/auth/login
POST   /api/v1/auth/refresh

命名规则

# 推荐(GOOD)
/api/v1/team-members          # 多词资源使用短横线命名法(kebab-case)
/api/v1/orders?status=active  # 使用查询参数进行过滤
/api/v1/users/123/orders      # 嵌套资源表示归属关系

# 错误(BAD)
/api/v1/getUsers              # URL 中包含动词
/api/v1/user                  # 使用单数(应使用复数)
/api/v1/team_members          # URL 中使用蛇形命名法(snake_case)
/api/v1/users/123/getOrders   # 嵌套资源中包含动词

HTTP 方法与状态码(HTTP Methods and Status Codes)

方法语义

方法 幂等性(Idempotent) 安全性(Safe) 用途
GET 获取资源
POST 创建资源,触发操作
PUT 完整替换资源
PATCH 否* 部分更新资源
DELETE 删除资源

*通过正确的实现,PATCH 也可以设计为幂等。

状态码参考

# 成功(Success)
200 OK                    — GET, PUT, PATCH(包含响应体)
201 Created               — POST(需包含 Location 响应头)
204 No Content            — DELETE, PUT(不含响应体)

# 客户端错误(Client Errors)
400 Bad Request           — 校验失败,JSON 格式错误
401 Unauthorized          — 缺失或无效的身份验证
403 Forbidden             — 已验证身份但未获得授权
404 Not Found             — 资源不存在
409 Conflict              — 重复条目,状态冲突
422 Unprocessable Entity  — 语义错误(JSON 正确但数据非法)
429 Too Many Requests     — 超出速率限制

# 服务端错误(Server Errors)
500 Internal Server Error — 意外错误(绝不要暴露详细堆栈)
502 Bad Gateway           — 上游服务失败
503 Service Unavailable   — 暂时性过载,需包含 Retry-After

常见错误

# 错误:所有响应都返回 200
{ "status": 200, "success": false, "error": "Not found" }

# 推荐:语义化地使用 HTTP 状态码
HTTP/1.1 404 Not Found
{ "error": { "code": "not_found", "message": "User not found" } }

# 错误:校验错误返回 500
# 推荐:返回 400 或 422 并提供字段级详情

# 错误:创建资源返回 200
# 推荐:返回 201 并附带 Location 响应头
HTTP/1.1 201 Created
Location: /api/v1/users/abc-123

Read the full file on GitHub · 524 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 6d ago First seen · 524 lines · 34 tokens per session scan A 06b029abfdab

Subscribe to this mod's changes

api-design is a skill published in the GitHub repository xu-xiang/everything-claude-code-zh (1,929 stars, last pushed 6mo ago), licensed MIT. It adds 34 tokens to every session and 3,866 once invoked, about $0.0002 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.