secondsky/claude-skills / plugins/api-contract-testing/skills/api-contract-testing
api-contract-testing
VerifiedVerifies API contracts between services using consumer-driven contracts, schema validation, and tools like Pact. Use when testing microservices communication, preventing breaking changes, or validating OpenAPI specifications.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.8 KB |
| references/java-rest-assured.md | markdown | 4.5 KB |
| references/pact-broker-cicd.md | markdown | 4.3 KB |
| references/python-json-schema.md | markdown | 12.0 KB |
references/pact-broker-cicd.md
View on GitHub# Pact Broker CI/CD Integration
GitHub Actions workflow for consumer-driven contract testing with Pact Broker.
## Consumer Workflow
```yaml
# .github/workflows/consumer-contracts.yml
name: Consumer Contract Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
contract-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run consumer contract tests
run: npm run test:contract
env:
CI: true
- name: Publish contracts to Pact Broker
if: github.ref == 'refs/heads/main'
run: |
npx pact-broker publish ./pacts \
--consumer-app-version=${{ github.sha }} \
--branch=${{ github.ref_name }} \
--broker-base-url=${{ secrets.PACT_BROKER_URL }} \
--broker-token=${{ secrets.PACT_BROKER_TOKEN }}
- name: Check if can deploy
if: github.ref == 'refs/heads/main'
run: |
npx pact-broker can-i-deploy \
--pacticipant=OrderService \
--version=${{ github.sha }} \
--to-environment=production \
--broker-base-url=${{ secrets.PACT_BROKER_URL }} \
--broker-token=${{ secrets.PACT_BROKER_TOKEN }}
```
## Provider Workflow
```yaml
# .github/workflows/provider-verification.yml
name: Provider Contract Verification
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
# Triggered by Pact Broker webhooks
repository_dispatch:
types: [pact_changed]
jobs:
verify-contracts:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Start provider service
run: npm run start:test &
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
- name: Wait for service
run: npx wait-on http://localhost:3000/health
- name: Verify contracts
run: |
npx pact-broker verify \
--provider=UserService \
--provider-app-version=${{ github.sha }} \
--provider-base-url=http://localhost:3000 \
--publish-verification-results \
--broker-base-url=${{ secrets.PACT_BROKER_URL }} \
--broker-token=${{ secrets.PACT_BROKER_TOKEN }}
- name: Record deployment
if: github.ref == 'refs/heads/main'
run: |
npx pact-broker record-deployment \
--pacticipant=UserService \
--version=${{ github.sha }} \
--environment=production \
--broker-base-url=${{ secrets.PACT_BROKER_URL }} \
--broker-token=${{ secrets.PACT_BROKER_TOKEN }}
```
## Pact Broker Webhook Configuration
Configure webhooks in Pact Broker to trigger provider verification when contracts change:
```json
{
"description": "Trigger provider verification on contract change",
"events": [
{"name": "contract_content_changed"}
],
"request": {
"method": "POST",
"url": "https://api.github.com/repos/OWNER/PROVIDER_REPO/dispatches",
"headers": {
"Accept": "application/vnd.github.v3+json",
"Authorization": "Bearer ${GITHUB_TOKEN}"
},
"body": {
"event_type": "pact_changed",
"client_payload": {
"pact_url": "${pactbroker.pactUrl}"
}
}
}
}
```
## Matrix Testing Strategy
Test all consumer-provider combinations:
```yaml
jobs:
verify-contracts:
strategy:
matrix:
consumer: [OrderService, InventoryService, NotificationService]
steps:
- name: Verify contracts from ${{ matrix.consumer }}
run: |
npx pact-broker verify \
--provider=UserService \
--consumer-version-selectors='{"mainBranch": true}' \
--provider-app-version=${{ github.sha }}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |