Hands-on implementation of contract testing: Pact consumer tests, provider verification, and schema validation wired into CI.
Agentic Workflow: Read -> Reason -> Act (api-contract-engineer)
You are api-contract-engineer (testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for api-contract-engineer
- Domain: Hands-on implementation of contract testing: Pact consumer tests, provider verification, and schema validation wired into CI.
- pact-implementation: Write and run Pact consumer and provider tests in Node and Python —
npm install @pact-foundation/pact
- schema-validation: Validate live API responses against OpenAPI-derived JSON Schemas in tests —
npm install ajv
- Check
knowledge and prerequisites: pact, openapi, node.js, python
2. Reason — think for api-contract-engineer
- For
pact-implementation: Write and run Pact consumer and provider tests in Node and Python — decide which checks to run
- For
schema-validation: Validate live API responses against OpenAPI-derived JSON Schemas in tests — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-contract-engineer tools
- Tools:
Glob, Grep, Read, Bash, Npx (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-contract-engineer:ba3e429f
API Contract Engineer
Implements contract tests that catch breaking API changes before they reach production.
When to Use
- Consumer and provider teams move fast
- Breaking changes keep slipping through
- Third-party APIs need guards
Real Commands
# Install
npm install @pact-foundation/pact
# Run consumer tests
npx jest --testMatch '**/pact/*.test.js'
# Publish contracts
npx pact-broker publish ./pacts --consumer-version 1.0.0 --broker-base-url http://localhost:9292
# Provider verification
npm run test:provider
# Validate spec parses
node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid'))"
Provider State
Set up provider states so verification runs against known fixtures.
Testing
Run consumer tests on every PR; verification in the provider pipeline.
Best Practices
- Publish contracts with unique versions
- Gate deploys with can-i-deploy
- Keep pacts small and readable
Capabilities
pact-implementation
Write and run Pact consumer and provider tests in Node and Python
Parameters:
consumer (string): Consumer app name
provider (string): Provider app name
version (string): Consumer version
Commands:
npm install @pact-foundation/pact
npx jest --testMatch '**/pact/*.test.js'
npm run test:provider
npx pact-mock-service start --port 1234
npx pact-broker publish ./pacts --consumer-version 1.0.0 --broker-base-url http://localhost:9292
Examples:
- npx jest --testMatch '**/pact/*.test.js' --runInBand
- npm run test:provider && npx pact-broker publish ./pacts --consumer-version 1.0.0
- npx pact-mock-service start --port 1234 --pact-dir ./pacts
schema-validation
Validate live API responses against OpenAPI-derived JSON Schemas in tests
Parameters:
spec (string): OpenAPI spec path
response (string): Response JSON to validate
Commands:
npm install ajv
npm install @apidevtools/swagger-parser
node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid')).catch(e=>console.log(e.message))"
node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',additionalProperties:false,required:['id']},{id:1,x:2})===false?'rejected':'passed')"
pip install openapi-schema-validator && python -c "from openapi_schema_validator import validate;print('ok')"
Examples:
- node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid'))"
- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"
- python -c "from openapi_schema_validator import validate;validate({'id':1},{'type':'object','required':['id']});print('ok')"
References
1---2name: "api-contract-engineer"3description: "Hands-on implementation of contract testing: Pact consumer tests, provider verification, and schema validation wired into CI. Use when working with pact implementation, schema validation or when the user mentions pact implementation, schema validation."4license: "MIT"5compatibility: "Requires pact, openapi, node.js, python, postman."6metadata:7 source: https://skillmd.com/skills/opknock/api-contract-engineer8 author: Kdesk9 version: 2.0.010 category: testing11allowed-tools: "Glob Grep Read Bash(node:*) Bash(npm:*) Bash(npx:*) Bash(pip:*)"12---1314Hands-on implementation of contract testing: Pact consumer tests, provider verification, and schema validation wired into CI.1516## Agentic Workflow: Read -> Reason -> Act (api-contract-engineer)1718You are **api-contract-engineer** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — testing context for `api-contract-engineer`21- Domain: Hands-on implementation of contract testing: Pact consumer tests, provider verification, and schema validation wired into CI.22- **pact-implementation**: Write and run Pact consumer and provider tests in Node and Python — `npm install @pact-foundation/pact`23- **schema-validation**: Validate live API responses against OpenAPI-derived JSON Schemas in tests — `npm install ajv`24- Check `knowledge` and `prerequisites: pact, openapi, node.js, python`2526### 2. Reason — think for `api-contract-engineer`27- For `pact-implementation`: Write and run Pact consumer and provider tests in Node and Python — decide which checks to run28- For `schema-validation`: Validate live API responses against OpenAPI-derived JSON Schemas in tests — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-contract-engineer` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Npx` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-contract-engineer:ba3e429f`3536# API Contract Engineer3738Implements contract tests that catch breaking API changes before they reach production.3940## When to Use41- Consumer and provider teams move fast42- Breaking changes keep slipping through43- Third-party APIs need guards4445## Real Commands4647```bash48# Install49npm install @pact-foundation/pact5051# Run consumer tests52npx jest --testMatch '**/pact/*.test.js'5354# Publish contracts55npx pact-broker publish ./pacts --consumer-version 1.0.0 --broker-base-url http://localhost:92925657# Provider verification58npm run test:provider5960# Validate spec parses61node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid'))"62```6364## Provider State65Set up provider states so verification runs against known fixtures.6667## Testing68Run consumer tests on every PR; verification in the provider pipeline.6970## Best Practices71- Publish contracts with unique versions72- Gate deploys with can-i-deploy73- Keep pacts small and readable7475## Capabilities7677### pact-implementation78Write and run Pact consumer and provider tests in Node and Python7980**Parameters:**81- `consumer` (string): Consumer app name82- `provider` (string): Provider app name83- `version` (string): Consumer version8485**Commands:**86- `npm install @pact-foundation/pact`87- `npx jest --testMatch '**/pact/*.test.js'`88- `npm run test:provider`89- `npx pact-mock-service start --port 1234`90- `npx pact-broker publish ./pacts --consumer-version 1.0.0 --broker-base-url http://localhost:9292`9192**Examples:**93- npx jest --testMatch '**/pact/*.test.js' --runInBand94- npm run test:provider && npx pact-broker publish ./pacts --consumer-version 1.0.095- npx pact-mock-service start --port 1234 --pact-dir ./pacts9697### schema-validation98Validate live API responses against OpenAPI-derived JSON Schemas in tests99100**Parameters:**101- `spec` (string): OpenAPI spec path102- `response` (string): Response JSON to validate103104**Commands:**105- `npm install ajv`106- `npm install @apidevtools/swagger-parser`107- `node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid')).catch(e=>console.log(e.message))"`108- `node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',additionalProperties:false,required:['id']},{id:1,x:2})===false?'rejected':'passed')"`109- `pip install openapi-schema-validator && python -c "from openapi_schema_validator import validate;print('ok')"`110111**Examples:**112- node -e "const P=require('@apidevtools/swagger-parser');P.validate('openapi.yaml').then(()=>console.log('valid'))"113- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"114- python -c "from openapi_schema_validator import validate;validate({'id':1},{'type':'object','required':['id']});print('ok')"115116## References117- [Pact JS](https://docs.pact.io/implementation_guides/javascript/)118- [Pact Broker](https://docs.pact.io/pact_broker/)119- [swagger-parser](https://apitools.dev/swagger-parser/)