用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill contract-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | contract-testing |
| description | Contract testing — Pact, schema validation, breaking change prevention. |
Integration tests require a live environment. E2E tests are slow and fragile. Contract testing catches API contract breaks between services in CI, without a shared environment, by verifying that the consumer's expectations match what the provider actually returns.
| Term | Meaning |
|---|---|
| Consumer | The service that calls the API (client, frontend, downstream service) |
| Provider | The service that serves the API (backend, upstream service) |
| Pact | A JSON file describing the interactions the consumer expects |
| Pact Broker | Central store for pact files and verification results |
| Provider state | Setup instructions telling the provider how to arrange its data for a given test |
Consumer writes expectations
↓
Pact file generated (JSON)
↓
Published to Pact Broker
↓
Provider runs pact:verify in CI
↓
Results published to Broker
↓
Can-I-Deploy check gates the release
Define each interaction with three parts:
given — provider state: "a user with ID 42 exists"upon receiving — the request: method, path, headers, bodywill respond with — expected status, headers, body shape (not exact values — use matchers)Use matchers (type, regex, like) rather than exact values so the contract stays stable across test data changes.
given in the pact — sets up the database or mocks needed.pact:verify (or equivalent) in CI on every PR that touches the API.can-i-deploy.Not needed for monoliths where consumer and provider are compiled and deployed together.
When Pact is too heavy (small team, simple API, no Pact Broker available):
dredd, schemathesis, or openapi-validator.This is weaker than Pact (no consumer-driven expectations) but far better than no contract enforcement.
| Change type | Safe? | Required action |
|---|---|---|
| Add new optional field to response | Yes | None |
| Add new optional query/body parameter | Yes | None |
| Remove a field from response | No | Provider version bump + consumer update cycle |
| Rename a field | No | Provider version bump + consumer update cycle |
| Change field type | No | Provider version bump + consumer update cycle |
| Remove an endpoint | No | Deprecation period + consumer migration |
/v1/, /v2/) for major breaking changes.