api-design

📁 davincidreams/agent-team-plugins 📅 14 days ago
2
总安装量
2
周安装量
#70384
全站排名
安装命令
npx skills add https://github.com/davincidreams/agent-team-plugins --skill api-design

Agent 安装分布

opencode 2
gemini-cli 2
antigravity 2
claude-code 2
github-copilot 2
codex 2

Skill 文档

API Design Guidelines

REST Conventions

  • Use plural nouns for resources: /users, /posts, /comments
  • Use HTTP methods correctly: GET (read), POST (create), PUT (replace), PATCH (update), DELETE (remove)
  • Nest sub-resources: /users/:id/posts
  • Use query params for filtering: /posts?status=published&author=123
  • Return proper status codes: 200, 201, 204, 400, 401, 403, 404, 409, 422, 500

Response Shape

{
  "data": {},
  "error": null,
  "meta": { "page": 1, "total": 42 }
}

Error Response

{
  "data": null,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Human-readable message",
    "details": [{ "field": "email", "message": "Invalid format" }]
  }
}

Input Validation

  • Validate all input at the API boundary
  • Return 422 with field-level error details for validation failures
  • Sanitize strings to prevent injection
  • Enforce size limits on all inputs

Authentication

  • Use the project’s existing auth mechanism
  • Apply auth middleware at the router level
  • Return 401 for missing/invalid credentials
  • Return 403 for insufficient permissions

Versioning

  • Follow the project’s existing versioning strategy
  • If none exists, prefer URL path versioning: /api/v1/resource