From aj-geddes-useful-ai-prompts-4
Verifies API contracts between services using Pact, OpenAPI, and JSON Schema. Prevents breaking changes in microservices communication.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:api-contract-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Contract testing verifies that APIs honor their contracts between consumers and providers. It ensures that service changes don't break dependent consumers without requiring full integration tests. Contract tests validate request/response formats, data types, and API behavior independently.
Minimal working example:
// tests/pact/user-service.pact.test.ts
import { PactV3, MatchersV3 } from "@pact-foundation/pact";
import { UserService } from "../../src/services/UserService";
const { like, eachLike, iso8601DateTimeWithMillis } = MatchersV3;
const provider = new PactV3({
consumer: "OrderService",
provider: "UserService",
port: 1234,
dir: "./pacts",
});
describe("User Service Contract", () => {
const userService = new UserService("http://localhost:1234");
describe("GET /users/:id", () => {
test("returns user when found", async () => {
await provider
.given("user with ID 123 exists")
.uponReceiving("a request for user 123")
.withRequest({
method: "GET",
path: "/users/123",
headers: {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Pact for Consumer-Driven Contracts | Pact for Consumer-Driven Contracts |
| OpenAPI Schema Validation | OpenAPI Schema Validation |
| JSON Schema Validation | JSON Schema Validation |
| REST Assured for Java | REST Assured for Java |
| Contract Testing with Postman | Contract Testing with Postman |
| Pact Broker Integration | Pact Broker Integration |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Verifies API contracts between services using Pact consumer-driven tests, provider verification, schema validation, and OpenAPI specs. Use for microservices communication, preventing breaking changes.
Validates API contracts using consumer-driven contract testing with Pact and Spring Cloud Contract. Prevents breaking changes in microservice integrations.
Writes contract tests between services using Pact or schema validation to ensure API compatibility. Covers consumer-driven contracts, provider verification, schema evolution, breaking change detection, and CI/CD integration.