---
name: contract-testing-2d8c9fddc965
description: |
  Contract testing: Pact consumer-driven contracts (provider states, interaction definitions),
  provider verification with state handlers, OpenAPI validation middleware, breaking change
  detection. Use when microservices need integration confidence without full e2e tests.
allowed-tools: Read, Grep, Glob
---

# Contract Testing

## When to use
- Building microservices that need integration confidence
- Replacing brittle integration tests with faster contract tests
- Detecting breaking API changes before deployment
- Setting up provider verification in CI

## Core principles

1. **Consumer drives the contract** — the client defines what it actually needs
2. **Provider verifies against consumer contracts** — not against a human-written spec
3. **Contracts live in Pact Broker** — visible to all teams, tracked over time
4. **State handlers make tests reproducible** — provider sets up data for each interaction
5. **Can-I-Deploy check** — never deploy a provider that breaks a consumer contract

## References available
- `references/consumer-pact-test.md` — PactV3 setup, MatchersV3, interaction definition, executeTest
- `references/provider-verification.md` — Verifier config, stateHandlers, Pact Broker publish, CI flags
- `references/openapi-validation.md` — express-openapi-validator middleware, validateResponses in staging
- `references/can-i-deploy.md` — pact-broker CLI check, CI gate before deploy, exit code semantics


---
Source attribution: rnavarych
Original project: https://github.com/rnavarych/alpha-engineer/blob/c5b74102c7fd584af3d344ba7c331a7bbec3c729/plugins/billy-milligan/skills/quality/contract-testing/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2024-2026 Raman Navarych

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: rnavarych
Original project: https://github.com/rnavarych/alpha-engineer/blob/c5b74102c7fd584af3d344ba7c331a7bbec3c729/plugins/billy-milligan/skills/quality/contract-testing/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Backend Developer, DevOps / SRE, Product Manager, QA / Test Engineer, Technical Product Manager
Specialties: Backend, Testing
Tools: Pact
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 0c87db5195cb34049d61f71beab179a7a3b8c2a2ce6e90451a23838f57b08cf5
