agentleFS
LIXIAO199115LIXIAO199115/skillrig/skills/api-contract-review/SKILL.md

api-contract-review

Skill0 starsChanged 25 days agoMITView on GitHub

Use when designing or reviewing an HTTP, GraphQL, or gRPC API contract before implementation or release. Covers resource naming, methods and status codes, error shapes, pagination, idempotency, concurrency control, versioning, backward compatibility, auth boundaries, and contract tests. Does not implement the service.

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use cloud-api-recipe-authoring, codebuddy-ide-mcp-upgrade and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • TencentCloudBaseSkill

    cloud-api-recipe-authoring

    Author or revise a cloud-api-operations recipe (config/source/skills/cloud-api-operations/references/recipes/). Encodes why the long tail of control-plane capabilities is deliberately NOT wrapped as MCP/CLI tools, the API-first admission test for whether a capability deserves a recipe, the negative and positive lists, the fixed recipe structure, the writing rules distilled from writing-for-agents, the user-facing copy red lines, and the product regeneration/verification pipeline. Also routes contributors (and their agents) to the contribution flow and the pre-PR self-test protocol in references/contributing.md. Use when adding a recipe, judging whether a scenario belongs in the recipe set, updating the recipes index, re-checking existing recipes against the admission test, or onboarding someone who wants to submit one.

    Also in 3 projects that use this

  • TencentCloudBaseSkill

    codebuddy-ide-mcp-upgrade

    升级 CodeBuddy IDE(genie 扩展)内置的 CloudBase MCP,以及 MCP 发版时同步 IDE 侧白名单。当用户提到「更新 IDE 里的 MCP」「内置 MCP 版本太老」「IDE 集成的 CloudBase 功能不足」「改工具白名单 toolWhiteList」「把新 bundle 打进 CodeBuddy」「白名单漂移」「MCP 发版要同步什么」时使用。覆盖:解包定位内置 bundle 与内嵌配置、重新构建 mcp bundle、生成新的工具白名单与系统提示词、安全注入 IDE 并备份、用 MCP 协议验证工具清单、人工端到端验收、一键回滚。

    Also in 3 projects that use this

  • zaxbysauceSkill

    pr-review-fix

    Codex adapter for addressing pull request review feedback in opencode-swarm. Use when the user asks to fix PR review comments, requested changes, reviewer findings, CI-review notes, or a pasted review summary with low false-positive tolerance.

    Also in 3 projects that use this

  • albertdobmeyerSkill

    git-workflows

    Advanced git operations beyond add/commit/push. Use when rebasing, bisecting bugs, using worktrees for parallel development, recovering with reflog, managing subtrees/submodules, resolving merge conflicts, cherry-picking across branches, or working with monorepos.

    Also in 3 projects that use this

  • ReinaMacCredySkill

    codebase-audit

    Deep codebase audit that first reads project docs (AGENTS.md, README.md) and investigates the architecture, then systematically finds hardcoded constants that should be dynamic and unfinished code (TODOs, "will"/"would" in comments). Use this skill when the user wants a thorough code review for hygiene issues, asks to find hardcoded values, wants to audit for TODOs or incomplete code, says things like "audit this codebase", "find hardcoded stuff", "what's unfinished", "find tech debt", "code hygiene check", or asks you to look across the whole project for issues. Also use when the user asks to understand a project before making changes, or wants a comprehensive health check of their codebase.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    skill-authoring

    Write Agent Skills that comply with the agentskills.io specification. WHEN: "create a skill", "new skill", "write a skill", "skill template", "skill structure", "review skill", "skill PR", "skill compliance", "SKILL.md format", "skill frontmatter", "skill best practices". DO NOT USE FOR: general documentation. INVOKES: vally CLI.

    Also in 5 projects that use this

  • +6 more from TencentCloudBase

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 17 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 17

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 22
  2. Distinctive:

    If the document and the implementation disagree, test the implementation and fix the document in the same change.

    line 40
  3. Distinctive:

    No verbs in the body that duplicate the method.

    line 55
  4. Distinctive:

    No stack traces, SQL, secrets, or internal hostnames.

    line 90
  5. Distinctive:

    Default page size and maximum.

    line 95
  6. Distinctive:

    Document the conflict response and how the client resolves it.

    line 124
  7. Distinctive:

    Every object access checks ownership or tenant, not only authentication.

    line 128
  8. Very specific:

    Check protobuf compatibility (for example, buf breaking).

    line 167
  9. Distinctive:

    Run contract tests against the implementation.

    line 168
  10. Distinctive:

    Verify error responses, not only success.

    line 169
  11. Distinctive:

    Test pagination boundaries and idempotent retries.

    line 170
  12. Distinctive:

    Do not expose internal identifiers or sequential ids when enumeration is a risk.

    line 204
  13. Distinctive:

    Do not return unbounded lists.

    line 205
  14. Very specific:

    Do not use 200 for errors.

    line 206
  15. Distinctive:

    Do not put secrets or tokens in URLs.

    line 207
  16. Distinctive:

    Do not change validation rules without a version or a migration plan.

    line 208
  17. Distinctive:

    Do not add a required field to an existing request.

    line 209
  18. Distinctive:

    Do not reuse a removed protobuf field number or a GraphQL field name with new semantics.

    line 210
  19. Distinctive:

    Do not publish an API without rate limits and a documented error shape.

    line 211

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Contract Review

