mcpbeat Sign in

Contract Testing Patterns Agent Skill

Pact consumer-driven contracts, provider verification, schema evolution

932 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
521
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/vibeeval/vibecosystem --skill contract-testing-patterns

The instruction itself

8 sections, as written by the author

Contract Testing Patterns

Consumer-Driven Contract Testing with Pact

Consumer Test (JavaScript)

const { PactV3, MatchersV3 } = require('@pact-foundation/pact');
const { like, eachLike, string, integer } = MatchersV3;

const provider = new PactV3({
  consumer: 'OrderService',
  provider: 'UserService',
  logLevel: 'warn',
});

describe('User API Contract', () => {
  it('returns user by ID', async () => {
    await provider
      .given('user with ID 1 exists')
      .uponReceiving('a request for user 1')
      .withRequest({
        method: 'GET',
        path: '/api/users/1',
        headers: { Accept: 'application/json' },
      })
      .willRespondWith({
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        body: {
          id: integer(1),
          name: string('Jane Doe'),
          email: string('[email protected]'),
          roles: eachLike('admin'),
        },
      })
      .executeTest(async (mockServer) => {
        const client = new UserClient(mockServer.url);
        const user = await client.getUser(1);
        expect(user.id).toBe(1);
        expect(user.name).toBeDefined();
      });
  });
});

Provider Verification

const { Verifier } = require('@pact-foundation/pact');

describe('User Provider Verification', () => {
  it('validates consumer contracts', async () => {
    const verifier = new Verifier({
      providerBaseUrl: 'http://localhost:3000',
      pactBrokerUrl: process.env.PACT_BROKER_URL,
      pactBrokerToken: process.env.PACT_BROKER_TOKEN,
      provider: 'UserService',
      providerVersion: process.env.GIT_SHA,
      providerVersionBranch: process.env.GIT_BRANCH,
      publishVerificationResult: true,
      stateHandlers: {
        'user with ID 1 exists': async () => {
          await db.users.create({ id: 1, name: 'Jane Doe', email: '[email protected]' });
        },
        'no users exist': async () => {
          await db.users.deleteAll();
        },
      },
    });
    await verifier.verifyProvider();
  });
});

Schema Evolution Rules

# Backward Compatible (SAFE):
- Adding optional fields
- Adding new endpoints
- Widening accepted value ranges
- Adding new enum values (if consumer ignores unknown)

# Breaking Changes (UNSAFE):
- Removing fields
- Renaming fields
- Changing field types
- Making optional fields required
- Narrowing accepted value ranges
- Removing endpoints

Can-I-Deploy Check

# Before deploying consumer
pact-broker can-i-deploy \
  --pacticipant OrderService \
  --version $GIT_SHA \
  --to-environment production

# Before deploying provider
pact-broker can-i-deploy \
  --pacticipant UserService \
  --version $GIT_SHA \
  --to-environment production

Checklist

  • [ ] Every external API dependency has a consumer contract
  • [ ] Provider state handlers seed realistic test data
  • [ ] Contracts published to Pact Broker with git SHA version
  • [ ] can-i-deploy gate in CI pipeline before deploy
  • [ ] Provider verification runs on every PR
  • [ ] Breaking change detection automated
  • [ ] Contract tests run in under 30 seconds
  • [ ] Webhook configured to trigger provider verification on new pact

Anti-Patterns

  • Testing provider internal logic in consumer tests
  • Using exact matchers instead of type matchers (brittle)
  • Skipping provider states (tests pass but don't reflect reality)
  • Not versioning contracts with git SHA
  • Running contract tests against shared environments
  • Coupling consumer tests to provider implementation details
  • Ignoring can-i-deploy failures

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
Test Driven Development
by w95
×7

Use when implementing any feature or bugfix, before writing implementation code

2k tokens
Systematic Debugging
by ratacat
×7

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

10k tokens scripts
Verification Before Completion
by ZhanlinCui
×6

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

1k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Adaptyv
by christophacham
×3

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

16k tokens
Aeon
by christophacham
×3

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

19k tokens

How to use it

Copy the folder

Take vibeeval/contract-testing-patterns from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.