contract-test — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited contract-test (Agent Skill) and scored it 96/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 1 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 1 flagged
The text {match} tells the agent to skip the normal "ask the user first" gate. Used adversarially it removes the human-in-the-loop check before destructive or sensitive actions, turning a normally-gated agent into a fire-and-forget executor.
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
You are in AUTONOMOUS MODE. Do NOT ask questions. Detect the API framework, generate contract tests to validate API schemas, verify backward compatibility, and configure CI-based contract verification.
INPUT: $ARGUMENTS
If arguments are provided, focus on those specific APIs, consumers, or contracts. If no arguments are provided, generate contract tests for ALL API endpoints.
============================================================ PHASE 1: API DISCOVERY ============================================================
Step 1.1 -- Detect API Framework
Scan for the API framework:
| Indicator | Framework |
|---|---|
| package.json with fastify | Fastify |
| package.json with express | Express |
| package.json with @nestjs/core | NestJS |
| manage.py + settings.py | Django |
| requirements.txt with fastapi | FastAPI |
| requirements.txt with flask | Flask |
| go.mod + net/http or gin or echo | Go |
| Gemfile with rails | Ruby on Rails |
| pubspec.yaml with shelf or dart_frog | Dart backend |
Record: framework, language, base URL, API versioning scheme (if any).
Step 1.2 -- Detect Existing API Specification
Check for existing API documentation:
| Indicator | Spec Type |
|---|---|
| openapi.yaml, openapi.json, swagger.yaml, swagger.json | OpenAPI/Swagger |
| api-docs/ directory | OpenAPI |
| graphql.schema, schema.graphql, *.graphql files | GraphQL SDL |
| proto/ directory, *.proto files | gRPC/Protobuf |
| asyncapi.yaml, asyncapi.json | AsyncAPI (events) |
| pact/ directory, pact-config.* | Pact contracts |
| dredd.yml | Dredd API testing |
| .spectral.yaml | Spectral linting |
Step 1.3 -- Discover All Endpoints
Build the full endpoint inventory by scanning route registrations, controller decorators, and URL patterns for the detected framework.
For each endpoint, extract the ACTUAL contract:
REQUEST CONTRACT:
RESPONSE CONTRACT:
Build the contract table:
| Endpoint | Method | Request Schema | Response 2xx Schema | Error Schema | Auth |
|---|
Step 1.4 -- Identify Consumers
Determine who consumes this API:
If consumers are in the same repo, read their API call code to extract ACTUAL usage patterns (which fields they send, which fields they read).
============================================================ PHASE 2: CONTRACT TOOL SETUP ============================================================
Step 2.1 -- Select Contract Testing Approach
Choose based on project needs:
APPROACH 1 -- OPENAPI VALIDATION (schema-first): Best for: Projects with an OpenAPI spec, or projects that should have one. Tools: Prism (mock server), Spectral (linting), committee (Ruby), openapi-enforcer (Node.js)
APPROACH 2 -- CONSUMER-DRIVEN CONTRACTS (Pact): Best for: Microservice architectures with multiple consumers. Tools: Pact (pact-js, pact-python, pact-go)
APPROACH 3 -- API BLUEPRINT + DREDD: Best for: Projects using API Blueprint documentation. Tools: Dredd
APPROACH 4 -- SCHEMA SNAPSHOT TESTING: Best for: Simple projects where a full contract framework is overkill. Tools: Jest/Vitest snapshot tests on API response shapes
Decision logic:
Step 2.2 -- Install Tools
FOR OPENAPI VALIDATION:
If no OpenAPI spec exists, generate one:
| Framework | Generation Method |
|---|---|
| Fastify | Use @fastify/swagger to auto-generate from route schemas |
| Express + Zod/Joi | Extract schemas from validation middleware |
| NestJS | Use @nestjs/swagger decorators (may already exist) |
| FastAPI | Auto-generated at /openapi.json |
| Django REST | Use drf-spectacular or drf-yasg |
| Go (Gin/Echo) | Use swaggo/swag annotations |
Install validation tools:
FOR PACT:
Install consumer and provider packages:
FOR SCHEMA SNAPSHOTS:
No additional installation needed. Uses existing test framework snapshot capabilities.
============================================================ PHASE 3: CONTRACT TEST GENERATION ============================================================
Step 3.1 -- OpenAPI Validation Tests
If using APPROACH 1:
SPEC LINTING:
deprecated endpoints without alternatives
RESPONSE VALIDATION: For each endpoint, generate a test that:
REQUEST VALIDATION: For each endpoint, generate a test that:
SCHEMA FUZZ TESTING:
Step 3.2 -- Consumer-Driven Contract Tests (Pact)
If using APPROACH 2:
CONSUMER SIDE: For each consumer, generate a Pact test that:
Interactions to define:
PROVIDER SIDE: Generate a provider verification test that:
Provider state handlers:
Step 3.3 -- Schema Snapshot Tests
If using APPROACH 4:
For each endpoint, generate a test that:
Shape extraction function:
Step 3.4 -- Backward Compatibility Tests
Generate tests that verify API changes do not break existing consumers:
FIELD REMOVAL:
FIELD TYPE CHANGE:
REQUIRED FIELD ADDITION (request):
STATUS CODE CHANGE:
URL CHANGE:
Generate a compatibility report:
| Change | Type | Breaking? | Affected Consumers |
|---|
============================================================ PHASE 4: EXECUTION ============================================================
Step 4.1 -- Run Contract Tests
Execute all generated contract tests:
| Approach | Command |
|---|---|
| OpenAPI + Prism | npx prism mock openapi.yaml && run validation tests |
| OpenAPI + Schemathesis | schemathesis run http://localhost:PORT/openapi.json |
| Spectral linting | npx spectral lint openapi.yaml |
| Pact consumer | npx vitest run tests/contract/consumer/ |
| Pact provider | npx vitest run tests/contract/provider/ |
| Schema snapshots | npx vitest run tests/contract/ |
Step 4.2 -- Self-Healing Loop (max 3 iterations)
For each failure, diagnose:
SPEC MISMATCH: The API response does not match the documented schema. -> Either fix the API to match the spec, or update the spec to match reality. -> Prefer fixing the spec if the API behavior is intentional.
CONTRACT VIOLATION: Provider does not satisfy consumer expectations. -> Fix the provider if the consumer expectation is valid. -> Update the consumer contract if the expectation was wrong.
SNAPSHOT DRIFT: Response shape changed from baseline. -> If intentional: update the snapshot. -> If unintentional: fix the API to restore the original shape.
Step 4.3 -- Publish Contracts (if using Pact)
If a Pact Broker is configured:
============================================================ OUTPUT ============================================================
| Endpoint | Request Valid | Response Valid | Types Match | Backward Compatible |
|---|
| Change Detected | Type | Breaking | Action Required |
|---|
NEXT STEPS:
/integration-test to verify the contracts hold under real conditions."/test-suite to see overall test health with contract coverage."/load-test to verify contract-compliant endpoints perform under load."DO NOT:
============================================================ SELF-EVOLUTION TELEMETRY ============================================================
After producing output, record execution metadata for the /evolve pipeline.
Check if a project memory directory exists:
~/.claude/projects/skill-telemetry.md in that memory directoryEntry format:
### /contract-test — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}Only log if the memory directory exists. Skip silently if not found. Keep entries concise — /evolve will parse these for skill improvement signals.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.