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

api-design-opsAPI 设计 OPS

Agent Skill

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

总安装

275

周安装

11

GitHub Stars

17

下载量

89
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/0xdarkmatter/claude-mods --skill api-design-ops

简介

整合 REST、gRPC 和 GraphQL 的高级设计模式与生产级实践。

  • 包含版本控制、认证授权、限流熔断等企业级功能设计。
  • 通过决策树帮助用户根据业务需求选择合适的 API 风格。
  • 适用于中大型系统微服务化过程中的 API 治理与标准化。
  • api-design-ops 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

API Design Ops

Comprehensive API design patterns covering REST (advanced), gRPC, and GraphQL. This skill provides decision frameworks, design patterns, and implementation guidance for building production APIs.

API Style Decision Tree

What kind of API do you need?
|
+-- Internal microservice-to-microservice?
|   +-- High throughput, low latency needed? --> gRPC
|   +-- Streaming (real-time data, logs)? --> gRPC (bidirectional streaming)
|   +-- Simple request/response, team comfort? --> REST
|
+-- Public-facing API?
|   +-- Third-party developers consuming it? --> REST (widest compatibility)
|   +-- Mobile app with varied data needs? --> GraphQL
|   +-- Browser-only, simple CRUD? --> REST
|
+-- Frontend for your own app?
|   +-- Multiple clients with different data shapes? --> GraphQL
|   +-- Single client, straightforward data? --> REST
|   +-- Real-time updates needed? --> GraphQL subscriptions or SSE
|
+-- IoT / embedded / constrained devices?
|   +-- Binary efficiency matters? --> gRPC
|   +-- HTTP-only environments? --> REST

Quick Comparison

ConcernRESTgRPCGraphQL
TransportHTTP/1.1+HTTP/2HTTP (any)
SerializationJSON (text)Protobuf (binary)JSON (text)
SchemaOpenAPI (optional).proto (required)SDL (required)
Browser supportNativeVia gRPC-Web/ConnectNative
CachingHTTP caching built-inCustomCustom (normalized)
Learning curveLowMediumMedium-High
Code generationOptionalRequiredOptional but recommended
StreamingSSE, WebSocketNative (4 patterns)Subscriptions
Over-fetchingCommon problemNo (typed)Solved by design
File uploadsMultipart nativeChunked streamingMultipart spec (awkward)

REST Resource Design Quick Reference

Resource Naming

GET    /users                  # Collection
GET    /users/{id}             # Singleton
GET    /users/{id}/orders      # Sub-collection
POST   /users                  # Create
PUT    /users/{id}             # Full replace
PATCH  /users/{id}             # Partial update
DELETE /users/{id}             # Remove

# Naming rules:
# - Plural nouns for collections: /users NOT /user
# - Kebab-case for multi-word: /line-items NOT /lineItems
# - No verbs in URLs: POST /orders NOT POST /create-order
# - Max 3 levels deep: /users/{id}/orders (not /users/{id}/orders/{oid}/items/{iid}/details)

HTTP Methods and Status Codes

MethodSuccessEmptyInvalidNot FoundConflict
GET200200 (empty array)400404-
POST201 + Location-400/422-409
PUT200-400/422404409
PATCH200-400/422404409
DELETE204204 (already gone)400404409

HATEOAS (When Worth It)

Use when: public APIs where discoverability matters, long-lived APIs, APIs that evolve frequently. Skip when: internal microservices, mobile backends, tight coupling is acceptable.

{
  "id": "order-123",
  "status": "shipped",
  "_links": {
    "self": { "href": "/orders/order-123" },
    "track": { "href": "/orders/order-123/tracking" },
    "cancel": { "href": "/orders/order-123", "method": "DELETE" }
  }
}

Pagination Decision Tree

What's your data like?
|
+-- Stable data, UI needs "jump to page 5"?
|   --> Offset pagination: ?page=5&per_page=20
|   Tradeoff: Slow on large offsets (OFFSET 10000), inconsistent with inserts
|
+-- Large dataset, forward-only traversal?
|   --> Cursor pagination: ?after=eyJpZCI6MTIzfQ&limit=20
|   Tradeoff: No random page access, but consistent and fast
|
+-- Real-time feed, ordered by timestamp or ID?
|   --> Keyset pagination: ?created_after=2024-01-01T00:00:00Z&limit=20
|   Tradeoff: Requires a unique, sequential column; no page jumping

Response Envelope

{
  "data": [...],
  "pagination": {
    "total": 1432,
    "limit": 20,
    "has_more": true,
    "next_cursor": "eyJpZCI6MTQzMn0="
  }
}

Error Response Format (RFC 7807)

All APIs should use Problem Details (RFC 7807 / RFC 9457):

{
  "type": "https://api.example.com/errors/insufficient-funds",
  "title": "Insufficient Funds",
  "status": 422,
  "detail": "Account xxxx-1234 has a balance of $10.00, but the transfer requires $25.00.",
  "instance": "/transfers/txn-abc-123",
  "balance": 1000,
  "required": 2500
}

Field Reference

FieldRequiredDescription
typeYesURI identifying the error type (stable, documentable)
titleYesHuman-readable summary (same for all instances of this type)
statusYesHTTP status code
detailYesHuman-readable explanation specific to this occurrence
instanceNoURI identifying the specific occurrence
(extensions)NoAdditional machine-readable fields

Validation Errors

