api-designer by charon-fan/agent-playbook
npx skills add https://github.com/charon-fan/agent-playbook --skill api-designer精通设计健壮、可扩展且可维护的 REST 和 GraphQL API。
在以下情况时激活:
良好示例:
GET /users # 列出用户
POST /users # 创建用户
GET /users/{id} # 获取特定用户
PATCH /users/{id} # 更新用户
DELETE /users/{id} # 删除用户
应避免:
POST /getUsers # 应为 GET
POST /users/create # 冗余
GET /users/get/{id} # 冗余
| 方法 | 安全 | 幂等 | 用途 |
|---|---|---|---|
| GET | ✓ | ✓ |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 读取资源 |
| POST | ✗ | ✗ | 创建资源 |
| PUT | ✗ | ✓ | 替换资源 |
| PATCH | ✗ | ✗ | 更新资源 |
| DELETE | ✗ | ✓ | 删除资源 |
| 状态码 | 含义 | 用途 |
|---|---|---|
| 200 | OK | 成功的 GET、PATCH、DELETE |
| 201 | Created | 成功的 POST |
| 204 | No Content | 成功的 DELETE(无响应体) |
| 400 | Bad Request | 无效输入 |
| 401 | Unauthorized | 缺少或无效的身份验证 |
| 403 | Forbidden | 已认证但未授权 |
| 404 | Not Found | 资源不存在 |
| 409 | Conflict | 资源已存在 |
| 422 | Unprocessable | 语法有效但语义错误 |
| 429 | Too Many Requests | 超出速率限制 |
| 500 | Internal Server Error | 服务器错误 |
/user-preferences){"userId": "123"})?page_size=10)GET /users?page=1&page_size=20
响应:
{
"data": [...],
"pagination": {
"page": 1,
"page_size": 20,
"total": 100,
"total_pages": 5
}
}
GET /users?status=active&sort=-created_at,name
# -created_at = 降序
# name = 升序
type Query {
user(id: ID!): User
users(limit: Int, offset: Int): UserConnection!
}
type Mutation {
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
}
type User {
id: ID!
email: String!
profile: Profile
posts(first: Int, after: String): PostConnection!
}
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
}
type UserEdge {
node: User!
cursor: String!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
URL 版本控制(推荐):
/api/v1/users
/api/v2/users
请求头版本控制:
GET /users
Accept: application/vnd.myapi.v2+json
Authorization: Bearer <token>
X-API-Key: <key>
Authorization: Bearer <access_token>
HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1631234567
推荐限制:
生成 API 脚手架:
python scripts/generate_api.py <resource-name>
验证 API 设计:
python scripts/validate_api.py openapi.yaml
references/rest-patterns.md - REST 设计模式references/graphql-patterns.md - GraphQL 设计模式每周安装次数
55
代码仓库
GitHub 星标数
11
首次出现
2026年1月22日
安全审计
安装于
gemini-cli48
codex47
cursor46
opencode46
github-copilot43
amp42
Expert in designing REST and GraphQL APIs that are robust, scalable, and maintainable.
Activates when you:
Good:
GET /users # List users
POST /users # Create user
GET /users/{id} # Get specific user
PATCH /users/{id} # Update user
DELETE /users/{id} # Delete user
Avoid:
POST /getUsers # Should be GET
POST /users/create # Redundant
GET /users/get/{id} # Redundant
| Method | Safe | Idempotent | Purpose |
|---|---|---|---|
| GET | ✓ | ✓ | Read resource |
| POST | ✗ | ✗ | Create resource |
| PUT | ✗ | ✓ | Replace resource |
| PATCH | ✗ | ✗ | Update resource |
| DELETE | ✗ | ✓ | Delete resource |
| Code | Meaning | Usage |
|---|---|---|
| 200 | OK | Successful GET, PATCH, DELETE |
| 201 | Created | Successful POST |
| 204 | No Content | Successful DELETE with no body |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Missing or invalid auth |
| 403 | Forbidden | Authenticated but not authorized |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Resource already exists |
| 422 | Unprocessable | Valid syntax but semantic errors |
| 429 | Too Many Requests |
/user-preferences){"userId": "123"})?page_size=10)GET /users?page=1&page_size=20
Response:
{
"data": [...],
"pagination": {
"page": 1,
"page_size": 20,
"total": 100,
"total_pages": 5
}
}
GET /users?status=active&sort=-created_at,name
# -created_at = descending
# name = ascending
type Query {
user(id: ID!): User
users(limit: Int, offset: Int): UserConnection!
}
type Mutation {
createUser(input: CreateUserInput!): CreateUserPayload!
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
}
type User {
id: ID!
email: String!
profile: Profile
posts(first: Int, after: String): PostConnection!
}
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
}
type UserEdge {
node: User!
cursor: String!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
URL Versioning (Recommended):
/api/v1/users
/api/v2/users
Header Versioning :
GET /users
Accept: application/vnd.myapi.v2+json
Authorization: Bearer <token>
X-API-Key: <key>
Authorization: Bearer <access_token>
HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1631234567
Recommended limits:
Generate API scaffold:
python scripts/generate_api.py <resource-name>
Validate API design:
python scripts/validate_api.py openapi.yaml
references/rest-patterns.md - REST design patternsreferences/graphql-patterns.md - GraphQL design patternsWeekly Installs
55
Repository
GitHub Stars
11
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
gemini-cli48
codex47
cursor46
opencode46
github-copilot43
amp42
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
157,400 周安装
GitHub Copilot AI模型推荐工具:根据任务复杂度自动选择最佳AI模型
7,700 周安装
Google Workspace CLI 项目经理角色技能 - 自动化项目协调与任务管理工具
7,800 周安装
winapp-cli:Windows应用开发命令行工具 - MSIX打包、SDK管理、商店发布
7,800 周安装
GitHub Copilot 技能推荐工具 - 自动分析仓库并推荐相关AI技能
7,800 周安装
结构化自主实施代理 - 精准执行GitHub Copilot实施计划,确保代码变更零偏差
7,700 周安装
GitHub Issues管理助手 - 智能筛选分配给我的问题,提升开发效率
7,700 周安装
| Rate limit exceeded |
| 500 | Internal Server Error | Server error |