explaingit

pluviobyte/contractspec

Analysis updated 2026-05-18

13JavaScriptAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A workflow add-on that forces AI coding assistants to agree on shared contracts before writing full-stack code, preventing frontend and backend drift.

Mindmap

mindmap
  root((ContractSpec))
    What it does
      Shared contracts first
      Prevents AI drift
      Built on OpenSpec
    Tech stack
      JavaScript
      TypeScript
      OpenSpec
    Use cases
      Define contracts early
      Validate alignment
      Stop invented fields
    Audience
      Developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Define shared contracts for a full-stack feature before letting an AI write any code.

USE CASE 2

Validate that frontend, backend, and test files stay aligned with the agreed contracts.

USE CASE 3

Stop an AI coding agent from inventing API fields or silently changing error formats.

What is it built with?

JavaScriptTypeScriptOpenSpec

How does it compare?

pluviobyte/contractspec09catho/axonabdulrdeveloper/react--tic-tac-toe
Stars131313
LanguageJavaScriptJavaScriptJavaScript
Setup difficultymoderatemoderateeasy
Complexity3/54/51/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Alpha software built on OpenSpec, the README recommends pairing it with executable schemas before production use.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

ContractSpec is a workflow add-on for teams building software with AI coding assistants. It addresses a specific problem: when you let an AI write code for a full-stack application (one that has both a frontend and a backend), the AI tends to invent details that were never agreed on. The frontend might ask for fields the backend never sends. Error messages might be formatted differently on each layer. Tests might get written after the implementation and simply confirm what the code already does rather than checking what the product actually requires. ContractSpec is designed to prevent that drift by requiring all layers to be defined in shared contract documents before any code is written. The tool builds on top of OpenSpec, an existing AI coding workflow system. ContractSpec adds a schema bundle and a validator on top of OpenSpec's lifecycle. Before implementation starts, you define a set of contracts covering the product intent, the data model, the API endpoints, the error formats, the UI states, and the tests. A "bindings" file then maps each contract to the actual code artifacts it governs: which TypeScript types, which API routes, which test files, which generated clients. The validator can check that all these pieces exist and align with each other. The workflow enforces a specific order: write contracts first, then write failing tests from those contracts, then implement the feature, then verify against the evidence. AI agents working in this workflow are given explicit rules: do not invent API fields, do not invent UI states, do not change error formats silently, and do not write tests that simply mirror the implementation you just wrote. If the implementation reveals that a contract was incomplete, the agent is expected to update the contracts first before continuing. A command-line validator checks that all required contract files exist, that each section covers the expected concepts (loading states, error codes, auth requirements, and so on), and that tasks are written as vertical slices with checkbox tracking. Running the validator gives developers a structured audit of whether the change folder is complete before code is applied. The project is in alpha and MIT-licensed. The README recommends pairing it with executable schemas, shared types, and CI checks before using it in production.

Copy-paste prompts

Prompt 1
Set up ContractSpec on top of OpenSpec for this full-stack project.
Prompt 2
Run the ContractSpec validator to check whether my change folder's contracts are complete.
Prompt 3
Write a contract-first task list for a new API endpoint using ContractSpec's workflow.

Frequently asked questions

What is contractspec?

A workflow add-on that forces AI coding assistants to agree on shared contracts before writing full-stack code, preventing frontend and backend drift.

What language is contractspec written in?

Mainly JavaScript. The stack also includes JavaScript, TypeScript, OpenSpec.

What license does contractspec use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is contractspec to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is contractspec for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.