What is StateAnchor?
A git-native gate that stops breaking API changes before they reach production — or your AI agents.
The problem: API drift
Your team ships a required field removal on Monday. The OpenAPI spec is updated. But the Python SDK your internal tooling uses was generated three weeks ago. The iOS app was built against last sprint’s contract. Your AI agent was given type definitions from the last release. Nobody regenerated. Nothing broke in CI. Everything breaks in production.
This is API drift — the silent divergence between what your spec says, what your service does, and what your consumers expect. It’s not a discipline problem. It’s an architecture problem: there’s no enforcement layer between “spec changed” and “consumers updated.” When that layer is missing, drift is structurally guaranteed.
How StateAnchor works
StateAnchor is a git-native gate. You commit a stateanchor.yamlfile to your repo root. It’s the single authoritative declaration of your API contract — endpoints, schemas, auth, versioning. On every push, StateAnchor diffs the current spec against the prior snapshot and classifies every change into one of three lanes:
- ERR— always blocks. Endpoint removed, required field deleted, type changed, auth scheme changed. No threshold, no exceptions, no manual review.
- WARN— blocks above a configurable threshold. Optional field removed, deprecation violated, response field made required.
- INFO— always passes. New endpoint added, optional field extended, description updated. Additive changes never block.
An ERR verdict stops the PR. A PASS verdict triggers optional SDK and MCP server regeneration. The gate never becomes a hard dependency: if StateAnchor is unreachable, your CI continues normally.
The detection benchmark
We built a 34-scenario ground-truth corpus covering every breaking change kind (endpoint removal, field removal, type changes, auth changes, enum value removal, and more). StateAnchor detects 100% of them. api-smart-diff— the most widely deployed open-source spec-diff tool — detects 65% on the same corpus.
The gap comes from how StateAnchor evaluates changes. Most diff tools compare structural shapes and flag what changed. StateAnchor’s gate engine evaluates what the change means for existing consumers: will this break a client that was built against the previous spec? That question requires understanding field optionality, deprecation policy, auth scheme contracts, and enum cardinality — not just structural equality. Details at StateAnchor vs api-smart-diff →
Two ways to use it
Gate-only— if you already use Speakeasy, Fern, or another generator, gate-only mode adds StateAnchor’s enforcement layer on top. Your SDK generation stays exactly as it is. StateAnchor gates the spec before your generator reads it. Drift is stopped before it reaches your consumers.
Full pipeline— if you’re starting from scratch, the full pipeline generates TypeScript, Python, and Go SDKs plus an MCP server artifact on every passing sync. The gate runs first; generation only happens when the contract is clean.
Both modes are free to start. No credit card required.
Connect your repo in 5 minutes
Add a stateanchor.yaml to your repo root, install the GitHub Action, and connect your repo at stateanchor.dev. The gate starts evaluating on the next push. You’ll see the first verdict in the PR checks immediately.