/quality-skills:pact-contract-testingfrom quality-skills
Designs, implements, and operates consumer-driven contract testing with Pact. Covers consumer/provider test setup, Pact Broker/Pactflow workflows, and CI integration with can-i-deploy gates.
Ships in quality-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in consumer-driven contract testing with Pact. Your goal is to help engineers design, implement, and operate contract tests across consumer and provider sides, plus the Pact Broker / Pactflow workflow that makes contract testing scalable. Don't fabricate Pact method names, broker API endpoints, or matcher syntax — point to docs.pact.io when uncertain.
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
can-i-deploy gates. Manual workflows are fragile.If the file does not exist, ask: architecture (number of services, ownership boundaries), consumer/provider languages, broker (Pact Broker / Pactflow / none yet), and CI provider.
Is: an agreement between a consumer (e.g., a mobile app) and a provider (e.g., a payments API) about the shape of HTTP requests/responses they exchange. The consumer writes a Pact test that says "when I send this request, I expect this response shape." The provider then runs a verification that says "if I receive that request, I produce that response shape." The agreement (the pact file) is the contract.
Isn't:
The consumer writes a unit-test-style file using its language's Pact library. Each test defines:
// JavaScript / Node example using @pact-foundation/pact
import { PactV3, MatchersV3 } from '@pact-foundation/pact';
const { like, eachLike, regex } = MatchersV3;
const provider = new PactV3({
consumer: 'web-app',
provider: 'orders-service',
});
describe('orders-service consumer', () => {
it('fetches orders for an authenticated user', async () => {
provider
.given('a user user-42 with 2 orders')
.uponReceiving('a request for that user’s orders')
.withRequest({
method: 'GET',
path: '/users/user-42/orders',
headers: { Authorization: regex('^Bearer .+', 'Bearer bearer-token-placeholder') },
})
.willRespondWith({
status: 200,
headers: { 'Content-Type': 'application/json' },
body: {
orders: eachLike({
id: like('ord-1001'),
total: like(99.0),
}, { min: 1 }),
},
});
await provider.executeTest(async (mock) => {
// call your code under test, pointing at mock.url
});
});
});
Running this test produces a pact file — a JSON document describing the interactions. That file gets published to the broker.
You almost never want exact equality. Use matchers so pacts don't break on every minor real value change.
| Matcher | Use |
|---|---|
like(value) | Same type as value, any actual content. |
eachLike(shape, { min }) | Array where each element matches shape. |
regex(pattern, example) | String matching the regex. |
term({ matcher, generate }) | Same as regex but more flexible. |
iso8601DateTime() / uuid() | Common formats. |
A pact full of literal strings is brittle. A pact full of like(...) matchers is the right amount of strictness.
The provider checks out each pact file (usually from the broker) and runs a verification: replay every recorded interaction against the real service, assert the response matches.
// JVM example (pact-jvm)
@Provider("orders-service")
@PactBroker(host = "broker.example.com")
public class OrdersServiceContractTest {
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void verifyPact(PactVerificationContext context) {
context.verifyInteraction();
}
@State("a user user-42 with 2 orders")
public void user42HasOrders() {
// seed the test database / fixtures for this state
}
}
@State handlers are how providers satisfy the consumer's preconditions. They run before each interaction.
The broker stores pacts and verification results. Without it, you have JSON files floating around — with it, you get the coordination workflow that makes contract testing worth the cost.
can-i-deploy before deploying.can-i-deploypact-broker can-i-deploy \
--pacticipant web-app --version $GIT_SHA \
--to-environment production
The broker answers: yes (every required compatibility is verified), or no (with a list of unverified or failing pacts). Wire this into the deploy job as a required gate.
Both prevent "we added a new pact and now the provider is red because it doesn't know about it":
Without these, contract testing creates a coupling between consumer and provider release cadence that defeats the point.
| Use a pact | Use an integration test |
|---|---|
| Different team owns the provider | Same team / same repo |
| Provider deploys independently | Provider deploys with consumer |
| You want to gate deployments on compatibility | You want to test wiring & business logic |
| Test shapes, not logic | Test logic end-to-end |
| The broker is set up | No broker available |
Don't write pacts between a controller and a service in the same JVM. That's an integration test.
like / eachLike / regex aggressively.@State("user with 2 orders") that does nothing means the verification runs against whatever data happens to be there. Tests become flaky and meaningless.can-i-deploy gate — the workflow only pays off when deploys check compatibility. Without that, contract testing is just extra tests.When helping with Pact, ask:
can-i-deploy into deploy gates.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
56 skills in this plugin
/accessibility-testingWhen the user wants to design, implement, or operate accessibility (a11y) testing — automated scans, manual audits, screen-reader testing, WCAG conformance, Section 508 / EAA compliance. Use when the user mentions "accessibility," "a11y," "WCAG," "Section 508," "EAA," "ADA compliance," "axe," "axe-core," "pa11y," "Lighthouse," "aXe DevTools," "screen reader," "NVDA," "JAWS," "VoiceOver," "TalkBack," "WAVE," or "AT testing." For visual diff see visual-regression. For overall test strategy see test-strategy./ai-augmented-testingWhen the user wants to evaluate, adopt, or operate AI-augmented testing tools and approaches — autonomous test generation, self-healing locators, AI-assisted authoring, vision-based testing, agentic test runners. Use when the user mentions "AI testing," "AI-augmented testing," "Testim," "Mabl," "Functionize," "Reflect," "TestRigor," "Tricentis Copilot," "Cypress AI," "Playwright codegen with AI," "AI test generation," "self-healing tests," or "vision-based test automation." For LLM-product evals see llm-eval-testing. For overall strategy see test-strategy./appiumWhen the user wants to design, implement, debug, or scale Appium tests for iOS and Android mobile automation. Use when the user mentions "Appium," "Appium 2," "UiAutomator2," "XCUITest driver," "appium:capabilities," "AppiumServer," "accessibility id," "TouchAction," "W3C Actions," "Appium inspector," "real device cloud," or "App Center / BrowserStack / Sauce mobile." For Android-native frameworks see espresso. For iOS-native see xcuitest. For React Native specifically see detox. For YAML-driven mobile flows see maestro. For desktop web automation see selenium / playwright / webdriverio./artilleryWhen the user wants to design, implement, debug, or operate Artillery load tests. Use when the user mentions "Artillery," "artillery.yml," "artillery run," "Artillery scenarios," "Artillery Pro," "phases (Artillery)," "Artillery plugins," "Artillery Engine," or "artillery report." For JS-tested perf with thresholds see k6. For JVM perf see gatling. For Python see locust. For JMeter see jmeter./bdd-anti-patternsWhen the user wants to audit, refactor, or rescue a Cucumber / Gherkin / SpecFlow / Reqnroll / behave BDD suite from common failure modes. Use when the user mentions "BDD anti-patterns," "Gherkin anti-patterns," "scenario refactoring," "imperative steps," "feature file review," "BDD smells," "BDD failing," "Cucumber feedback loop," "scenarios as scripts," or "is BDD worth it." For Cucumber/Gherkin basics see cucumber-gherkin. For .NET BDD see specflow-reqnroll. For Python BDD see behave./behaveWhen the user wants to design, implement, debug, or operate BDD tests on Python using behave. Use when the user mentions "behave," "behave.ini," "@given/@when/@then," "context.x," "environment.py," "behave hooks," "behave tags," "step definitions in Python," "behave-django," or "behave-pytest." For language-agnostic Gherkin patterns see cucumber-gherkin. For .NET BDD see specflow-reqnroll. For BDD failure modes see bdd-anti-patterns. For non-BDD Python testing see pytest.npx claudepluginhub aks-builds/quality-skills --plugin quality-skills