contract-testing

Applies consumer-driven contract testing to verify API compatibility between packages or services without full E2E tests. Use when designing or evolving API boundaries between loosely coupled modules.

16 stars

Best use case

contract-testing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Applies consumer-driven contract testing to verify API compatibility between packages or services without full E2E tests. Use when designing or evolving API boundaries between loosely coupled modules.

Teams using contract-testing should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/contract-testing/SKILL.md --create-dirs "https://raw.githubusercontent.com/woojubb/robota/main/.agents/skills/contract-testing/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/contract-testing/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How contract-testing Compares

Feature / Agentcontract-testingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Applies consumer-driven contract testing to verify API compatibility between packages or services without full E2E tests. Use when designing or evolving API boundaries between loosely coupled modules.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Contract Testing (Consumer-Driven Contracts)

## Rule Anchor

- `AGENTS.md` > "Build Requirements"
- `AGENTS.md` > "Type System (Strict)"

## Use This Skill When

- Two modules communicate via API (HTTP, WebSocket, or typed interface).
- The consumer and provider are developed independently.
- You need to catch breaking API changes before deployment.
- E2E tests are too slow or flaky for API compatibility checks.

## Core Principles

1. **Consumer defines the contract**: what requests it sends and what responses it expects.
2. **Provider verifies the contract**: replays consumer expectations against its implementation.
3. **Contracts live in version control**: JSON or TypeScript files checked into the repo.
4. **Independent testing**: consumer and provider run contract tests without needing the other running.

## Workflow

1. Consumer writes a contract file describing expected request/response pairs.
2. Consumer tests pass against a mock that satisfies the contract.
3. Provider loads the contract and replays requests against its real handlers.
4. Provider tests verify all consumer expectations are met.
5. CI runs both sides; a contract violation blocks the merge.
6. When the API changes, update the contract first, then the implementation.

## Contract File Format (Lightweight)

```ts
// contracts/agent-server.contract.ts
export const AGENT_SERVER_CONTRACT = {
  name: 'agent-server',
  interactions: [
    {
      description: 'start a playground session',
      request: {
        method: 'POST',
        path: '/v1/sessions',
        body: { provider: 'openai', model: 'gpt-4.1-mini' },
      },
      response: { status: 201, bodySchema: { sessionId: 'string', status: 'string' } },
    },
    {
      description: 'get server capabilities',
      request: { method: 'GET', path: '/v1/capabilities' },
      response: { status: 200, bodySchema: { scheduler: 'boolean', projection: 'boolean' } },
    },
  ],
} as const;
```

## Checklist

- [ ] Contract file exists for each API boundary.
- [ ] Consumer tests use a mock derived from the contract.
- [ ] Provider tests replay contract interactions.
- [ ] Contract violations fail CI before merge.
- [ ] Contract changes go through review (breaking vs. additive).
- [ ] Contracts are versioned alongside API version (v1, v2).

## Anti-Patterns

- Consumer tests use hand-written mocks that drift from the real API.
- Provider changes API without updating the contract.
- Contracts are too detailed (testing internal implementation, not contract shape).
- Relying solely on E2E tests for API compatibility.
- Contracts stored outside version control.

Related Skills

vitest-testing-strategy

16
from woojubb/robota

Defines a practical testing strategy for TypeScript and JavaScript using Vitest across unit, integration, and type-level tests. Use when adding features, refactoring, or preventing regressions with fast feedback loops.

contract-audit

16
from woojubb/robota

Use when reviewing a package's class contract relationships (interface implementations, inheritance chains, cross-package port consumers) and updating its SPEC.md Class Contract Registry.

web-design-guidelines

16
from woojubb/robota

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

version-management

16
from woojubb/robota

All packages must have the same version. Use changesets for coordinated version bumps. Never version packages independently.

vercel-react-native-skills

16
from woojubb/robota

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

vercel-react-best-practices

16
from woojubb/robota

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-composition-patterns

16
from woojubb/robota

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

user-request-gate

16
from woojubb/robota

Use immediately when the user requests any implementation, code change, feature addition, fix, or modification. Gates code writing behind a backlog draft document. Read-only exploration is always permitted.

type-boundary-and-ssot

16
from woojubb/robota

Applies Robota's preferred workflow for trust-boundary validation, strict typing, quality gates, and owner-based SSOT reuse. Use when adding or reviewing type contracts, boundary parsing, shared contract ownership, or running quality checks.

tdd-red-green-refactor

16
from woojubb/robota

Kent Beck's TDD workflow. Use when writing new code or modifying existing behavior. Enforces the Red-Green-Refactor cycle with small, verifiable steps.

task-tracking

16
from woojubb/robota

Track work using task files in .agents/tasks/. Use when starting, progressing, or completing a task to maintain a persistent record of work.

tailwind-truncation

16
from woojubb/robota

Provide Tailwind truncation patterns for single-line and multi-line text. Use when discussing text ellipsis, truncation, or line-clamp usage.