Get the FREE Ultimate OpenClaw Setup Guide →

contract-test-generator

npx machina-cli add skill a5c-ai/babysitter/contract-test-generator --openclaw
Files (1)
SKILL.md
2.4 KB

Contract Test Generator Skill

Generates contract tests for API migrations, supporting consumer-driven contracts, provider verification, and breaking change detection.

Purpose

Enable API contract testing for:

  • Consumer contract generation
  • Provider verification
  • Schema validation
  • Breaking change detection
  • Mock server generation

Capabilities

1. Consumer Contract Generation

  • Generate from API usage
  • Extract from tests
  • Build from specs
  • Support multiple formats

2. Provider Verification

  • Verify against contracts
  • Test all consumers
  • Check compatibility
  • Document failures

3. Schema Validation

  • Validate request schemas
  • Check response schemas
  • Verify data types
  • Enforce constraints

4. Breaking Change Detection

  • Detect field removals
  • Find type changes
  • Identify required additions
  • Flag compatibility issues

5. Mock Server Generation

  • Generate from contracts
  • Support stub responses
  • Handle scenarios
  • Enable development isolation

6. Contract Versioning

  • Track contract versions
  • Manage compatibility
  • Support migrations
  • Document changes

Tool Integrations

ToolPurposeIntegration Method
PactConsumer-driven contractsCLI
Spring Cloud ContractJava contractsCLI
DreddAPI validationCLI
PrismMock serverCLI
WireMockMock serverCLI

Output Schema

{
  "generationId": "string",
  "timestamp": "ISO8601",
  "contracts": [
    {
      "consumer": "string",
      "provider": "string",
      "interactions": [
        {
          "description": "string",
          "request": {},
          "response": {}
        }
      ]
    }
  ],
  "verification": {
    "passed": "boolean",
    "results": []
  },
  "artifacts": {
    "contractFiles": [],
    "mockServerConfig": "string"
  }
}

Integration with Migration Processes

  • api-modernization: Contract verification
  • monolith-to-microservices: Service contracts

Related Skills

  • openapi-generator: Spec generation
  • api-compatibility-analyzer: Breaking changes

Related Agents

  • regression-detector: Regression prevention
  • cross-team-integrator: Contract coordination

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/code-migration-modernization/skills/contract-test-generator/SKILL.mdView on GitHub

Overview

Generates and verifies API contracts across migrations using consumer-driven contracts and provider verification. It supports schema validation, breaking change detection, and mock server generation to enable safe, observable migrations.

How This Skill Works

The skill derives contracts from API usage, tests, or specs, then performs provider verification against those contracts, validates request/response schemas, detects breaking changes, and can generate a mock server configuration from the contracts for development isolation.

When to Use It

  • During API modernization to ensure consumer expectations match provider behavior
  • When migrating from monolith to microservices to coordinate contracts across teams
  • To verify compatibility between consumers and providers before release
  • When you need breaking-change detection to flag removals, type changes, or required additions
  • To generate and use mock servers for development isolation and contract-driven testing

Quick Start

  1. Step 1: Generate contracts from API usage, tests, or specs (consumer-driven contracts).
  2. Step 2: Run provider verification to ensure providers satisfy the contracts and document failures.
  3. Step 3: Enable mock server generation from contracts and manage contract versions for migrations.

Best Practices

  • Define and version contracts early from multiple sources (usage, tests, specs)
  • Run provider verification as part of CI to catch regressions
  • Enforce strict schema validation for requests and responses
  • Document breaking changes and compatibility notes in contract history
  • Use mock servers derived from contracts to accelerate development and testing

Example Use Cases

  • Generate consumer contracts from observed API usage and validate against providers in CI
  • Verify provider compatibility against all registered consumer contracts
  • Validate request/response schemas and enforce data type constraints
  • Detect breaking changes such as field removals or added required fields
  • Spin up a mock server from contracts to enable offline development and testing

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers