Wires contract testing into CI/CD: broker pipelines, deploy gates, and breaking-change detection for every release.
Agentic Workflow: Read -> Reason -> Act (api-contract-ci)
You are Api Contract Ci (testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for api-contract-ci
- Domain: Wires contract testing into CI/CD: broker pipelines, deploy gates, and breaking-change detection for every release.
- ci-integration: Add Pact publish, verify, and can-i-deploy steps to pipelines —
npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-u
- breaking-change-gates: Block incompatible spec changes with automated diffs —
openapi-diff --fail-on-incompatible main.yaml pr.yaml
- Check
knowledge and prerequisites: pact, openapi, node.js, python
2. Reason — think for api-contract-ci
- For
ci-integration: Add Pact publish, verify, and can-i-deploy steps to pipelines — decide which checks to run
- For
breaking-change-gates: Block incompatible spec changes with automated diffs — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-contract-ci tools
- Tools:
Glob, Grep, Read, Npx, Openapi-diff (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-contract-ci:e92a68e4
API Contract (CI/CD)
Makes contract tests a release gate, not an afterthought.
When to Use
- Releases break consumers silently
- Multiple teams share one API
- Need deploy-time confidence
Real Commands
# In the consumer pipeline
npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:9292
# In the provider pipeline
npx pact-provider-verifier --provider-base-url http://localhost:8080 --pact-broker-base-url http://localhost:9292 --provider api
# Gate the release
npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:9292
# Record the deployment
npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:9292
# Spec diff gate
openapi-diff --fail-on-incompatible main.yaml pr.yaml
Pipeline Layout
- Consumer: test, publish, can-i-deploy
- Provider: verify, can-i-deploy
- Release: record-deployment
Testing
Break a contract on purpose and confirm the gate blocks the release.
Best Practices
- Version every build
- Record deployments so the broker knows prod state
Capabilities
ci-integration
Add Pact publish, verify, and can-i-deploy steps to pipelines
Parameters:
broker (string): Broker base URL
environment (string): Deployment environment
buildNumber (string): Build/version identifier
Commands:
npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:9292
npx pact-provider-verifier --provider-base-url http://localhost:8080 --pact-broker-base-url http://localhost:9292 --provider api --consumer-version-selector '{"branch":"main"}'
npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:9292
npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:9292
npx pact-broker list-environments --broker-base-url http://localhost:9292
Examples:
- npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:9292
- npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:9292
- npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:9292
breaking-change-gates
Block incompatible spec changes with automated diffs
Parameters:
base (string): Baseline spec
candidate (string): PR spec
Commands:
openapi-diff --fail-on-incompatible main.yaml pr.yaml
git diff main.yaml pr.yaml --stat
npx @stoplight/spectral-cli lint pr.yaml
swagger-cli validate pr.yaml
openapi-diff --fail-on-changed main.yaml pr.yaml
Examples:
- openapi-diff --fail-on-incompatible main.yaml pr.yaml
- git diff main.yaml pr.yaml --stat && openapi-diff --fail-on-incompatible main.yaml pr.yaml
- swagger-cli validate pr.yaml && npx @stoplight/spectral-cli lint pr.yaml
References
1---2name: "api-contract-ci"3description: "Wires contract testing into CI/CD: broker pipelines, deploy gates, and breaking-change detection for every release. Use when working with ci integration, breaking change gates or when the user mentions ci integration, breaking change gates."4license: "MIT"5compatibility: "Requires pact, openapi, node.js, python, postman."6metadata:7 source: https://skillmd.com/skills/opknock/api-contract-ci8 author: Kdesk9 version: 2.0.010 category: testing11allowed-tools: "Glob Grep Read Bash(git:*) Bash(npx:*) Bash(openapi-diff:*) Bash(swagger-cli:*)"12---1314Wires contract testing into CI/CD: broker pipelines, deploy gates, and breaking-change detection for every release.1516## Agentic Workflow: Read -> Reason -> Act (api-contract-ci)1718You are **Api Contract Ci** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — testing context for `api-contract-ci`21- Domain: Wires contract testing into CI/CD: broker pipelines, deploy gates, and breaking-change detection for every release.22- **ci-integration**: Add Pact publish, verify, and can-i-deploy steps to pipelines — `npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-u`23- **breaking-change-gates**: Block incompatible spec changes with automated diffs — `openapi-diff --fail-on-incompatible main.yaml pr.yaml`24- Check `knowledge` and `prerequisites: pact, openapi, node.js, python`2526### 2. Reason — think for `api-contract-ci`27- For `ci-integration`: Add Pact publish, verify, and can-i-deploy steps to pipelines — decide which checks to run28- For `breaking-change-gates`: Block incompatible spec changes with automated diffs — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-contract-ci` tools32- Tools: `Glob`, `Grep`, `Read`, `Npx`, `Openapi-diff` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-contract-ci:e92a68e4`3536# API Contract (CI/CD)3738Makes contract tests a release gate, not an afterthought.3940## When to Use41- Releases break consumers silently42- Multiple teams share one API43- Need deploy-time confidence4445## Real Commands4647```bash48# In the consumer pipeline49npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:92925051# In the provider pipeline52npx pact-provider-verifier --provider-base-url http://localhost:8080 --pact-broker-base-url http://localhost:9292 --provider api5354# Gate the release55npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:92925657# Record the deployment58npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:92925960# Spec diff gate61openapi-diff --fail-on-incompatible main.yaml pr.yaml62```6364## Pipeline Layout65- Consumer: test, publish, can-i-deploy66- Provider: verify, can-i-deploy67- Release: record-deployment6869## Testing70Break a contract on purpose and confirm the gate blocks the release.7172## Best Practices73- Version every build74- Record deployments so the broker knows prod state7576## Capabilities7778### ci-integration79Add Pact publish, verify, and can-i-deploy steps to pipelines8081**Parameters:**82- `broker` (string): Broker base URL83- `environment` (string): Deployment environment84- `buildNumber` (string): Build/version identifier8586**Commands:**87- `npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:9292`88- `npx pact-provider-verifier --provider-base-url http://localhost:8080 --pact-broker-base-url http://localhost:9292 --provider api --consumer-version-selector '{"branch":"main"}'`89- `npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:9292`90- `npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:9292`91- `npx pact-broker list-environments --broker-base-url http://localhost:9292`9293**Examples:**94- npx pact-broker publish ./pacts --consumer-version $BUILD_NUMBER --broker-base-url http://localhost:929295- npx pact-broker can-i-deploy --pacticipant api --version $BUILD_NUMBER --to prod --broker-base-url http://localhost:929296- npx pact-broker record-deployment --pacticipant api --version $BUILD_NUMBER --environment prod --broker-base-url http://localhost:92929798### breaking-change-gates99Block incompatible spec changes with automated diffs100101**Parameters:**102- `base` (string): Baseline spec103- `candidate` (string): PR spec104105**Commands:**106- `openapi-diff --fail-on-incompatible main.yaml pr.yaml`107- `git diff main.yaml pr.yaml --stat`108- `npx @stoplight/spectral-cli lint pr.yaml`109- `swagger-cli validate pr.yaml`110- `openapi-diff --fail-on-changed main.yaml pr.yaml`111112**Examples:**113- openapi-diff --fail-on-incompatible main.yaml pr.yaml114- git diff main.yaml pr.yaml --stat && openapi-diff --fail-on-incompatible main.yaml pr.yaml115- swagger-cli validate pr.yaml && npx @stoplight/spectral-cli lint pr.yaml116117## References118- [Pact Broker can-i-deploy](https://docs.pact.io/pact_broker/can_i_deploy)119- [Pact Broker Environments](https://docs.pact.io/pact_broker/recording_deployments)