contract-testing

Design consumer-driven contract tests for APIs and microservices using Pact.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill contract-testing-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contract-testing
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/07-testing-quality/contract-testing
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill contract-testing-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? End-to-end integration testing across microservices is slow, flaky, and expensive, and breaking API changes are often discovered only after deployment. This Skill designs consumer-driven contract tests that verify API compatibility between services without deploying the full stack. ## Core Features & Use Cases - Consumer-Driven Contracts: Write Pact consumer tests that define expected API behavior and generate shareable contract files. - Provider Verification: Validate that provider services satisfy all consumer contracts, with provider state handlers for test data setup. - CI/CD Integration: Publish contracts to a Pact Broker, run can-i-deploy checks, and block breaking changes on every pull request. - Use Case: A frontend team depends on a UserService API owned by another team. Use this Skill to generate a Pact contract from the frontend's expectations, publish it to the broker, and have the provider pipeline verify compatibility before any deployment. ## Quick Start Design Pact contract tests between my frontend and user-service, including provider verification and CI integration with a Pact Broker.

Frequently Asked Questions about contract-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write contract tests with Pact?

Write a consumer test that defines expected interactions using provider.addInteraction with request and response details, then run it against Pact's mock server. This generates a JSON contract file that the provider later verifies against its real implementation.

What is the difference between contract testing and end-to-end testing?

Contract tests verify API boundaries between two services using mocks, running in seconds without deployment. End-to-end tests deploy the full system and test through the UI, which is slower, flakier, and gives later feedback.

How does Pact Broker prevent breaking API changes?

Consumers publish contracts to the Pact Broker, and providers verify against all consumer contracts in CI. The can-i-deploy command checks verification results before production deployment and fails the build if any consumer contract is broken.

What are provider states in Pact testing?

Provider states are named preconditions like 'user 123 exists' that the consumer declares in its contract. The provider implements state handlers that set up required test data, such as inserting database records, before each verification runs.

Should Pact contracts use exact values or matchers?

Use matchers like like(), eachLike(), and term() instead of exact values. Type-based matching keeps contracts flexible so providers can return different valid values without breaking verification, while exact matching creates brittle tests.

When should I not use contract testing?

Contract tests do not replace integration or end-to-end tests because they verify API shape, not business logic across services. They also add overhead for single-team monoliths where services are not independently deployed.