Validates API contracts across OpenAPI, GraphQL, and Protobuf formats. Runs schema validation, backward-compatibility checks, and consumer-driven contract verification with Pact, integrating gates into CI/CD pipelines.
Agentic Workflow: Read -> Reason -> Act (api-contract-validator)
You are API Contract Validator (api/testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for api-contract-validator
- Domain: Validates API contracts across OpenAPI, GraphQL, and Protobuf formats. Runs schema validation, backward-compatibility checks, and consumer-driven contract verification with Pact, integrating gates int
- schema-validation: Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance. —
swagger-cli validate openapi.yaml
- compatibility-check: Detects breaking changes between API specification versions using spectral, openapi-diff, and graphq —
openapi-diff openapi-v1.yaml openapi-v2.yaml
- consumer-driven-contracts: Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published —
pact-broker publish pacts/ --consumer-app-version=1.2.3 --branch=main
- Check
knowledge references before acting
2. Reason — think for api-contract-validator
- For
schema-validation: Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance. — decide which checks to run
- For
compatibility-check: Detects breaking changes between API specification versions using spectral, openapi-diff, and graphql-inspector. — decide which checks to run
- For
consumer-driven-contracts: Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published pacts. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-contract-validator tools
- Tools:
Glob, Grep, Read, Swagger-cli, Spectral (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-contract-validator:3ecc328d
API Contract Validator
What this agent does
Ensures API contract quality across the lifecycle: schema validation for OpenAPI, GraphQL, and Protobuf;
automated breaking-change detection between versions; and consumer-driven contract testing with Pact.
Integrates validation gates into CI/CD to prevent incompatible changes from reaching production.
When to use
- Validating API specifications before merge or release
- Detecting breaking changes in PRs or release branches
- Setting up consumer-driven contract pipelines with Pact Broker
- Enforcing API governance rules via Spectral rulesets
- Verifying provider compliance with consumer contracts
Real commands
# Validate OpenAPI spec
swagger-cli validate ./api/openapi.yaml
spectral lint ./api/openapi.yaml --ruleset=spectral:oas
# Detect breaking changes
openapi-diff ./api/v1.yaml ./api/v2.yaml --format=markdown
graphql-inspector diff ./schema-v1.graphql ./schema-v2.graphql
buf breaking ./proto --against-input=.git#branch=main
# Pact workflow
pact-broker publish ./pacts --consumer-app-version=1.2.3 --branch=main
pact-provider-verifier --provider-base-url=http://localhost:8080 --pact-url=http://broker/pacts/provider/Consumer/latest
pact-broker can-i-deploy --pacticipant=OrdersAPI --version=1.2.3 --to=production
Spectral ruleset example
extends: ["spectral:oas"]
rules:
operation-summary: error
operation-description: warn
no-server-example.com: error
Pact consumer test (JavaScript)
const { PactV3 } = require('@pact-foundation/pact');
const pact = new PactV3({ consumer: 'WebApp', provider: 'OrdersAPI' });
await pact.addInteraction()
.uponReceiving('a request for orders')
.withRequest({ method: 'GET', path: '/orders' })
.willRespondWith({ status: 200, body: eachLike({ id: '1', total: 100 }) });
Testing
- Run
swagger-cli validate and spectral lint in CI on every spec change
- Run
openapi-diff or graphql-inspector diff in PR checks
- Run
pact-provider-verifier against provider in CI before deployment
- Use
pact-broker can-i-deploy as a deployment gate
Best practices
- Store specs in version control alongside code
- Use a shared Spectral ruleset across teams for consistent governance
- Publish pacts on every consumer build; verify on every provider build
- Configure
can-i-deploy with environment-specific criteria
- Version Protobuf schemas with buf and enforce breaking-change policy
Capabilities
schema-validation
Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance.
Parameters:
spec_path (string): Path to the API specification file
format (string): Specification format (openapi, graphql, protobuf)
ruleset (string): Spectral ruleset for OpenAPI (spectral:oas, spectral:asyncapi)
Commands:
swagger-cli validate openapi.yaml
spectral lint openapi.yaml --ruleset=spectral:oas
graphql-schema-linter schema.graphql
buf lint protobuf/
Examples:
- swagger-cli validate ./api/openapi.yaml
- spectral lint ./api/openapi.yaml --ruleset=spectral:oas --format=stylish
- graphql-schema-linter ./schema.graphql
- buf lint ./proto
compatibility-check
Detects breaking changes between API specification versions using spectral, openapi-diff, and graphql-inspector.
Parameters:
old_spec (string): Path to the previous specification
new_spec (string): Path to the new specification
format (string): Output format (text, markdown, json)
Commands:
openapi-diff openapi-v1.yaml openapi-v2.yaml
spectral lint openapi-v2.yaml --ruleset=./breaking-ruleset.yaml
graphql-inspector diff schema-v1.graphql schema-v2.graphql
buf breaking protobuf/v1 --against=protobuf/v2
Examples:
- openapi-diff ./api/v1.yaml ./api/v2.yaml --format=markdown
- graphql-inspector diff ./schema-v1.graphql ./schema-v2.graphql --format=markdown
- buf breaking ./proto --against-input=.git#branch=main
consumer-driven-contracts
Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published pacts.
Parameters:
broker_url (string): Pact Broker base URL
consumer_version (string): Consumer application version
provider_url (string): Provider base URL for verification
Commands:
pact-broker publish pacts/ --consumer-app-version=1.2.3 --branch=main
pact-provider-verifier --provider-base-url=http://localhost:8080 --pact-url=http://broker/pacts/provider/Consumer/latest
pact-broker can-i-deploy --pacticipant=MyService --version=1.2.3 --to=production
Examples:
References
1---2name: "api-contract-validator"3description: "Validates API contracts across OpenAPI, GraphQL, and Protobuf formats. Runs schema validation, backward-compatibility checks, and consumer-driven contract verification with Pact, integrating gates into CI/CD pipelines. Use when working with schema validation, compatibility check, consumer driven contracts, api contract or when the user mentions schema validation, compatibility check, consumer driven contracts, api contract."4license: "MIT"5compatibility: "No special requirements."6metadata:7 source: https://skillmd.com/skills/opknock/api-contract-validator8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(buf:*) Bash(graphql-inspector:*) Bash(graphql-schema-linter:*) Bash(openapi-diff:*) Bash(pact-broker:*) Bash(pact-provider-verifier:*) Bash(spectral:*)"12---1314Validates API contracts across OpenAPI, GraphQL, and Protobuf formats. Runs schema validation, backward-compatibility checks, and consumer-driven contract verification with Pact, integrating gates into CI/CD pipelines.1516## Agentic Workflow: Read -> Reason -> Act (api-contract-validator)1718You are **API Contract Validator** (api/testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `api-contract-validator`21- Domain: Validates API contracts across OpenAPI, GraphQL, and Protobuf formats. Runs schema validation, backward-compatibility checks, and consumer-driven contract verification with Pact, integrating gates int22- **schema-validation**: Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance. — `swagger-cli validate openapi.yaml`23- **compatibility-check**: Detects breaking changes between API specification versions using spectral, openapi-diff, and graphq — `openapi-diff openapi-v1.yaml openapi-v2.yaml`24- **consumer-driven-contracts**: Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published — `pact-broker publish pacts/ --consumer-app-version=1.2.3 --branch=main`25- Check `knowledge` references before acting2627### 2. Reason — think for `api-contract-validator`28- For `schema-validation`: Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance. — decide which checks to run29- For `compatibility-check`: Detects breaking changes between API specification versions using spectral, openapi-diff, and graphql-inspector. — decide which checks to run30- For `consumer-driven-contracts`: Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published pacts. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `api-contract-validator` tools34- Tools: `Glob`, `Grep`, `Read`, `Swagger-cli`, `Spectral` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `api-contract-validator:3ecc328d`3738# API Contract Validator3940## What this agent does4142Ensures API contract quality across the lifecycle: schema validation for OpenAPI, GraphQL, and Protobuf;43automated breaking-change detection between versions; and consumer-driven contract testing with Pact.44Integrates validation gates into CI/CD to prevent incompatible changes from reaching production.4546## When to use4748- Validating API specifications before merge or release49- Detecting breaking changes in PRs or release branches50- Setting up consumer-driven contract pipelines with Pact Broker51- Enforcing API governance rules via Spectral rulesets52- Verifying provider compliance with consumer contracts5354## Real commands5556```bash57# Validate OpenAPI spec58swagger-cli validate ./api/openapi.yaml59spectral lint ./api/openapi.yaml --ruleset=spectral:oas6061# Detect breaking changes62openapi-diff ./api/v1.yaml ./api/v2.yaml --format=markdown63graphql-inspector diff ./schema-v1.graphql ./schema-v2.graphql64buf breaking ./proto --against-input=.git#branch=main6566# Pact workflow67pact-broker publish ./pacts --consumer-app-version=1.2.3 --branch=main68pact-provider-verifier --provider-base-url=http://localhost:8080 --pact-url=http://broker/pacts/provider/Consumer/latest69pact-broker can-i-deploy --pacticipant=OrdersAPI --version=1.2.3 --to=production70```7172## Spectral ruleset example7374```yaml75extends: ["spectral:oas"]76rules:77 operation-summary: error78 operation-description: warn79 no-server-example.com: error80```8182## Pact consumer test (JavaScript)8384```javascript85const { PactV3 } = require('@pact-foundation/pact');86const pact = new PactV3({ consumer: 'WebApp', provider: 'OrdersAPI' });8788await pact.addInteraction()89 .uponReceiving('a request for orders')90 .withRequest({ method: 'GET', path: '/orders' })91 .willRespondWith({ status: 200, body: eachLike({ id: '1', total: 100 }) });92```9394## Testing9596- Run `swagger-cli validate` and `spectral lint` in CI on every spec change97- Run `openapi-diff` or `graphql-inspector diff` in PR checks98- Run `pact-provider-verifier` against provider in CI before deployment99- Use `pact-broker can-i-deploy` as a deployment gate100101## Best practices102103- Store specs in version control alongside code104- Use a shared Spectral ruleset across teams for consistent governance105- Publish pacts on every consumer build; verify on every provider build106- Configure `can-i-deploy` with environment-specific criteria107- Version Protobuf schemas with buf and enforce breaking-change policy108109## Capabilities110111### schema-validation112Validates OpenAPI, GraphQL SDL, and Protobuf schemas for structural correctness and spec compliance.113114**Parameters:**115- `spec_path` (string): Path to the API specification file116- `format` (string): Specification format (openapi, graphql, protobuf)117- `ruleset` (string): Spectral ruleset for OpenAPI (spectral:oas, spectral:asyncapi)118119**Commands:**120- `swagger-cli validate openapi.yaml`121- `spectral lint openapi.yaml --ruleset=spectral:oas`122- `graphql-schema-linter schema.graphql`123- `buf lint protobuf/`124125**Examples:**126- swagger-cli validate ./api/openapi.yaml127- spectral lint ./api/openapi.yaml --ruleset=spectral:oas --format=stylish128- graphql-schema-linter ./schema.graphql129- buf lint ./proto130131### compatibility-check132Detects breaking changes between API specification versions using spectral, openapi-diff, and graphql-inspector.133134**Parameters:**135- `old_spec` (string): Path to the previous specification136- `new_spec` (string): Path to the new specification137- `format` (string): Output format (text, markdown, json)138139**Commands:**140- `openapi-diff openapi-v1.yaml openapi-v2.yaml`141- `spectral lint openapi-v2.yaml --ruleset=./breaking-ruleset.yaml`142- `graphql-inspector diff schema-v1.graphql schema-v2.graphql`143- `buf breaking protobuf/v1 --against=protobuf/v2`144145**Examples:**146- openapi-diff ./api/v1.yaml ./api/v2.yaml --format=markdown147- graphql-inspector diff ./schema-v1.graphql ./schema-v2.graphql --format=markdown148- buf breaking ./proto --against-input=.git#branch=main149150### consumer-driven-contracts151Runs Pact consumer tests, publishes contracts to a broker, and verifies providers against published pacts.152153**Parameters:**154- `broker_url` (string): Pact Broker base URL155- `consumer_version` (string): Consumer application version156- `provider_url` (string): Provider base URL for verification157158**Commands:**159- `pact-broker publish pacts/ --consumer-app-version=1.2.3 --branch=main`160- `pact-provider-verifier --provider-base-url=http://localhost:8080 --pact-url=http://broker/pacts/provider/Consumer/latest`161- `pact-broker can-i-deploy --pacticipant=MyService --version=1.2.3 --to=production`162163**Examples:**164- pact-broker publish ./pacts --consumer-app-version=1.2.3 --branch=main165- pact-provider-verifier --provider-base-url=http://localhost:8080 --pact-url=http://broker/pacts/provider/Consumer/latest166- pact-broker can-i-deploy --pacticipant=OrdersAPI --version=1.2.3 --to=production167168## References169- [OpenAPI Specification](https://spec.openapis.org/oas/v3.1.0)170- [Spectral Linting](https://meta.stoplight.io/docs/spectral)171- [Pact Contract Testing](https://docs.pact.io/)172- [GraphQL Schema Validation](https://github.com/graphql-schema-linter/graphql-schema-linter)173- [Buf Breaking Change Detection](https://buf.build/docs/cli/commands/buf-breaking)