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

api-designerAPI 设计

Agent Skill

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

总安装

31,107

周安装

772

GitHub Stars

26

下载量

10,783
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/daffy0208/ai-dev-standards --skill 'API Designer'

简介

api-designer 用于辅助设计健壮、可扩展且开发者友好的 API,涵盖接口文档、请求响应结构和集成说明。

  • 适合梳理 endpoint、生成 OpenAPI 草稿、检查字段命名或协助前后端联调。
  • 基于开发者体验优先、演进式设计、安全默认和性能优化四大原则构建 API。
  • 使用时需结合项目现有代码或 schema 提取事实,避免凭空补字段或假设业务语义。
  • 涉及鉴权方式、分页策略和错误处理时,应从真实接口样例中获取准确信息。

SKILL.md

API Designer

Design robust, scalable, and developer-friendly APIs.

Core Principles

1. Developer Experience First

  • Clear, predictable naming conventions
  • Comprehensive documentation
  • Helpful error messages
  • Consistent patterns across endpoints

2. Design for Evolution

  • Versioning strategy from day one
  • Backward compatibility
  • Deprecation process
  • Migration guides for breaking changes

3. Security by Default

  • Authentication and authorization
  • Rate limiting and throttling
  • Input validation and sanitization
  • HTTPS only, no exceptions

4. Performance Matters

  • Efficient queries and indexing
  • Caching strategies
  • Pagination for large datasets
  • Compression (gzip, brotli)

REST API Design

Resource Naming Conventions

✅ Good (Nouns, plural, hierarchical):
GET    /users                  # List all users
GET    /users/123              # Get specific user
POST   /users                  # Create user
PUT    /users/123              # Replace user
PATCH  /users/123              # Update user
DELETE /users/123              # Delete user
GET    /users/123/posts        # User's posts (nested)
GET    /users/123/posts/456    # Specific post

❌ Bad (Verbs, inconsistent, unclear):
GET /getUsers
POST /createUser
GET /user-list
GET /UserData?id=123

HTTP Methods & Semantics

MethodPurposeIdempotentSafeRequest BodyResponse Body
GETRetrieve dataYesYesNoYes
POSTCreate resourceNoNoYesYes (created)
PUTReplace resourceYesNoYesYes (optional)
PATCHPartial updateNoNoYesYes (optional)
DELETERemove resourceYesNoNoNo (204) or Yes

Idempotent: Multiple identical requests have same effect as single request Safe: Request doesn't modify server state

HTTP Status Codes

Success (2xx):

  • 200 OK - Successful GET, PUT, PATCH, DELETE
  • 201 Created - Successful POST, includes Location header
  • 204 No Content - Successful request, no response body (often DELETE)

Client Errors (4xx):

  • 400 Bad Request - Invalid syntax, validation error
  • 401 Unauthorized - Authentication required or failed
  • 403 Forbidden - Authenticated but lacks permission
  • 404 Not Found - Resource doesn't exist
  • 409 Conflict - Request conflicts with current state
  • 422 Unprocessable Entity - Validation error (semantic)
  • 429 Too Many Requests - Rate limit exceeded

Server Errors (5xx):

  • 500 Internal Server Error - Generic server error
  • 502 Bad Gateway - Upstream service error
  • 503 Service Unavailable - Temporary unavailability
  • 504 Gateway Timeout - Upstream timeout

Response Format Standards

Success Response:

{
  "data": {
    "id": "123",
    "type": "user",
    "attributes": {
      "name": "John Doe",
      "email": "john@example.com",
      "created_at": "2025-01-15T10:30:00Z"
    }
  }
}

Error Response:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "details": [
      {
        "field": "email",
        "code": "REQUIRED",
        "message": "Email is required"
      },
      {
        "field": "age",
        "code": "OUT_OF_RANGE",
        "message": "Age must be between 18 and 120"
      }
    ],
    "request_id": "req_abc123",
    "documentation_url": "https://api.example.com/docs/errors/validation"
  }
}

List Response with Pagination:

{
  "data": [...],
  "pagination": {
    "cursor": "eyJpZCI6MTIzfQ==",
    "has_more": true,
    "total_count": 1000
  },
  "links": {
    "next": "/users?cursor=eyJpZCI6MTIzfQ==&limit=20",
    "prev": "/users?cursor=eyJpZCI6MTAwfQ==&limit=20"
  }
}

Pagination Strategies

Cursor-based (Recommended):

GET /users?cursor=abc123&limit=20

Pros: Consistent results, efficient, handles real-time data
Cons: Can't jump to arbitrary page
Use when: Large datasets, real-time data, performance critical

Offset-based:

GET /users?page=1&per_page=20
GET /users?offset=0&limit=20

Pros: Simple, can jump to any page
Cons: Inconsistent with concurrent writes, inefficient at scale
Use when: Small datasets, admin interfaces, simple use cases

Filtering, Sorting, and Search

Filtering:

GET /users?status=active&role=admin&created_after=2025-01-01

Sorting:

GET /users?sort=-created_at,name  # Descending created_at, then ascending name

Search:

GET /users?q=john&fields=name,email  # Search across specified fields

Authentication & Authorization

JWT Bearer Token (Recommended for SPAs):

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Pros: Stateless, includes user claims, works across domains
Cons: Can't revoke until expiry, larger payload

API Keys (for service-to-service):

X-API-Key: sk_live_abc123...

Pros: Simple, easy to rotate, per-service keys
Cons: No user context, must be kept secret

OAuth 2.0 (for third-party access):

Authorization: Bearer access_token

