contract-testing-builder
Implements API contract testing to ensure provider-consumer compatibility using Pact or similar tools. Prevents breaking changes with contract specifications and bi-directional verification. Use for "contract testing", "API contracts", "Pact", or "consumer-driven contracts".
What this skill does
# Contract Testing Builder
Ensure API contracts don't break consumers.
## Contract Testing Concepts
```
Consumer → Defines expected contract → Provider must satisfy
Benefits:
- Catch breaking changes early
- Independent development
- Fast feedback (no integration env needed)
- Documentation as code
```
## Pact Setup (Consumer Side)
```typescript
// consumer/tests/pacts/user-api.pact.test.ts
import { PactV3 } from "@pact-foundation/pact";
import { userApi } from "../api/userApi";
const provider = new PactV3({
consumer: "UserWebApp",
provider: "UserAPI",
dir: path.resolve(__dirname, "../../pacts"),
});
describe("User API Contract", () => {
it("should get user by ID", async () => {
// Define expected interaction
await provider
.given("user 123 exists")
.uponReceiving("a request for user 123")
.withRequest({
method: "GET",
path: "/api/users/123",
headers: {
Authorization: "Bearer token123",
},
})
.willRespondWith({
status: 200,
headers: {
"Content-Type": "application/json",
},
body: {
id: "123",
email: "[email protected]",
name: "John Doe",
role: "USER",
createdAt: like("2024-01-01T00:00:00Z"),
},
})
.executeTest(async (mockServer) => {
// Make actual API call against mock server
const user = await userApi.getUser("123", mockServer.url);
// Verify consumer can handle response
expect(user.id).toBe("123");
expect(user.email).toBe("[email protected]");
});
});
it("should return 404 when user not found", async () => {
await provider
.given("user 999 does not exist")
.uponReceiving("a request for non-existent user")
.withRequest({
method: "GET",
path: "/api/users/999",
})
.willRespondWith({
status: 404,
headers: {
"Content-Type": "application/json",
},
body: {
error: "User not found",
},
})
.executeTest(async (mockServer) => {
await expect(userApi.getUser("999", mockServer.url)).rejects.toThrow(
"User not found"
);
});
});
});
```
## Pact Verification (Provider Side)
```typescript
// provider/tests/pacts/verify.test.ts
import { Verifier } from "@pact-foundation/pact";
import { app } from "../src/app";
describe("Pact Verification", () => {
let server: Server;
beforeAll(async () => {
server = app.listen(3000);
});
afterAll(() => {
server.close();
});
it("should validate consumer contracts", async () => {
const verifier = new Verifier({
provider: "UserAPI",
providerBaseUrl: "http://localhost:3000",
// Fetch pacts from broker or local files
pactUrls: [
path.resolve(__dirname, "../../pacts/UserWebApp-UserAPI.json"),
],
// Provider states setup
stateHandlers: {
"user 123 exists": async () => {
// Seed database with user 123
await db.user.create({
id: "123",
email: "[email protected]",
name: "John Doe",
role: "USER",
});
},
"user 999 does not exist": async () => {
// Ensure user 999 doesn't exist
await db.user.deleteMany({ where: { id: "999" } });
},
},
// Teardown after each test
afterEach: async () => {
await db.$executeRaw`TRUNCATE TABLE users CASCADE`;
},
});
await verifier.verifyProvider();
});
});
```
## OpenAPI Contract Testing
```yaml
# contracts/user-api.yaml
openapi: 3.0.0
info:
title: User API
version: 1.0.0
paths:
/api/users/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: User found
content:
application/json:
schema:
$ref: "#/components/schemas/User"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
User:
type: object
required:
- id
- email
- name
- role
properties:
id:
type: string
email:
type: string
format: email
name:
type: string
role:
type: string
enum: [USER, ADMIN]
createdAt:
type: string
format: date-time
```
## Contract Validation (OpenAPI)
```typescript
// tests/contract-validation.test.ts
import * as OpenAPIValidator from "express-openapi-validator";
import * as fs from "fs";
import * as yaml from "js-yaml";
describe("API Contract Validation", () => {
it("should match OpenAPI spec", async () => {
const spec = yaml.load(
fs.readFileSync("./contracts/user-api.yaml", "utf8")
);
app.use(
OpenAPIValidator.middleware({
apiSpec: spec,
validateRequests: true,
validateResponses: true,
})
);
// Valid request - should pass
await request(app)
.get("/api/users/123")
.expect(200)
.expect((res) => {
expect(res.body).toHaveProperty("id");
expect(res.body).toHaveProperty("email");
expect(res.body).toHaveProperty("name");
expect(res.body).toHaveProperty("role");
});
});
it("should reject invalid responses", async () => {
// Mock endpoint that returns invalid data
app.get("/api/invalid", (req, res) => {
res.json({
id: "123",
// Missing required fields!
});
});
// Should fail validation
await request(app).get("/api/invalid").expect(500);
});
});
```
## JSON Schema Validation
```typescript
// schemas/user.schema.ts
export const userSchema = {
type: "object",
required: ["id", "email", "name", "role"],
properties: {
id: { type: "string" },
email: { type: "string", format: "email" },
name: { type: "string", minLength: 1 },
role: { type: "string", enum: ["USER", "ADMIN"] },
createdAt: { type: "string", format: "date-time" },
},
additionalProperties: false,
};
// tests/schema-validation.test.ts
import Ajv from "ajv";
import addFormats from "ajv-formats";
const ajv = new Ajv();
addFormats(ajv);
describe("User Schema Validation", () => {
const validate = ajv.compile(userSchema);
it("should validate correct user object", () => {
const user = {
id: "123",
email: "[email protected]",
name: "John Doe",
role: "USER",
createdAt: "2024-01-01T00:00:00Z",
};
expect(validate(user)).toBe(true);
});
it("should reject missing required fields", () => {
const user = {
id: "123",
email: "[email protected]",
// Missing name and role
};
expect(validate(user)).toBe(false);
expect(validate.errors).toContainEqual(
expect.objectContaining({
message: "must have required property 'name'",
})
);
});
it("should reject invalid email format", () => {
const user = {
id: "123",
email: "invalid-email",
name: "John Doe",
role: "USER",
};
expect(validate(user)).toBe(false);
});
});
```
## CI Integration
```yaml
# .github/workflows/contract-tests.yml
name: Contract Tests
on: [push, pull_request]
jobs:
consumer-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Run consumer tests
run: npm run test:pact
- name: Publish pacts
run: |
npx pact-broker publish \
./pacts \
--consumer-app-version=${{ github.sha }} \
--broker-base-url=${{ secrets.PACT_BROKER_URL }} \
--broker-token=${{ secrets.PACT_BROKERRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.