Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

api-designAPI 设计

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

259

周安装

11

GitHub Stars

35

下载量

91
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:api-design(API 设计)
来源仓库:https://github.com/kazdenc/builder-skills
仓库路径:skills/api-design
安装命令:
npx skills add https://github.com/kazdenc/builder-skills --skill api-design
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/kazdenc/builder-skills --skill api-design

简介

api-design 用于辅助 API 设计、接口文档和请求响应结构梳理。

  • 适合生成 OpenAPI 草稿、检查字段命名或整理错误码等场景。
  • 使用时需确认真实业务语义、鉴权方式和错误处理规则。
  • 涉及生成接口文档时应避免凭空补字段,优先从现有代码提取事实。
  • 通过 npx skills add 命令从 GitHub 仓库安装,需结合原始 README 确认具体用法。

SKILL.md

API Design

Apply these conventions when designing, reviewing, or implementing RESTful APIs. Consistency matters more than cleverness — follow the patterns below.

URL Structure

Use nouns for resources, not verbs. Resources are things, not actions.

RuleCorrectIncorrect
Plural nouns/users, /orders/user, /getOrders
Nouns, not verbsPOST /usersPOST /createUser
Kebab-case for multi-word/line-items/lineItems, /line_items
Nest for relationships (max 2 levels)/users/:id/orders/users/:id/orders/:orderId/items/:itemId
Flat when parent is obvious/orders/:orderId/items/users/:userId/orders/:orderId/items

Query Parameters

Use query parameters for filtering, sorting, searching, and pagination. Never encode these in the URL path.

GET /users?status=active&sort=-created_at&limit=20&cursor=abc123
GET /orders?user_id=42&min_total=100&fields=id,status,total
ParameterConventionExample
FilterField name as key?status=active&role=admin
SortField name, prefix - for descending?sort=-created_at,name
Searchq parameter?q=john
Field selectionfields comma-separated?fields=id,name,email
Paginationcursor or offset/limit?cursor=abc&limit=20

HTTP Methods

MethodPurposeIdempotentRequest BodySuccess CodeResponse Body
GETRetrieve resource(s)YesNo200Resource or collection
POSTCreate a new resourceNoYes201Created resource
PUTReplace a resource entirelyYesYes200Updated resource
PATCHPartially update a resourceNo*Yes200Updated resource
DELETERemove a resourceYesNo204No body

*PATCH is not inherently idempotent but can be implemented as such. Treat it as non-idempotent by default.

Key rules:

  • GET must never mutate state. Ever.
  • PUT replaces the entire resource — omitted fields are removed or reset to defaults.
  • PATCH updates only the fields included in the body.
  • POST to a collection creates a new resource. Return the created resource with its id.
  • DELETE should succeed silently if the resource is already gone (idempotent).

Status Codes

Use the most specific appropriate code. Don't return 200 for everything.

2xx — Success

CodeMeaningUse When
200 OKRequest succeededGET, PUT, PATCH success
201 CreatedResource createdPOST success — include Location header
204 No ContentSuccess, no bodyDELETE success, or PUT/PATCH when no body is needed

4xx — Client Error

CodeMeaningUse When
400 Bad RequestMalformed requestInvalid JSON, missing required fields, validation failures
401 UnauthorizedNot authenticatedMissing or invalid authentication token
403 ForbiddenAuthenticated but not allowedUser lacks permission for this action
404 Not FoundResource doesn't existID not found, or route doesn't exist
405 Method Not AllowedWrong HTTP methodPOST to a read-only resource
409 ConflictState conflictDuplicate creation, version mismatch
422 Unprocessable EntitySemantic validation failureValid JSON, but business rules violated
429 Too Many RequestsRate limit exceededInclude Retry-After header

5xx — Server Error

CodeMeaningUse When
500 Internal Server ErrorUnexpected failureUnhandled exception — log it, don't leak details
502 Bad GatewayUpstream failureA dependency returned an invalid response
503 Service UnavailableTemporarily downMaintenance or overload — include Retry-After

Error Format

Return errors in a consistent shape. Every error response uses this structure:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request body failed validation.",
    "details": [
      { "field": "email", "message": "Must be a valid email address." },
      { "field": "age", "message": "Must be at least 18." }
    ]
  }
}
FieldTypeRequiredDescription
error.codestringYesMachine-readable error code (UPPER_SNAKE_CASE)
error.messagestringYesHuman-readable summary
error.details`array \object`NoField-level errors, additional context

Rules:

  • Always return the same top-level {error: {...}} shape for all error responses.
  • Use code for programmatic handling (clients switch on it), message for display.
  • Never expose stack traces, internal paths, or database errors in production.
  • Include a request_id in error responses (or top-level meta) for debugging.

