跳到正文
cccskills
免费在 GitHub 公开

api-contract-testing

Design and review API contract tests across providers and consumers. Use for schema changes, compatibility regressions and client integration failures.

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

查看安装方法

包含的文件(1)

  • SKILL.md5.3 KB

SKILL.md(原文)

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

API Contract Testing

Overview

Turn an API change into explicit provider and consumer checks. Start from the actual contract and affected clients, then verify wire-level behavior rather than relying on generated types or a successful build. Default to local fixtures and existing test tools; this skill does not provision a testing service.

When to Use

  • A response field, endpoint, event schema or error envelope changes.
  • A client and server build successfully but disagree at runtime.
  • A team needs to distinguish a breaking change from a compatible extension.
  • A reported regression needs a minimal provider/consumer reproduction.

Do not use this as authorization to call production endpoints, bypass access controls or publish a new API version.

How It Works

1. Bind the contract and scope

Identify the provider, transport, contract source and version, known consumers and the requested behavior. Read the real OpenAPI/JSON Schema/protobuf definition or documented examples and the corresponding server/client code. Record missing consumers and stale specifications as coverage gaps; do not invent interfaces or claim complete coverage from one client.

Keep these distinct: documented schema, actual provider output, generated client types and runtime parsing. A type assertion alone is not validation. Preserve the existing protocol and test runner instead of introducing a new platform by default.

2. Classify the change

Review fields, requiredness, nullability, enum values, status codes, headers, content type, pagination and error behavior. Inspect whether clients tolerate extra fields and unknown enum values. Even an added optional field can break a strict consumer. Explicitly identify affected versions and assumptions before calling a change compatible.

For events, include duplicate delivery, ordering and version envelopes. For request changes, check serialization and server validation as well as responses.

3. Build a small test matrix

Use deterministic synthetic fixtures for:

  • Valid success, including optional and empty values.
  • Missing required fields, wrong types and explicit nulls.
  • Extra fields and unknown enums according to the actual compatibility policy.
  • Declared error envelopes, non-success statuses and malformed bodies.
  • Old consumer against new provider and new consumer against retained old provider, where those combinations are supported.

Assert the behavior promised by the contract. Do not silently coerce malformed values or make the fixture match a defect just to get a passing test.

4. Verify each boundary

Run the existing schema validator against fixtures. Exercise the provider handler locally and pass its serialized result through the real consumer parser. Check failure cases reject or map errors as specified. Use an authorized isolated integration environment only when fixtures cannot establish the required property; report that boundary explicitly.

A mock verifies assumptions encoded in the mock. It does not establish that the real provider implements them. Record exact commands, fixture versions and observed outcomes separately from unrun checks.

5. Report and hand off

Deliver the change classification, affected consumers, test matrix, observed failures, minimal reproduction and remaining coverage gaps. For a breaking change, propose versioning, a compatibility adapter or a staged migration with owners and rollback criteria. Deployment and consumer migration require their own task authorization.

Example

Synthetic documented response:

{"id":"invoice-demo","amount_minor":1250,"currency":"EUR"}

Contract: id and currency are strings; amount_minor is a non-negative integer in minor units. This fixture does not represent an actual customer or payment.

Fixture changeExpected check
amount_minor becomes "1250"Runtime parser rejects the string; compile-time generated types alone cannot detect wire drift.
amount_minor is missing or nullReject when the field is required and non-nullable.
Extra display_label fieldVerify the consumer's documented extra-field policy before declaring compatibility.
HTTP error with an HTML bodyProduce the declared transport/protocol error, rather than treating it as a valid invoice.

Reusable prompt:

Review this API change against the actual contract and supplied client/server code.
List affected consumers and supported version combinations. Add local contract tests
for valid, missing, null, wrong-type and error responses with the existing runner.
Report checks actually run and any provider behavior still requiring integration proof.

Best Practices

  • Keep fixtures synthetic, minimal and versioned with the relevant contract.
  • Test serialization and runtime parsing in addition to static types.
  • Require evidence for compatibility claims and preserve the failing reproduction.
  • Use the existing tools; no hosted vendor, broker or

评价

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

评论

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

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

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

0 / 1000 字

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

同一仓库的技能

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

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

ranbot-ai/awesome-skills72026年10月18日 更新

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

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

ranbot-ai/awesome-skills72026年10月18日 更新

Usar al iniciar o mejorar un proyecto de IA: diagnostica código y restricciones, propone skills existentes y redacta tareas y un plan de implementación en español.

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

ranbot-ai/awesome-skills72026年10月18日 更新

Usar para crear o mejorar una skill de Andru.ia: define entradas y resultados, redacta SKILL.md con ejemplos y límites, valida la estructura y prepara una PR.

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

ranbot-ai/awesome-skills72026年10月18日 更新

Usar tras definir el sector de un proyecto: prepara un dossier en español con contexto, normas aplicables, patrones UX y riesgos, distinguiendo fuentes verificadas de hipótesis.

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

ranbot-ai/awesome-skills72026年10月18日 更新

AI-powered presentation generation via the 2slides API — create slides from text, match a reference image style, summarize documents into decks, add AI voice narration, and export pages/audio. Use f

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

ranbot-ai/awesome-skills72026年10月18日 更新

查看 ranbot-ai 的全部技能

报告此技能的问题