code-check-contracts

Detect runtime contract drift between producers and consumers from git diffs.

22|3|Updated Jul 28, 2024
One-click install
npx skills add https://github.com/webdevcody/go-mailing-list --skill code-check-contracts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-check-contracts
Source: https://github.com/webdevcody/go-mailing-list/tree/main/.claude/skills/code-check-contracts
Command: npx skills add https://github.com/webdevcody/go-mailing-list --skill code-check-contracts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents runtime bugs caused by producer/consumer contract drift, such as renamed fields, changed route params/search params, or mismatched DTO/Zod/DB shapes that TypeScript can’t fully guarantee across boundaries.

Core Features & Use Cases

  • Audits client/server contract drift across server functions, route handlers, tRPC procedures, Zod/DTO definitions, DB schemas, and route param/search definitions.
  • Ranks findings by severity and distinguishes safe mechanical renames from structural changes that require domain review.
  • Finds and updates call sites for mechanical renames (while never auto-fixing removals or semantic changes).
  • Reports full evidence by pointing to producer and consumer locations (including the differing field names) so reviewers can verify quickly.

Quick Start

Run the contract scan after any change that crosses the client/server boundary by triggering it with the instruction: "check contracts for drift in the current diff".

Frequently Asked Questions about code-check-contracts

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

FAQPage Schema
How do I detect API contract drift between my server routes and client call sites?

Detect API contract drift by comparing changed server routes, procedures, and expected Zod/DTO/DB shapes against all known TypeScript call sites. This Skill scans git diffs to find mismatches like renamed fields or changed route params before they cause runtime errors.

Why does TypeScript not catch Zod to DB to DTO divergence across boundaries?

TypeScript cannot fully guarantee type safety across runtime boundaries like Zod to DB to DTO divergence because generated clients and serialized shapes often bypass static checks. Contract scanning extracts before and after shapes from git diffs to find these mismatches.

What is the best way to find stale generated client surfaces after editing API procedures?

Find stale generated client surfaces by scanning git diffs for changed server procedures and comparing their expected shapes against actual TS/TSX call sites. This process reports evidence with producer and consumer locations for quick verification.

Can I automatically fix renamed fields in my API consumers without breaking semantic changes?

You can automatically fix mechanical field renames across API consumers, but the Skill never auto-fixes removals or semantic changes. It ranks findings by severity and distinguishes safe renames from structural changes that require manual domain review.

Does this contract testing approach work with tRPC procedures and OpenAPI shapes?

This contract testing approach works with tRPC procedures, OpenAPI shapes, Zod definitions, and DB schemas. It audits client/server contract drift across these boundaries by extracting changed shapes from git diffs and scanning relevant TypeScript call sites.

When should I not use automated contract drift fixing for API changes?

Avoid automated contract drift fixing for field removals, structural changes, or semantic modifications. The tool only auto-fixes mechanical renames and explicitly leaves removals and semantic changes for manual domain review to prevent unintended behavior shifts.