Pagination

Cursor-Based (Preferred)

Use cursor-based pagination by default. It handles inserts/deletes gracefully and scales to large datasets.

Request:

GET /users?limit=20&cursor=eyJpZCI6MTAwfQ

Response:

{
  "data": [ { "id": 101, "name": "Ada" }, { "id": 102, "name": "Bob" } ],
  "pagination": {
    "next_cursor": "eyJpZCI6MTAyfQ",
    "has_more": true
  }
}
FieldDescription
next_cursorOpaque string — encode whatever your DB needs (usually last ID)
has_moreBoolean — tells client whether to fetch again

Offset-Based (When Needed)

Use offset pagination only when users need to jump to arbitrary pages (admin tables, search results).

Request:

GET /users?offset=40&limit=20

Response:

{
  "data": [ { "id": 41, "name": "Ada" } ],
  "pagination": {
    "offset": 40,
    "limit": 20,
    "total": 523
  }
}

Warning: Offset pagination degrades on large datasets (DB must skip offset rows). Never use for infinite scroll.

Authentication

Bearer Tokens (Preferred for User Auth)

Pass tokens in the Authorization header:

Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
  • Use short-lived access tokens (15 min–1 hr) with refresh tokens.
  • Validate tokens on every request. Don't cache validation results.
  • Return 401 for missing/expired tokens, 403 for insufficient permissions.

API Keys (For Server-to-Server)

Pass API keys in a custom header or as a query parameter (header preferred):

X-API-Key: sk_live_abc123def456
AspectRecommendation
Where to sendX-API-Key header (preferred) or Authorization: ApiKey <key>
Key formatPrefix with environment: sk_live_, sk_test_
StorageHash keys server-side, never store plaintext
RotationSupport multiple active keys for zero-downtime rotation

When to Use Each

ScenarioAuth Method
Browser/mobile app user sessionsBearer token (OAuth 2.0 / JWT)
Server-to-server integrationAPI key
Third-party developer accessOAuth 2.0 with scopes
Internal microservicesmTLS or signed JWTs

Versioning

URL Versioning (Preferred)

Prefix major versions in the URL path:

GET /v1/users
GET /v2/users
  • Version only when you introduce breaking changes.
  • Run old versions in parallel during migration. Set a sunset date and communicate it.
  • Non-breaking additions (new optional fields, new endpoints) do not require a version bump.

Header Versioning (Alternative)

Accept: application/vnd.myapi.v2+json

Use header versioning when URL versioning creates routing complexity or you need fine-grained version control. URL versioning is simpler for most cases.

What Counts as a Breaking Change

BreakingNot Breaking
Removing a field from a responseAdding a new optional field to a response
Renaming a fieldAdding a new endpoint
Changing a field's typeAdding a new optional query parameter
Removing an endpointAdding a new enum value (if clients handle unknown)
Making an optional field requiredImproving error messages

Rate Limiting

Include rate-limit headers in every response so clients can self-regulate:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 742
X-RateLimit-Reset: 1702483200
HeaderDescription
X-RateLimit-LimitMax requests allowed in the window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets

When the limit is exceeded, return:

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests. Retry after 30 seconds.",
    "details": {
      "retry_after": 30
    }
  }
}

Return 429 Too Many Requests with a Retry-After header (in seconds).

Anti-Patterns

Avoid these. When you see them in a codebase, flag or refactor.

Anti-PatternProblemDo Instead
Verbs in URLs/getUsers, /deleteOrderUse HTTP methods: GET /users, DELETE /orders/:id
Deep nesting (3+ levels)/users/:id/orders/:oid/items/:iid/reviewsFlatten: /order-items/:iid/reviews
200 for errorsClient can't distinguish success from failure by statusUse appropriate 4xx/5xx codes
GET for mutationsBreaks caching, prefetching, crawlersUse POST, PUT, PATCH, DELETE
Plural/singular inconsistency/user/1 but /ordersAlways use plural: /users/1, /orders
Returning arrays at rootVulnerable to JSON hijacking, can't add metadataWrap in {"data": [...]}
Leaking internal errorsStack traces, SQL errors in responsesReturn generic message, log details server-side
Ignoring Accept headersClient can't negotiate content typeRespect Accept or return 406
Custom status codesClients won't understand themStick to standard HTTP status codes
Inconsistent error shapesSome errors return {message}, others {error}Use one error shape everywhere

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.29%
按下载量换算32

Claude

30.16%
按下载量换算27

Cursor

19.21%
按下载量换算17

Gemini CLI

9.17%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills