agentleFS
dennisrongodennisrongo/claude-skills/skills/api-contract-review/SKILL.md

api-contract-review

Skill1 starsChanged 3 months agoMITView on GitHub

Review an API's contract as a promise to consumers — detects breaking changes by diffing the before/after surface (removed/renamed fields, type changes, tightened requiredness, status-code changes), and judges design by the repo's OWN precedent (error envelope, naming, pagination, auth placement) with every consistency finding citing the in-repo convention being violated. Covers versioning, idempotency on retryable writes, pagination on collections, and status-code semantics. Use this skill whenever the user says "review this API", "review the endpoint", "API design review", "is this a breaking change", "check backward compatibility", "review the contract", "review this OpenAPI/swagger spec", or "/api-contract-review" — even if they don't name the skill. Distinct from code-review (implementation quality); this reviews the SURFACE consumers depend on.

11 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

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not auto-trigger for internal function signatures or module interfaces (that's code-review / improve-codebase-architecture territory) — …

    line 16

“Common” is measured: kept by at least 6 in 10 of the 11 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 made to code you can't see and can't fix. This skill reviews the promise, not the implementation: what a consumer can observe — paths, methods, fields, types, requiredness, status codes, error shapes, headers, ordering and pagination semantics — and whether this change keeps, extends, or breaks it. Two evidence rules do the work: breaking requires a before/after diff of a consumer-visible element, and inconsistent requires a citation of the in-repo precedent being violated.

When to use this skill

  • The user says "review this API", "API design review", "is this a breaking change", "check backward compat", "review the contract", "review this OpenAPI spec", "/api-contract-review".
  • A new endpoint, GraphQL type, gRPC service, webhook payload, or event schema is being added or changed.
  • plan-and-build is designing an endpoint and the contract deserves its own pass before implementation.

Do not auto-trigger for internal function signatures or module interfaces (that's code-review / improve-codebase-architecture territory) — this skill is for surfaces crossed by consumers who deploy independently: HTTP APIs, published events, webhooks, SDK-facing types.

Workflow

  1. Establish the before and the after. For a change: the old contract is git show of the previous handler/spec/DTO, the new one is the working tree — read both; a breaking-change verdict without the before-state in hand is a hypothesis. Uncommitted change: the before is git show HEAD:<path>. Committed branch work: git show $(git merge-base HEAD <base-branch>):<path>. If neither yields the file (renamed, spec lives in another repo), STOP and ask the user for the before-state — never reconstruct it from memory; until it is in hand, the report's Breaking section reads "not run: before-state unavailable", never "safe". For a brand-new endpoint there is no "before", so the compat section reduces to forward-compat design (step 4). Identify the consumers — grep sibling repos in the workspace for the route path and DTO names; if that turns up nothing, ask the user once; still unknown → record "unknown external" (other repos, mobile apps, webhook subscribers). Unknown consumers raise the cost of every breaking change and the report should say so.
  2. Diff the consumer-visible surface for breaking changes. Breaking = an existing valid consumer interaction stops working or changes meaning. The checklist, each judged by before/after citation:
    • Removed or renamed: path, method, field, enum value, header.
    • Type changes (string→int, scalar→object, nullable→non-null in responses).
    • Requiredness tightened on requests (new required field/param, stricter validation rejecting previously-valid input).
    • Semantics changed under the same name: status code for the same condition, default value, sort order consumers observe, pagination behavior, error code values, ID format.
    • Response fields removed or now-sometimes-absent (additive response fields are non-breaking for tolerant readers — but check the repo's serializer isn't strict (grep the repo's own spec/serializer config AND any known consumers for additionalProperties: false, FAIL_ON_UNKNOWN_PROPERTIES, MissingMemberHandling.Error, JsonUnmappedMemberHandling.Disallow; no hits and consumers unknown → state the tolerant-reader assumption in the report)).
    • ❌ "Changing this field feels risky." — no before/after, not a verdict.
    • ✅ "Breaking: status response field was \"active\"|\"disabled\" (git show UserDto.cs:14), now adds \"suspended\" — consumers with exhaustive enum handling will throw. New enum values in responses are breaking unless the contract documents open enums; nothing in the spec says so."
  3. Judge design by local precedent, not by taste. Before flagging anything as inconsistent, grep the sibling endpoints and read at least two. If the repo has fewer than two comparable endpoints, there is no local precedent — skip consistency findings, say so in the report, and judge only step 4's invariants. Then check the new surface against what THIS repo does: error envelope shape (find the canonical one; new endpoint must return it, not a fresh ad-hoc {message} — cite both), naming (camelCase vs snake_case, plural collections, ID field naming), auth placement (same middleware/guard pattern as siblings — compose with security-review if it's absent entirely), pagination style (cursor vs offset, envelope keys), timestamp format, route casing. A consistency finding without the cited precedent is an opinion; drop it or label it one.
  4. Check the design invariants that hurt later. These apply even with zero consumers today, because they're near-impossible to retrofit:
    • Collections paginate from day one — an unpaginated list endpoint is a time bomb; adding pagination later breaks every consumer.
    • Retryable writes are idempotent — POSTs that create money-adjacent or non-deduplicable resources need an idempotency key or a natural dedup constraint; name which.
    • Status codes carry their standard meaning — 200-with-error-body, 404 for authz denials (unless deliberate resource-hiding, then say so), 500 for validation failures: each flagged with the observed code and the condition.
    • Errors are machine-usable — a stable code field, not prose-only messages consumers will regex.
    • Nothing leaks that can't be unshipped — internal IDs, stack traces, ORM entity fields serialized wholesale (grep: does the handler return the entity type or a DTO?). Every response field is a permanent promise; flag fields with no evident consumer need.
    • Timestamps and money have explicit units/zones/currency — amount: 4200 with no currency or minor-unit convention is a production incident on layaway.
  5. Report in three ranked sections. (a) Breaking — each with before/after citations and the migration path (version bump per the repo's existing strategy, additive alternative, deprecation window); (b) Design — invariant violations and precedent-cited inconsistencies; (c) Questions — semantics you couldn't determine from code (is this enum open? is this endpoint consumer-facing at all?). Zero findings is a valid outcome — an additive, precedent-matching endpoint should get a short pass, not invented nits. Never edit code or specs unprompted. Before sending: every Breaking item quotes a before you actually ran git show for; every Design item cites a sibling file:line you opened; consumers you could not identify are listed as "unknown external"; anything not diffed appears in Coverage as not diffed — a diff you did not run is "not run", never "safe".

Output format:

## Breaking
- <element>: before `<quote>` (<git ref>) → after `<quote>` (<file:line>) — migration: <path>

## Design
- <finding> — precedent: <file:line>

## Questions
- <semantics you could not determine from code>

Coverage: diffed <surface> against <ref>; not diffed: <what> — verdicts tagged `verified` (observed this session), `inferred` (deduced from something observed) or `assumed` (neither)

Examples

Example 1: "is this a breaking change?"

User: "I'm renaming customer_id to customerId in the orders response — breaking?"

Claude: Diffs before/after (breaking: field rename is remove+add for every existing reader), greps the repo — every other response uses snake_case, so the rename also breaks local convention rather than fixing it (cited: 9 sibling DTOs). Recommends: keep customer_id; if the target is a casing migration, that's an API-version-level change, not a field edit.

Example 2: new endpoint pass

User: "Review the contract for the new /api/reports endpoints before I build them."

Claude: No before-state → forward-compat pass: flags the unpaginated GET /reports (day-one invariant), flags POST /reports/generate returning 200 with the result inline when generation takes minutes (should be 202 + status resource — cites the repo's existing export endpoint doing exactly that), confirms error envelope and naming match siblings, asks one question (open or closed enum for format?).

Anti-patterns

  • ❌ Declaring "breaking" or "safe" without reading the before-state — the diff of the surface is the entire evidence base.
  • ❌ Imposing REST doctrine the repo doesn't follow ("should be HATEOAS", "must be plural nouns") when siblings consistently do otherwise — local consistency beats global convention; flag the doctrine mismatch once as a question, at most.
  • ❌ Consistency findings with no cited precedent — grep the siblings first or don't flag it.
  • ❌ Treating additive response fields as breaking, or new required request fields as safe — the asymmetry (requests: consumers write them; responses: consumers read them) is the whole compat model.
  • ❌ Passing an unpaginated collection endpoint because "there won't be much data" — volume assumptions don't survive; retrofitting pagination breaks every consumer.
  • ❌ Reviewing the handler's implementation quality (naming, DRY, perf) — that's code-review; scope discipline keeps this report actionable.
  • ✅ Before/after-cited breaking verdicts, precedent-cited consistency findings, day-one invariants checked, questions kept separate from findings.

Notes

  • Spec-first repos (OpenAPI/proto/GraphQL SDL): review the spec diff as the contract and verify the implementation actually matches it (spot-check one handler against its spec entry — drift between the two is itself a finding). Code-first repos: the serialized DTOs + routes are the contract.
  • Deprecation over deletion: when a breaking change is genuinely wanted, the recommendation is the repo's existing versioning/deprecation mechanism if one exists (grep for it) — inventing a versioning strategy is a grill-with-docs conversation, not a review finding.
  • Apply think-like-fable: the risk lives in the unknown consumers, so compat verdicts get the re-derivation effort; "safe" claims are labeled by what was actually diffed; the report leads with the one change the user must not merge as-is.

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.