An API contract is a promise about inputs, outputs, errors, and evolution. The expensive mistakes are rarely syntax. They are ambiguous semantics, unbounded results, missing idempotency, and a breaking change shipped as a patch.

Review the contract before code, then test it against the contract.

When to use

Use this skill when:

  • Designing a new endpoint, mutation, or RPC.
  • Reviewing an OpenAPI, GraphQL, or protobuf change.
  • Adding a field, status code, or parameter to an existing API.
  • Planning a version bump or deprecation.
  • An agent or client needs to integrate with the API.

Workflow

1. Identify the contract source of truth

  • OpenAPI document for REST.
  • GraphQL schema and persisted operations.
  • .proto files and the generated stubs.
  • JSON Schema for event payloads.
  • A human document, which is the weakest source.

If the document and the implementation disagree, test the implementation and fix the document in the same change.

2. Check resource and method semantics

OperationMethodSuccessSafeIdempotent
ListGET200yesyes
ReadGET200yesyes
CreatePOST201 + Locationnono unless keyed
Full replacePUT200/204noyes
Partial updatePATCH200/204nonot guaranteed
DeleteDELETE204/202noyes
  • Nouns in paths, verbs in methods: /orders/{id}, not /getOrder.
  • Plural collections, stable identifiers.
  • No verbs in the body that duplicate the method.
  • POST for actions that do not fit CRUD: /orders/{id}/cancel.
  • HEAD and OPTIONS behave consistently with GET.

3. Check status and error semantics

  • 200 with a body, 204 without.
  • 201 with Location for creation.
  • 400 for malformed syntax, 422 for semantically invalid input when the stack distinguishes them.
  • 401 unauthenticated, 403 authenticated but not allowed.
  • 404 for missing or intentionally hidden resources.
  • 409 for state conflicts.
  • 412 for failed preconditions, 428 when a precondition is required.
  • 429 with retry guidance.
  • 5xx only for server faults.

Error body, preferably RFC 9457 Problem Details:

{
  "type": "https://example.com/problems/insufficient-funds",
  "title": "Insufficient funds",
  "status": 409,
  "detail": "The account balance is 1200 cents; the transfer requires 5000.",
  "instance": "/transfers/01J8Z3",
  "code": "insufficient_funds",
  "traceId": "4f1c..."
}

Rules:

  • One error shape across the API.
  • Machine-readable code stable across versions.
  • Human-readable detail safe to show.
  • No stack traces, SQL, secrets, or internal hostnames.
  • Validation errors identify the field and the rule.

