Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
secondsky avatar

Api Contract Testing

  • 344 installs
  • 202 repo stars
  • Updated August 4, 2026
  • secondsky/claude-skills

api-contract-testing is a Claude Code agent skill that automates API contract testing workflows for developers who need to verify service schemas and consumer-producer compatibility before release.

About

api-contract-testing is an agent skill in secondsky/claude-skills for API contract testing automation inside Claude Code workflows. The skill helps developers define, run, and maintain contract tests that catch breaking changes between API providers and consumers before deployment. Teams reach for api-contract-testing when microservices, REST, or GraphQL boundaries need repeatable verification that payloads, status codes, and schemas stay compatible across versions. It fits backend engineers shipping API changes who want agent-guided test scaffolding rather than ad hoc manual checks.

  • Extends Claude Code agent capabilities
  • Activates on relevant task triggers
  • Integrates with Claude Code workflow

Api Contract Testing by the numbers

  • 344 all-time installs (skills.sh)
  • +12 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #2,137 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill api-contract-testing

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs344
repo stars202
Last updatedAugust 4, 2026
Repositorysecondsky/claude-skills

How do you automate API contract testing in CI?

api-contract-testing: agent skill for task automation in Claude Code workflows.

Who is it for?

Backend developers shipping REST or GraphQL services who need repeatable contract verification across API versions.

Skip if: Frontend-only teams or projects without shared API contracts between services and clients.

When should I use this skill?

A developer needs to add, update, or debug API contract tests before merging service changes.

What you get

Contract test suites, schema assertions, and compatibility checks for API endpoints

  • Contract test suite
  • Schema compatibility assertions

Files

SKILL.mdMarkdownGitHub ↗

API Contract Testing

Verify that APIs honor their contracts between consumers and providers without requiring full integration tests.

Key Concepts

TermDefinition
ConsumerService that calls an API
ProviderService that exposes an API
ContractAgreed request/response format
PactConsumer-driven contract testing tool
SchemaStructure definition (OpenAPI, JSON Schema)
BrokerCentral repository for contracts

Pact Consumer Test (TypeScript)

import { PactV3, MatchersV3 } from '@pact-foundation/pact';

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

describe('User API Contract', () => {
  it('returns user by ID', async () => {
    await provider
      .given('user 123 exists')
      .uponReceiving('a request for user 123')
      .withRequest({ method: 'GET', path: '/users/123' })
      .willRespondWith({
        status: 200,
        body: MatchersV3.like({
          id: '123',
          name: MatchersV3.string('John'),
          email: MatchersV3.email('john@example.com')
        })
      })
      .executeTest(async (mockServer) => {
        const response = await fetch(`${mockServer.url}/users/123`);
        expect(response.status).toBe(200);
      });
  });

  it('returns 404 for non-existent user', async () => {
    await provider
      .given('user does not exist')
      .uponReceiving('a request for non-existent user')
      .withRequest({ method: 'GET', path: '/users/999' })
      .willRespondWith({
        status: 404,
        body: MatchersV3.like({
          error: { code: 'NOT_FOUND', message: MatchersV3.string() }
        })
      })
      .executeTest(async (mockServer) => {
        const response = await fetch(`${mockServer.url}/users/999`);
        expect(response.status).toBe(404);
      });
  });
});

Provider Verification

import { Verifier } from '@pact-foundation/pact';

new Verifier({
  provider: 'UserService',
  providerBaseUrl: 'http://localhost:3000',
  pactBrokerUrl: process.env.PACT_BROKER_URL,
  publishVerificationResult: true,
  providerVersion: process.env.GIT_SHA,
  stateHandlers: {
    'user 123 exists': async () => {
      await db.users.create({ id: '123', name: 'John' });
    },
    'user does not exist': async () => {
      await db.users.deleteAll();
    }
  }
}).verifyProvider();

OpenAPI Validation (Express)

const OpenApiValidator = require('express-openapi-validator');

app.use(OpenApiValidator.middleware({
  apiSpec: './openapi.yaml',
  validateRequests: true,
  validateResponses: true,
  validateSecurity: true
}));

Additional Implementations

  • Python JSON Schema: See references/python-json-schema.md
  • Java REST Assured: See references/java-rest-assured.md
  • Pact Broker CI/CD: See references/pact-broker-cicd.md

Best Practices

Do:

  • Test from consumer perspective
  • Use matchers for flexible matching
  • Validate structure, not specific values
  • Version contracts explicitly
  • Test error responses
  • Run tests in CI pipeline
  • Test backward compatibility

Don't:

  • Test business logic in contracts
  • Hard-code specific values
  • Skip error scenarios
  • Ignore versioning
  • Deploy without verification

Tools

  • Pact - Multi-language consumer-driven contracts
  • Spring Cloud Contract - JVM ecosystem
  • OpenAPI/Swagger - Schema-first validation
  • Dredd - API blueprint testing
  • Spectral - OpenAPI linting

Related skills

FAQ

What does api-contract-testing validate?

api-contract-testing helps developers verify API contracts between producers and consumers, checking that request and response schemas, status behavior, and compatibility hold before release. It automates contract test workflows inside Claude Code.

When should teams invoke api-contract-testing?

Teams should invoke api-contract-testing when shipping API changes across microservices or client-server boundaries. The skill scaffolds contract assertions to catch breaking schema or behavior drift before deployment.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.