{
  "type": "https://api.example.com/errors/validation",
  "title": "Validation Failed",
  "status": 422,
  "detail": "The request body contains 2 validation errors.",
  "errors": [
    { "field": "email", "message": "Must be a valid email address", "code": "invalid_format" },
    { "field": "age", "message": "Must be at least 18", "code": "out_of_range", "min": 18 }
  ]
}

Versioning Strategies

StrategyExampleProsCons
URL path/v2/usersObvious, cacheable, easy routingURL pollution, hard to sunset
Accept headerAccept: application/vnd.api.v2+jsonClean URLs, content negotiationHidden, harder to test
Query param/users?version=2Easy to addPollutes query string, caching issues
Date-basedAPI-Version: 2024-01-15Granular evolution (Stripe style)Complex implementation

Recommendation

  • Public APIs: URL path versioning (/v1/) - simplicity wins
  • Internal APIs: Header or no versioning (deploy in lockstep)
  • Evolving APIs: Date-based (Stripe model) if you have the engineering investment

Breaking Change Rules

A breaking change is anything that can cause existing clients to fail:

  • Removing a field from a response
  • Renaming a field
  • Changing a field's type
  • Adding a required field to a request
  • Changing URL structure
  • Changing error formats
  • Removing an endpoint

Non-breaking (safe):

  • Adding optional fields to requests
  • Adding fields to responses
  • Adding new endpoints
  • Adding new enum values (if client handles unknown values)

Rate Limiting Design

Algorithms

AlgorithmBehaviorUse When
Token bucketAllows bursts, refills at steady rateGeneral API rate limiting
Sliding windowSmooth distribution, no burstStrict fairness needed
Fixed windowSimple, potential burst at boundaryLow-stakes limiting
Leaky bucketConstant output rateQueue processing

Response Headers

X-RateLimit-Limit: 1000          # Max requests per window
X-RateLimit-Remaining: 743       # Requests left in current window
X-RateLimit-Reset: 1672531200    # Unix timestamp when window resets
Retry-After: 30                  # Seconds to wait (on 429)

429 Response Body

{
  "type": "https://api.example.com/errors/rate-limit-exceeded",
  "title": "Rate Limit Exceeded",
  "status": 429,
  "detail": "You have exceeded 1000 requests per hour. Try again in 30 seconds.",
  "retry_after": 30
}

Idempotency

Which Methods Need Idempotency Keys?

MethodIdempotent by spec?Needs key?
GETYesNo
PUTYesNo (full replacement is naturally idempotent)
DELETEYesNo
PATCHNoRecommended for critical operations
POSTNoYes (always for payments, orders, transfers)

Implementation

POST /payments
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
Content-Type: application/json

{ "amount": 2500, "currency": "usd", "customer": "cust_123" }

Server-side:

  1. Receive request with Idempotency-Key header
  2. Check if key exists in store (Redis, DB)
  3. If exists: return stored response (same status code + body)
  4. If not: process request, store response keyed by idempotency key
  5. Keys expire after 24-48 hours

Authentication Overview

MethodUse WhenSecurity Level
API KeyServer-to-server, internal, simpleLow-Medium
JWT (Bearer)Stateless auth, microservicesMedium-High
OAuth2 + PKCEThird-party access, user delegationHigh
mTLSService mesh, zero-trust infraVery High

Decision Guide

Who is authenticating?
|
+-- Your own frontend? --> JWT (short-lived access + refresh token)
+-- Third-party developer? --> OAuth2 (client credentials for server, PKCE for SPA)
+-- Another internal service? --> mTLS or JWT with service accounts
+-- Quick prototype? --> API key (but plan migration)

Gotchas Table

GotchaProblemPrevention
Breaking changes in "non-breaking" releaseClient crashesAdditive-only policy, contract tests
N+1 in REST APIs100 users = 101 queriesCompound documents, ?include=, or GraphQL
Over-fetchingMobile gets 50 fields, needs 3Sparse fieldsets ?fields=id,name or GraphQL
Under-fetching3 requests to build one viewComposite endpoints or BFF pattern
CORS misconfigurationFrontend can't reach APIExplicit allowed origins, never * with credentials
Missing Content-Type415 or silent parsing failureValidate Content-Type on every mutation endpoint
Large payloads without paginationOOM, timeoutsAlways paginate collections, set max page size
Inconsistent date formatsParsing hellISO 8601 everywhere: 2024-01-15T10:30:00Z
No request IDsImpossible to debugGenerate X-Request-ID, propagate through services
Enum evolutionNew value breaks old clientDocument that enums may grow, clients must handle unknown
Missing idempotencyDuplicate charges, ordersIdempotency keys on all POST endpoints with side effects
Unbounded query complexityGraphQL DoSDepth limiting, cost analysis, persisted queries

Reference Files

FileContents
references/rest-advanced.mdResource modeling, PATCH strategies, caching, webhooks, bulk ops
references/grpc.mdProtobuf, service definitions, Go/Rust, streaming, error handling
references/graphql.mdSchema design, resolvers, DataLoader, federation, performance
references/api-security.mdJWT, OAuth2, CORS, rate limiting, OWASP API Top 10

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

37.78%
按下载量换算34

Claude

31.05%
按下载量换算28

Cursor

18.21%
按下载量换算16

Gemini CLI

9.4%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

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

安装前确认

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

来源信息

继续浏览同类 Skills