Designs consumer-driven contract testing setups: Pact workflows, contract publishing, and provider verification pipelines.
Agentic Workflow: Read -> Reason -> Act (api-contract-pact-workflow)
You are Api Contract Pact Workflow (testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for api-contract-pact-workflow
- Domain: Designs consumer-driven contract testing setups: Pact workflows, contract publishing, and provider verification pipelines.
- pact-workflow: Write consumer tests, publish contracts, and verify providers against them —
npm install @pact-foundation/pact
- schema-validation: Validate API responses against JSON Schema from OpenAPI —
npm install ajv
- Check
knowledge and prerequisites: pact, openapi, node.js, python
2. Reason — think for api-contract-pact-workflow
- For
pact-workflow: Write consumer tests, publish contracts, and verify providers against them — decide which checks to run
- For
schema-validation: Validate API responses against JSON Schema from OpenAPI — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-contract-pact-workflow 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-pact-workflow:710dc671
API Contract (Design)
Designs consumer-driven contract testing: who writes what, where contracts live, and how verification gates releases.
When to Use
- Microservices with many consumers
- Preventing breaking changes between teams
- Contract-first development
Real Commands
# Start a local Pact Broker
brew install pact_broker
# Publish contracts
npx pact-broker publish ./pacts -a 1.0.0 -b http://localhost:9292
# Gate deploys
npx pact-broker can-i-deploy --pacticipant consumer -a 1.0.0 --to prod -b http://localhost:9292
# Schema validation
npm install ajv
node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"
Design Decisions
- Consumer tests define the contract
- Provider verifies all consumer contracts in CI
- Broker is the integration point
Testing
Run can-i-deploy as the final gate in every release pipeline.
Best Practices
- One contract version per app version
- Tag prod versions in the broker
- Keep contracts small and focused
Capabilities
pact-workflow
Write consumer tests, publish contracts, and verify providers against them
Parameters:
broker (string): Pact Broker URL
participant (string): Consumer or provider name
Commands:
npm install @pact-foundation/pact
npx pact-broker publish ./pacts -a 1.0.0 -b http://localhost:9292
npx pact-broker can-i-deploy --pacticipant consumer -a 1.0.0 --to prod -b http://localhost:9292
npm install @pact-foundation/pact-node
npx pact-broker list-latest-pacticipant-versions consumer -b http://localhost:9292
Examples:
schema-validation
Validate API responses against JSON Schema from OpenAPI
Parameters:
schema (string): JSON Schema to validate against
data (string): Response data
Commands:
npm install ajv
node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"
npm install @apidevtools/json-schema-ref-parser
python -m pip install jsonschema && python -c "import jsonschema;print(jsonschema.validate({'id':1},{'type':'object','required':['id']}))"
node -e "const Ajv=require('ajv');const a=new Ajv();const v=a.compile({type:'object',required:['id']});try{v({x:1})}catch(e){console.log(e.message)}"
Examples:
- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"
- python -c "import jsonschema;jsonschema.validate({'x':1},{'type':'object','required':['id']})" 2>&1 | tail -1
- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'number',minimum:0},-1)===false?'rejected':'passed')"
References
1---2name: "api-contract-pact-workflow"3description: "Designs consumer-driven contract testing setups: Pact workflows, contract publishing, and provider verification pipelines. Use when working with pact workflow, schema validation or when the user mentions pact workflow, schema validation."4license: "MIT"5compatibility: "Requires pact, openapi, node.js, python, postman."6metadata:7 source: https://skillmd.com/skills/opknock/api-contract-pact-workflow8 author: Kdesk9 version: 2.0.010 category: testing11allowed-tools: "Glob Grep Read Bash(node:*) Bash(npm:*) Bash(npx:*) Bash(python:*)"12---1314Designs consumer-driven contract testing setups: Pact workflows, contract publishing, and provider verification pipelines.1516## Agentic Workflow: Read -> Reason -> Act (api-contract-pact-workflow)1718You are **Api Contract Pact Workflow** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — testing context for `api-contract-pact-workflow`21- Domain: Designs consumer-driven contract testing setups: Pact workflows, contract publishing, and provider verification pipelines.22- **pact-workflow**: Write consumer tests, publish contracts, and verify providers against them — `npm install @pact-foundation/pact`23- **schema-validation**: Validate API responses against JSON Schema from OpenAPI — `npm install ajv`24- Check `knowledge` and `prerequisites: pact, openapi, node.js, python`2526### 2. Reason — think for `api-contract-pact-workflow`27- For `pact-workflow`: Write consumer tests, publish contracts, and verify providers against them — decide which checks to run28- For `schema-validation`: Validate API responses against JSON Schema from OpenAPI — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-contract-pact-workflow` 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-pact-workflow:710dc671`3536# API Contract (Design)3738Designs consumer-driven contract testing: who writes what, where contracts live, and how verification gates releases.3940## When to Use41- Microservices with many consumers42- Preventing breaking changes between teams43- Contract-first development4445## Real Commands4647```bash48# Start a local Pact Broker49brew install pact_broker5051# Publish contracts52npx pact-broker publish ./pacts -a 1.0.0 -b http://localhost:92925354# Gate deploys55npx pact-broker can-i-deploy --pacticipant consumer -a 1.0.0 --to prod -b http://localhost:92925657# Schema validation58npm install ajv59node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"60```6162## Design Decisions63- Consumer tests define the contract64- Provider verifies all consumer contracts in CI65- Broker is the integration point6667## Testing68Run `can-i-deploy` as the final gate in every release pipeline.6970## Best Practices71- One contract version per app version72- Tag prod versions in the broker73- Keep contracts small and focused7475## Capabilities7677### pact-workflow78Write consumer tests, publish contracts, and verify providers against them7980**Parameters:**81- `broker` (string): Pact Broker URL82- `participant` (string): Consumer or provider name8384**Commands:**85- `npm install @pact-foundation/pact`86- `npx pact-broker publish ./pacts -a 1.0.0 -b http://localhost:9292`87- `npx pact-broker can-i-deploy --pacticipant consumer -a 1.0.0 --to prod -b http://localhost:9292`88- `npm install @pact-foundation/pact-node`89- `npx pact-broker list-latest-pacticipant-versions consumer -b http://localhost:9292`9091**Examples:**92- npx pact-broker publish ./pacts -a 1.0.0 -b http://localhost:929293- npx pact-broker can-i-deploy --pacticipant consumer -a 1.0.0 --to prod -b http://localhost:929294- npx pact-broker list-latest-pacticipant-versions consumer -b http://localhost:92929596### schema-validation97Validate API responses against JSON Schema from OpenAPI9899**Parameters:**100- `schema` (string): JSON Schema to validate against101- `data` (string): Response data102103**Commands:**104- `npm install ajv`105- `node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"`106- `npm install @apidevtools/json-schema-ref-parser`107- `python -m pip install jsonschema && python -c "import jsonschema;print(jsonschema.validate({'id':1},{'type':'object','required':['id']}))"`108- `node -e "const Ajv=require('ajv');const a=new Ajv();const v=a.compile({type:'object',required:['id']});try{v({x:1})}catch(e){console.log(e.message)}"`109110**Examples:**111- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'object',required:['id']},{id:1}))"112- python -c "import jsonschema;jsonschema.validate({'x':1},{'type':'object','required':['id']})" 2>&1 | tail -1113- node -e "const Ajv=require('ajv');const a=new Ajv();console.log(a.validate({type:'number',minimum:0},-1)===false?'rejected':'passed')"114115## References116- [Pact Docs](https://docs.pact.io/)117- [Pact Broker CLI](https://docs.pact.io/pact_broker/client_cli)118- [AJV](https://ajv.js.org/)