4. Bound every collection

  • Default page size and maximum.
  • Cursor pagination for large or changing sets.
  • Stable sort order with a tiebreaker.
  • Total counts only when cheap, or marked approximate.
  • Filters and sort fields documented and allowlisted.
{
  "data": [],
  "nextCursor": "eyJpZCI6MTIzfQ",
  "hasMore": true
}

Offset pagination is acceptable for small, stable datasets. It skips and duplicates rows when the underlying data changes.

5. Design for retries

  • POST creation accepts an Idempotency-Key.
  • The server stores the key with the result for a documented window.
  • A repeated key returns the original result, not a duplicate.
  • Retries are safe for GET, PUT, DELETE, and keyed POST.
  • Timeouts and retry guidance are in the error body or headers.

6. Handle concurrent updates

  • ETag on reads, If-Match on writes.
  • 412 when the precondition fails.
  • Or a version field in the body with a compare-and-set.
  • Document the conflict response and how the client resolves it.

7. Check authorization boundaries

  • Every object access checks ownership or tenant, not only authentication.
  • List endpoints filter by tenant at the query level.
  • Admin-only fields are not serialized for normal users.
  • Bulk endpoints check every id, not only the first.
  • Errors do not reveal whether another tenant's object exists.

8. Plan evolution

Non-breaking:

  • Adding an optional request field with a safe default.
  • Adding a response field clients must ignore.
  • Adding a new endpoint.
  • Adding an enum value only if clients tolerate unknown values. Document that requirement.
  • Adding an optional header.

Breaking:

  • Removing or renaming a field.
  • Changing a type or format.
  • Making an optional field required.
  • Changing a status code or error shape.
  • Changing default behavior.
  • Tightening validation.
  • Changing pagination or sort semantics.
  • Removing an enum value clients may send.

Versioning options:

  • URI version /v2 for broad, visible breaks.
  • Media type versioning for content negotiation.
  • Additive evolution with a compatibility policy.
  • GraphQL: deprecate fields, never reuse a removed name with different semantics.
  • Protobuf: reserve removed field numbers and names; never reuse them.

9. Test the contract

  • Validate the document (for example, Spectral for OpenAPI).
  • Diff against the previous version (for example, openapi-diff).
  • Check protobuf compatibility (for example, buf breaking).
  • Run contract tests against the implementation.
  • Verify error responses, not only success.
  • Test pagination boundaries and idempotent retries.

Examples

Weak:

POST /api/doOrder
{ "user": 12, "items": "..." }

Problems: verb in the path, ambiguous creation semantics, no idempotency, no error contract.

Stronger:

POST /orders
Idempotency-Key: 8f14e45f-ea3b-4c1a-9d1f-2b7c9a1e5d3f
Content-Type: application/json

{ "items": [{ "sku": "SKU-1", "quantity": 2 }] }
201 Created
Location: /orders/01J8Z3
{ "id": "01J8Z3", "status": "pending", "totalCents": 5000 }

Guardrails

  • Do not expose internal identifiers or sequential ids when enumeration is a risk.
  • Do not return unbounded lists.
  • Do not use 200 for errors.
  • Do not put secrets or tokens in URLs.
  • Do not change validation rules without a version or a migration plan.
  • Do not add a required field to an existing request.
  • Do not reuse a removed protobuf field number or a GraphQL field name with new semantics.
  • Do not publish an API without rate limits and a documented error shape.

Verification checklist

  • Source of truth identified and current.
  • Paths and methods follow the resource model.
  • Success and error status codes documented.
  • One error shape with machine-readable codes.
  • Collections bounded with documented pagination.
  • Retries safe and idempotency documented.
  • Concurrency control defined.
  • Authorization checked per object.
  • Breaking-change diff reviewed.
  • Contract tests cover errors, pagination, and retries.
  • Deprecation policy stated.

References

  • references/api-checklist.md contains an endpoint review sheet and a breaking-change matrix.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.