# Contract Testing

Consumer-driven contract testing for microservices using Pact, schema validation, API...

- Repository: https://github.com/proffesor-for-testing/agentic-qe (521 stars)
- Category: Testing
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add proffesor-for-testing/agentic-qe --skill contract-testing -g -a claude-code -y`
Codex: `npx skills add proffesor-for-testing/agentic-qe --skill contract-testing -g -a codex -y`
Cursor: `npx skills add proffesor-for-testing/agentic-qe --skill contract-testing -g -a cursor -y`
Gemini CLI: `npx skills add proffesor-for-testing/agentic-qe --skill contract-testing -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add proffesor-for-testing/agentic-qe`

## Description

Consumer-driven contract testing for microservices using Pact, schema validation, API versioning, and backward compatibility testing. Use when testing API contracts or coordinating distributed teams.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Contract Testing

<default_to_action>
When testing API contracts or microservices:
1. DEFINE consumer expectations (what consumers actually need)
2. VERIFY provider fulfills contracts (Pact verification)
3. DETECT breaking changes before deployment (CI/CD integration)
4. VERSION APIs semantically (breaking = major bump)
5. MAINTAIN backward compatibility for supported versions

**Quick Contract Testing Steps:**
- Consumer: Define expected request/response pairs
- Provider: Verify against all consumer contracts
- CI/CD: Block deploys that break contracts
- Versioning: Document supported versions and deprecation

**Critical Success Factors:**
- Consumers own the contract (they define what they need)
- Provider must pass all consumer contracts before deploy
- Breaking changes require coordination, not surprise
</default_to_action>

## Quick Reference Card

### When to Use
- Microservices communication
- Third-party API integrations
- Distributed team coordination
- Preventing breaking changes

### Consumer-Driven Contract Flow
```
Consumer → Defines Expectations → Contract
                    ↓
Provider → Verifies Contract → Pass/Fail
                    ↓
CI/CD → Blocks Breaking Changes
```

### Breaking vs Non-Breaking Changes
| Change Type | Breaking? | Semver |
|-------------|-----------|--------|
| Remove field | ✅ Yes | Major |
| Rename field | ✅ Yes | Major |
| Change type | ✅ Yes | Major |
| Add optional field | ❌ No | Minor |
| Add new endpoint | ❌ No | Minor |
| Bug fix | ❌ No | Patch |

### Tools
| Tool | Best For |
|------|----------|
| **Pact** | Consumer-driven contracts |
| **OpenAPI/Swagger** | API-first design |
| **JSON Schema** | Schema validation |
| **GraphQL** | Schema-first contracts |

---

## Consumer Contract (Pact)

```javascript
// Consumer defines what it needs
const { Pact } = require('@pact-foundation/pact');

The rest: https://github.com/proffesor-for-testing/agentic-qe/blob/HEAD/.claude/skills/contract-testing/SKILL.md
