contracts

Generates mocks and observability wiring from a contract.go file for Go packages.

4|1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/reliant-labs/forge --skill contracts-reliant-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contracts
Source: https://github.com/reliant-labs/forge/tree/main/internal/templates/project/skills/forge/contracts
Command: npx skills add https://github.com/reliant-labs/forge --skill contracts-reliant-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Contracts ensure your internal Go packages expose stable, mockable interfaces so tests can validate behavior without relying on concrete implementations and side effects.

Core Features & Use Cases

  • Define contract.go per internal package to establish the package’s public surface as an interface for consumers.
  • Generate mocks and cross-cutting middleware seams with forge generate, enabling consistent logging/tracing/metrics/test scaffolding around the contract boundary.
  • Adopt strict contract linting via forge lint --contract and forge.yaml so missing contracts are caught immediately as a change is introduced.

Quick Start

Add an internal/<package>/contract.go that defines the interface for your package, then run forge generate so mocks and the observe wiring hooks are produced automatically.

Frequently Asked Questions about contracts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make internal Go interfaces testable without depending on concrete implementations?

Make internal Go interfaces testable by defining a contract.go file per package to establish a stable public surface, then generate mocks and observability seams automatically via forge generate. This enables behavior validation without side effects.

What is a contract.go file and when do I need one for Go package testing?

A contract.go file defines an internal Go package's public surface as an interface for consumers. You need one when establishing test seams for greenfield packages or migrating existing packages to enforce strict contract linting and mock generation.

How do I generate mocks and observability middleware for Go interfaces?

Generate mocks and observability middleware for Go interfaces by adding an internal/<package>/contract.go file and running forge generate. This produces logging, tracing, metrics, and test scaffolding around the contract boundary automatically.

Can I enforce strict interface naming conventions and prevent missing contracts in Go?

Enforce strict interface naming conventions and prevent missing contracts in Go by configuring forge lint --contract with forge.yaml. This catches missing contracts immediately as a change is introduced, satisfying functional linting requirements.

What is the best way to migrate existing Go packages to a contract workflow?

Migrate existing Go packages to a contract workflow by introducing a contract.go file to define the interface, then running forge generate to produce mocks and observe wiring hooks. Apply strict contract linting via forge.yaml to prevent regressions.

Why should generated mock artifacts not be hand-edited in Go contract testing?

Generated mock artifacts in Go contract testing should not be hand-edited because regeneration rules override manual changes during forge generate. Hand-editing breaks strict contract linting and disrupts the automated observability integration and middleware seams.