# Contract enforcement

> Contract enforcement is an open-source agent skill for developer tools. Keeps mocks honest by tying them to typed ports, OpenAPI schemas and Pact contracts. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/zerotechdebt/ffflow/tree/main/plugin/skills/contract-enforcement
- **Repository:** https://github.com/zerotechdebt/ffflow
- **GitHub stars:** 6
- **License:** Apache-2.0
- **Skill name:** contract-enforcement
- **Collection:** https://github.com/zerotechdebt/ffflow
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This reference rulebook argues that every mock makes a claim about how a dependency behaves, and that claim should be checked against something verifiable. It tells the agent to mock against the full typed port interface rather than ad-hoc partial stubs, and to pair each mock with adapter tests that run the real implementation against the same interface. When a port changes, the mock tests and adapter tests are expected to change together.

For cross-language boundaries, such as a FastAPI backend feeding a TypeScript frontend, the skill describes generating the OpenAPI schema from Pydantic models and then generating frontend types from it. It includes a CI check that regenerates the types and fails the build if the committed file differs. For services owned by separate teams, it describes consumer-driven contract testing with Pact, where consumers publish expectations and providers verify against them before deploying.

The skill is a rulebook loaded as context by other workflow skills when ports are involved, not a tool the agent invokes directly. It expects a project with port interfaces, typed mocks and, where relevant, FastAPI and openapi-typescript or Pact in its build pipeline.

## When your agent uses it

> Mocks must be anchored to verifiable contracts — typed mocks against ports, adapter tests on the same interface, OpenAPI schema generation, consumer-driven contracts. L2+ reference rulebook.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/zerotechdebt/ffflow/tree/HEAD/plugin/skills/contract-enforcement)
- [License: Apache-2.0](https://github.com/zerotechdebt/ffflow/tree/HEAD/plugin/skills/contract-enforcement)

## Features

- **Typed mock rule:** Requires unit tests to mock against the full typed port interface instead of partial ad-hoc stubs.
- **Adapter contract tests:** Verifies that real adapter implementations satisfy the same interface the mocks use.
- **OpenAPI type generation:** Exports a FastAPI OpenAPI schema and generates TypeScript types from it for the frontend.
- **Build-time drift check:** Fails the build when generated contract types change without being regenerated and committed.
- **Consumer-driven contracts:** Describes Pact-based testing where consumers declare needs and providers verify them.

## Good for

- Check that unit test mocks still match a changed port interface
- Set up adapter tests that run against the same interface as the mocks
- Generate TypeScript types from a FastAPI OpenAPI schema
- Add a CI step that catches stale generated API types
- Plan Pact consumer contracts between services owned by different teams

## Install

### Claude Code

This skill ships in the `fff` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add zerotechdebt/ffflow
/plugin install fff@ffflow
```

Or copy only this skill to `~/.claude/skills/contract-enforcement`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/contract-enforcement &&
cp -R "$tmp/plugin/skills/contract-enforcement" ~/.claude/skills/contract-enforcement &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/contract-enforcement` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/contract-enforcement` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/contract-enforcement &&
cp -R "$tmp/plugin/skills/contract-enforcement" ~/.agents/skills/contract-enforcement &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/contract-enforcement` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/contract-enforcement` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/contract-enforcement &&
cp -R "$tmp/plugin/skills/contract-enforcement" ~/.cursor/skills/contract-enforcement &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/contract-enforcement` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/zerotechdebt/ffflow.git --path plugin/skills/contract-enforcement
```

Or copy the folder to `~/.gemini/skills/contract-enforcement` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/contract-enforcement`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/contract-enforcement &&
cp -R "$tmp/plugin/skills/contract-enforcement" ~/.copilot/skills/contract-enforcement &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/contract-enforcement` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git
```

Then copy `ffflow/plugin/skills/contract-enforcement` into your agent's skills folder as `contract-enforcement`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When is Contract enforcement loaded?

It is loaded as context by the work-issue and plan-chat skills when ports are involved. It is not invoked as a tool on its own.

### Does Contract enforcement require a specific language or framework?

The rules mention TypeScript types or Python Protocols and ABCs for ports, and a FastAPI backend with a TypeScript frontend for the OpenAPI example.

### What does the OpenAPI check run?

The example CI check runs a Python script to export openapi.json, regenerates types with openapi-typescript, and then checks with git diff that the generated file is unchanged.

### Does the skill include scripts?

No. It is a single SKILL.md file with no bundled scripts; the commands it shows are examples for the user's own project.

### How do I install Contract enforcement in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/contract-enforcement to use it in all your projects, or to .claude/skills/contract-enforcement in one project. Or install the fff plugin, which includes it: /plugin marketplace add zerotechdebt/ffflow, then /plugin install fff@ffflow.

### Does Contract enforcement run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Contract enforcement?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Contract enforcement?

The closest alternatives to Contract enforcement are Contract first, Testing conventions, API mock helper, API mocking and Contract author.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Contract first](https://ai-powered.com/skills/contract-first): Contract first is an open-source agent skill for developer tools.
- [Testing conventions](https://ai-powered.com/skills/testing-conventions): Testing conventions is an open-source agent skill for developer tools.
- [API mock helper](https://ai-powered.com/skills/api-mock-helper): API mock helper is an open-source agent skill for developer tools.
- [API mocking](https://ai-powered.com/skills/api-mocking): API mocking is an open-source agent skill for developer tools.
- [Contract author](https://ai-powered.com/skills/contract-author): Contract author is an open-source agent skill for developer tools.
- [TypeScript best practices](https://ai-powered.com/skills/typescript-best-practices): TypeScript best practices is an open-source agent skill for developer tools.
- [Contracts](https://ai-powered.com/skills/contracts-ramboz): Contracts is an open-source agent skill for developer tools.
- [Contract auditor](https://ai-powered.com/skills/contract-auditor): Contract auditor is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/contract-enforcement
