跳到正文
cccskills
免费在 GitHub 公开

api-conventions

REST API design conventions for this codebase. Use when writing or reviewing API endpoints, route definitions, response formatting, or client code that calls the API.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md4.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

These conventions apply to every API endpoint in this codebase. Follow them exactly. If a new situation requires deviation, document the reason in a code comment.

URL structure

Pattern: /api/v{major}/{resource}

  • Resource names are plural nouns in kebab-case: /api/v1/users, /api/v1/billing-accounts
  • Nested resources use path segments: /api/v1/users/{id}/sessions
  • Do not use verbs in URLs: use /api/v1/users/{id} with DELETE, not /api/v1/delete-user/{id}
  • Query parameters are kebab-case: ?page-size=20&sort-by=created-at

HTTP methods

MethodMeaningSuccess status
GETRetrieve resource(s), no side effects200
POSTCreate a new resource201
PUTReplace a resource entirely200
PATCHPartially update a resource200
DELETEDelete a resource204 (no body)

Use GET for all read operations. Do not use POST for reads.

Response envelope

All successful responses (except 204) use this envelope:

{
  "data": <resource or array of resources>,
  "meta": {
    "timestamp": "<ISO 8601 UTC>",
    "version": "<API minor version string, e.g. 1.4>"
  }
}

For list responses, meta also includes pagination fields:

{
  "data": [...],
  "meta": {
    "timestamp": "2024-11-01T14:30:00Z",
    "version": "1.4",
    "next_cursor": "<opaque cursor string or null>",
    "limit": 20,
    "count": 20
  }
}

count is the number of items in the current page, not the total across all pages. Do not include a total count unless explicitly required, as it forces an expensive COUNT query.

Error format

All error responses use this envelope:

{
  "error": {
    "code": "SNAKE_CASE_ERROR_CODE",
    "message": "Human-readable description safe for end users.",
    "details": {}
  }
}
  • code is a stable machine-readable identifier in SCREAMING_SNAKE_CASE
  • message is safe for end users — do not include stack traces, SQL, or internal paths
  • details carries structured field-level information for validation errors:
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "One or more fields failed validation.",
    "details": {
      "fields": [
        { "field": "email", "message": "Must be a valid email address." },
        { "field": "birth_date", "message": "Must be in the past." }
      ]
    }
  }
}

Status codes

CodeUse
200Successful GET, PUT, PATCH
201Successful POST (resource created)
204Successful DELETE (no body)
400Malformed request (bad JSON, wrong content-type)
401Not authenticated — missing or invalid token
403Authenticated but not authorized for this resource
404Resource not found
409Conflict — resource already exists, optimistic lock conflict
422Validation failed — request is well-formed but semantically invalid
429Rate limited — include Retry-After header
500Unexpected server error
503Service temporarily unavailable — include Retry-After header

Do not use 400 for validation errors — use 422. Do not use 500 for expected error cases that have a more specific code.

Authentication

All protected endpoints require a Bearer token in the Authorization header:

Authorization: Bearer <token>

The token is validated by the auth middleware before the handler runs. Handlers do not validate tokens directly. If the middleware passes, request.user (or the framework equivalent) is populated with the authenticated user's identity.

Pagination

Use cursor-based pagination, not offset-based.

Request parameters:

  • cursor: opaque cursor string from the previous page's next_cursor (absent on first page)
  • limit: number of items to return, default 20, maximum 100

Response meta fields:

  • next_cursor: cursor to pass for the next page, or null if this is the last page
  • limit: the limit used for this page
  • count: number of items returned in this page

Do not expose integer offsets or page numbers in the public API.

Versioning

  • Major version in the URL path: /api/v1/, /api/v2/
  • Minor version in the response header: X-API-Version: 1.4
  • Breaking changes require a new major version
  • Additive changes (new fields, new endpoints) increment the minor version
  • Deprecated fields are kept for at least two minor versions before removal

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Write an Architecture Decision Record (ADR) document for a technical decision. Use when documenting a technical choice, architectural decision, or design decision.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

Automatically format code files after every edit using Prettier and ESLint. Active in the background whenever Claude edits a file. Formatting is silent — no prompts, no output unless a formatter fails. Use when you want consistent formatting enforced automatically during a coding session.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

Create a git branch named after a GitHub issue.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

Draft the changelog entry for all unreleased commits in Keep a Changelog format. Groups commits into Added, Changed, Fixed, Removed, and Security. Use before releasing a new version or when updating CHANGELOG.md.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

Draft a CHANGELOG.md entry for the current changes in Keep a Changelog format. Use when releasing, tagging a version, or updating CHANGELOG.md.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

Run a comprehensive code quality audit covering security, performance, and maintainability. Use for quarterly audits, pre-release reviews, or when onboarding to a large codebase.

中文简介正在准备中。当前显示原文说明。

davila7/claude-with-skills132026年5月15日 更新

查看 davila7 的全部技能

报告此技能的问题