api-design by yonatangross/orchestkit
npx skills add https://github.com/yonatangross/orchestkit --skill api-design涵盖 REST/GraphQL 框架设计、版本控制策略和 RFC 9457 错误处理的全面 API 设计模式。每个类别在 rules/ 目录下都有独立的规则文件,按需加载。
| 类别 | 规则数 | 影响程度 | 何时使用 |
|---|---|---|---|
| API 框架 | 3 | 高 | REST 约定、资源建模、OpenAPI 规范 |
| 版本控制 | 3 | 高 | URL 路径版本控制、请求头版本控制、弃用/终止策略 |
| 错误处理 | 4 | 高 | RFC 9457 问题详情、面向代理的错误、验证错误、错误类型注册表 |
| GraphQL | 2 | 高 | Strawberry 代码优先、DataLoader、权限、订阅 |
| gRPC | 2 | 高 | Protobuf 服务、流式传输、拦截器、重试 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 流式传输 | 2 | 高 | SSE 端点、WebSocket 双向通信、异步生成器 |
| 集成 | 2 | 高 | 消息平台(WhatsApp、Telegram)、Payload CMS 模式 |
总计:7 个类别,共 18 条规则
用于构建一致、对开发者友好的 API 的 REST 和 GraphQL API 设计约定。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| REST 约定 | rules/framework-rest-conventions.md | 复数名词、HTTP 方法、状态码、分页 |
| 资源建模 | rules/framework-resource-modeling.md | 分层 URL、过滤、排序、字段选择 |
| OpenAPI | rules/framework-openapi.md | OpenAPI 3.1 规范、文档、模式定义 |
在不破坏客户端的前提下进行 API 演进的策略。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| URL 路径 | rules/versioning-url-path.md | /api/v1/ 前缀路由、版本特定模式 |
| 请求头 | rules/versioning-header.md | X-API-Version 请求头、内容协商 |
| 弃用 | rules/versioning-deprecation.md | 终止请求头、生命周期管理、破坏性变更策略 |
用于机器可读、标准化错误响应的 RFC 9457 问题详情。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 问题详情 | rules/errors-problem-details.md | RFC 9457 模式、application/problem+json、异常类 |
| 面向代理的错误 | rules/errors-agent-facing.md | 代理扩展:retryable、error_category、内容协商、令牌效率 |
| 验证 | rules/errors-validation.md | 字段级错误、Pydantic 集成、422 响应 |
| 错误目录 | rules/errors-error-catalog.md | 问题类型注册表、错误类型 URI、客户端处理 |
具有类型安全解析器和 FastAPI 集成的 Strawberry GraphQL 代码优先模式。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 模式设计 | rules/graphql-strawberry.md | 类型安全模式、DataLoader、联合错误、私有字段 |
| 模式与认证 | rules/graphql-schema.md | 权限类、FastAPI 集成、订阅 |
用于内部微服务通信的高性能 gRPC。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 服务定义 | rules/grpc-service.md | Protobuf、异步服务器、客户端超时、代码生成 |
| 流式传输与拦截器 | rules/grpc-streaming.md | 服务器/双向流式传输、认证、重试退避 |
使用 SSE、WebSocket 和适当清理的实时数据流式传输。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| SSE | rules/streaming-sse.md | SSE 端点、LLM 流式传输、重连、保活 |
| WebSocket | rules/streaming-websocket.md | 双向通信、心跳、aclosing()、背压 |
消息平台集成和无头 CMS 模式。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 消息平台 | rules/messaging-integrations.md | WhatsApp WAHA、Telegram Bot API、Webhook 安全性 |
| Payload CMS | rules/payload-cms.md | Payload 3.0 集合、访问控制、CMS 选择 |
# REST endpoint with versioning and RFC 9457 errors
from fastapi import APIRouter, Depends, Request
from fastapi.responses import JSONResponse
router = APIRouter()
@router.get("/api/v1/users/{user_id}")
async def get_user(user_id: str, service: UserService = Depends()):
user = await service.get_user(user_id)
if not user:
raise NotFoundProblem(
resource="User",
resource_id=user_id,
)
return UserResponseV1(id=user.id, name=user.full_name)
| 决策 | 建议 |
|---|---|
| 版本控制策略 | 公共 API 使用 URL 路径(/api/v1/) |
| 资源命名 | 复数名词,短横线命名法 |
| 分页 | 大型数据集使用基于游标的分页 |
| 错误格式 | 使用 application/problem+json 的 RFC 9457 问题详情 |
| 错误类型 URI | 您的 API 域名 + /problems/ 前缀 |
| 支持窗口 | 当前版本 + 前 1 个版本 |
| 弃用通知 | 终止前至少 3 个月 |
| 终止期 | 弃用后 6 个月 |
| GraphQL 模式 | 使用 Strawberry 类型的代码优先模式 |
| N+1 问题预防 | 所有嵌套解析器使用 DataLoader |
| GraphQL 认证 | 权限类(基于上下文) |
| gRPC proto | 每个文件一个服务,共享 common.proto |
| gRPC 流式传输 | 列表使用服务器流,实时通信使用双向流 |
| SSE 保活 | 每 30 秒一次 |
| WebSocket 心跳 | 每 30 秒 ping-pong 一次 |
| 异步生成器清理 | 所有外部资源使用 aclosing() |
POST /createUser 而不是 POST /users)Content-Type: application/problem+json查看 test-cases.json 了解所有类别的 9 个测试用例。
fastapi-advanced - FastAPI 特定的实现模式rate-limiting - 高级速率限制实现和算法observability-monitoring - 版本使用指标和错误跟踪input-validation - API 错误处理之外的验证模式streaming-api-patterns - 实时 API 的 SSE 和 WebSocket 模式关键词: rest, restful, http, endpoint, route, path, resource, CRUD 解决的问题:
关键词: graphql, schema, query, mutation, connection, relay 解决的问题:
关键词: endpoint, route, path, resource, CRUD, openapi 解决的问题:
关键词: url version, path version, /v1/, /v2/ 解决的问题:
关键词: header version, X-API-Version, content negotiation 解决的问题:
关键词: deprecation, sunset, version lifecycle, backward compatible 解决的问题:
关键词: problem details, RFC 9457, RFC 7807, structured error, application/problem+json 解决的问题:
关键词: agent error, AI agent, retryable, retry_after, error_category, content negotiation, accept header, token efficient, machine readable 解决的问题:
关键词: validation, field error, 422, unprocessable, pydantic 解决的问题:
关键词: error registry, problem types, error catalog, error codes 解决的问题:
每周安装量
92
代码仓库
GitHub 星标数
142
首次出现
2026年2月14日
安全审计
安装于
gemini-cli86
github-copilot86
codex85
opencode85
cursor84
kimi-cli81
Comprehensive API design patterns covering REST/GraphQL framework design, versioning strategies, and RFC 9457 error handling. Each category has individual rule files in rules/ loaded on-demand.
| Category | Rules | Impact | When to Use |
|---|---|---|---|
| API Framework | 3 | HIGH | REST conventions, resource modeling, OpenAPI specifications |
| Versioning | 3 | HIGH | URL path versioning, header versioning, deprecation/sunset policies |
| Error Handling | 4 | HIGH | RFC 9457 Problem Details, agent-facing errors, validation errors, error type registries |
| GraphQL | 2 | HIGH | Strawberry code-first, DataLoader, permissions, subscriptions |
| gRPC | 2 | HIGH | Protobuf services, streaming, interceptors, retry |
| Streaming | 2 | HIGH | SSE endpoints, WebSocket bidirectional, async generators |
| Integrations | 2 | HIGH | Messaging platforms (WhatsApp, Telegram), Payload CMS patterns |
Total: 18 rules across 7 categories
REST and GraphQL API design conventions for consistent, developer-friendly APIs.
| Rule | File | Key Pattern |
|---|---|---|
| REST Conventions | rules/framework-rest-conventions.md | Plural nouns, HTTP methods, status codes, pagination |
| Resource Modeling | rules/framework-resource-modeling.md | Hierarchical URLs, filtering, sorting, field selection |
| OpenAPI | rules/framework-openapi.md | OpenAPI 3.1 specs, documentation, schema definitions |
Strategies for API evolution without breaking clients.
| Rule | File | Key Pattern |
|---|---|---|
| URL Path | rules/versioning-url-path.md | /api/v1/ prefix routing, version-specific schemas |
| Header | rules/versioning-header.md | X-API-Version header, content negotiation |
| Deprecation | rules/versioning-deprecation.md | Sunset headers, lifecycle management, breaking change policy |
RFC 9457 Problem Details for machine-readable, standardized error responses.
| Rule | File | Key Pattern |
|---|---|---|
| Problem Details | rules/errors-problem-details.md | RFC 9457 schema, application/problem+json, exception classes |
| Agent-Facing Errors | rules/errors-agent-facing.md | Agent extensions: retryable, error_category, content negotiation, token efficiency |
| Validation | rules/errors-validation.md | Field-level errors, Pydantic integration, 422 responses |
Strawberry GraphQL code-first schema with type-safe resolvers and FastAPI integration.
| Rule | File | Key Pattern |
|---|---|---|
| Schema Design | rules/graphql-strawberry.md | Type-safe schema, DataLoader, union errors, Private fields |
| Patterns & Auth | rules/graphql-schema.md | Permission classes, FastAPI integration, subscriptions |
High-performance gRPC for internal microservice communication.
| Rule | File | Key Pattern |
|---|---|---|
| Service Definition | rules/grpc-service.md | Protobuf, async server, client timeout, code generation |
| Streaming & Interceptors | rules/grpc-streaming.md | Server/bidirectional streaming, auth, retry backoff |
Real-time data streaming with SSE, WebSockets, and proper cleanup.
| Rule | File | Key Pattern |
|---|---|---|
| SSE | rules/streaming-sse.md | SSE endpoints, LLM streaming, reconnection, keepalive |
| WebSocket | rules/streaming-websocket.md | Bidirectional, heartbeat, aclosing(), backpressure |
Messaging platform integrations and headless CMS patterns.
| Rule | File | Key Pattern |
|---|---|---|
| Messaging Platforms | rules/messaging-integrations.md | WhatsApp WAHA, Telegram Bot API, webhook security |
| Payload CMS | rules/payload-cms.md | Payload 3.0 collections, access control, CMS selection |
# REST endpoint with versioning and RFC 9457 errors
from fastapi import APIRouter, Depends, Request
from fastapi.responses import JSONResponse
router = APIRouter()
@router.get("/api/v1/users/{user_id}")
async def get_user(user_id: str, service: UserService = Depends()):
user = await service.get_user(user_id)
if not user:
raise NotFoundProblem(
resource="User",
resource_id=user_id,
)
return UserResponseV1(id=user.id, name=user.full_name)
| Decision | Recommendation |
|---|---|
| Versioning strategy | URL path (/api/v1/) for public APIs |
| Resource naming | Plural nouns, kebab-case |
| Pagination | Cursor-based for large datasets |
| Error format | RFC 9457 Problem Details with application/problem+json |
| Error type URI | Your API domain + /problems/ prefix |
| Support window | Current + 1 previous version |
| Deprecation notice | 3 months minimum before sunset |
| Sunset period | 6 months after deprecation |
| GraphQL schema | Code-first with Strawberry types |
POST /createUser instead of POST /users)Content-Type: application/problem+json on error responsesSee test-cases.json for 9 test cases across all categories.
fastapi-advanced - FastAPI-specific implementation patternsrate-limiting - Advanced rate limiting implementations and algorithmsobservability-monitoring - Version usage metrics and error trackinginput-validation - Validation patterns beyond API error handlingstreaming-api-patterns - SSE and WebSocket patterns for real-time APIsKeywords: rest, restful, http, endpoint, route, path, resource, CRUD Solves:
Keywords: graphql, schema, query, mutation, connection, relay Solves:
Keywords: endpoint, route, path, resource, CRUD, openapi Solves:
Keywords: url version, path version, /v1/, /v2/ Solves:
Keywords: header version, X-API-Version, content negotiation Solves:
Keywords: deprecation, sunset, version lifecycle, backward compatible Solves:
Keywords: problem details, RFC 9457, RFC 7807, structured error, application/problem+json Solves:
Keywords: agent error, AI agent, retryable, retry_after, error_category, content negotiation, accept header, token efficient, machine readable Solves:
Keywords: validation, field error, 422, unprocessable, pydantic Solves:
Keywords: error registry, problem types, error catalog, error codes Solves:
Weekly Installs
92
Repository
GitHub Stars
142
First Seen
Feb 14, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
gemini-cli86
github-copilot86
codex85
opencode85
cursor84
kimi-cli81
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
166,500 周安装
| Error Catalog | rules/errors-error-catalog.md | Problem type registry, error type URIs, client handling |
| N+1 prevention |
| DataLoader for all nested resolvers |
| GraphQL auth | Permission classes (context-based) |
| gRPC proto | One service per file, shared common.proto |
| gRPC streaming | Server stream for lists, bidirectional for real-time |
| SSE keepalive | Every 30 seconds |
| WebSocket heartbeat | ping-pong every 30 seconds |
| Async generator cleanup | aclosing() for all external resources |