Pros: Delegated auth, scoped permissions, industry standard
Cons: Complex setup, requires OAuth server

Basic Auth (only for internal/admin tools):

Authorization: Basic base64(username:password)

Pros: Simple, built-in to HTTP
Cons: Credentials in every request, must use HTTPS

Rate Limiting

Standard Headers:

X-RateLimit-Limit: 1000          # Max requests per window
X-RateLimit-Remaining: 999       # Requests left
X-RateLimit-Reset: 1640995200    # Unix timestamp when limit resets
Retry-After: 60                  # Seconds to wait (on 429)

Common Strategies:

  • Fixed window: 1000 requests per hour
  • Sliding window: 1000 requests per rolling hour
  • Token bucket: Burst allowance with refill rate
  • Per-user, per-IP, or per-API-key limits

Versioning Strategies

URL Versioning (Recommended):

/v1/users
/v2/users

Pros: Explicit, easy to route, clear in logs
Cons: URL pollution, harder to evolve incrementally

Header Versioning:

Accept: application/vnd.myapp.v2+json
API-Version: 2

Pros: Clean URLs, follows REST principles
Cons: Less visible, harder to test in browser

Best Practices:

  • Start with v1, not v0
  • Only increment for breaking changes
  • Support N and N-1 versions simultaneously
  • Provide migration guides
  • Announce deprecation 6-12 months ahead

GraphQL API Design

Schema Design

type User {
  id: ID!
  name: String!
  email: String!
  posts(first: Int, after: String): PostConnection!
  createdAt: DateTime!
}

type PostConnection {
  edges: [PostEdge!]!
  pageInfo: PageInfo!
}

type PostEdge {
  node: Post!
  cursor: String!
}

type PageInfo {
  hasNextPage: Boolean!
  endCursor: String
}

type Query {
  user(id: ID!): User
  users(first: Int, after: String): UserConnection!
}

type Mutation {
  createUser(input: CreateUserInput!): CreateUserPayload!
  updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
}

input CreateUserInput {
  name: String!
  email: String!
}

type CreateUserPayload {
  user: User
  errors: [Error!]
}

GraphQL Best Practices

1. Use Relay Connection Pattern for Pagination:

query {
  users(first: 10, after: "cursor") {
    edges {
      node {
        id
        name
      }
      cursor
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

2. Input Types for Mutations:

# ✅ Good: Input type + payload
mutation {
  createUser(input: { name: "John", email: "john@example.com" }) {
    user {
      id
      name
    }
    errors {
      field
      message
    }
  }
}

# ❌ Bad: Flat arguments
mutation {
  createUser(name: "John", email: "john@example.com") {
    id
    name
  }
}

3. Error Handling:

type Mutation {
  createUser(input: CreateUserInput!): CreateUserPayload!
}

type CreateUserPayload {
  user: User # Null if errors
  errors: [Error!] # Field-level errors
}

type Error {
  field: String!
  code: String!
  message: String!
}

REST vs GraphQL Decision

Use REST when:

  • Simple CRUD operations
  • Caching is critical (HTTP caching)
  • Public API for third-parties
  • File uploads/downloads
  • Team unfamiliar with GraphQL

Use GraphQL when:

  • Clients need flexible queries
  • Reducing over-fetching/under-fetching
  • Rapid frontend iteration
  • Complex nested data relationships
  • Strong typing and schema benefits

API Documentation

OpenAPI/Swagger Specification

openapi: 3.0.0
info:
  title: User Management API
  version: 1.0.0
  description: API for managing users and posts
servers:
  - url: https://api.example.com/v1
paths:
  /users:
    get:
      summary: List users
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
        - name: per_page
          in: query
          schema:
            type: integer
            default: 20
            maximum: 100
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      summary: Create user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserInput'
      responses:
        '201':
          description: User created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        email:
          type: string
          format: email
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

Documentation Best Practices

  • ✅ Include request/response examples
  • ✅ Document all error codes
  • ✅ Provide authentication guides
  • ✅ Interactive API playground (Swagger UI, GraphQL Playground)
  • ✅ Code examples in multiple languages
  • ✅ Rate limit information
  • ✅ Changelog for API updates

Security Checklist

  • HTTPS only (redirect HTTP → HTTPS)
  • Authentication required for protected endpoints
  • Authorization checks (user can only access own data)
  • Input validation (schema validation, sanitization)
  • Rate limiting per user/IP
  • CORS configuration (whitelist origins)
  • SQL injection prevention (parameterized queries)
  • No sensitive data in URLs (use headers/body)
  • Audit logging for sensitive operations
  • API keys rotatable and revocable

Related Resources

Related Skills:

  • frontend-builder - For consuming APIs from frontend
  • deployment-advisor - For API hosting decisions
  • performance-optimizer - For API performance tuning

Related Patterns:

  • META/DECISION-FRAMEWORK.md - REST vs GraphQL decisions
  • STANDARDS/architecture-patterns/api-gateway-pattern.md - API gateway architecture (when created)

Related Playbooks:

  • PLAYBOOKS/deploy-api.md - API deployment procedure (when created)
  • PLAYBOOKS/version-api.md - API versioning workflow (when created)

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

OpenCode

28.38%
按下载量换算3,060

Claude Code

22.25%
按下载量换算2,399

Gemini CLI

19.17%
按下载量换算2,067

Antigravity

13.62%
按下载量换算1,469

Codex

7.72%
按下载量换算832

Cursor

3.03%
按下载量换算327

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源字段存在多来源差异,先按来源优先级自动处理,无法消解时进入异常复核队列。

来源信息

继续浏览同类 Skills