# Stopping Breaking API Contracts and Locking SQL Migrations Before Agents Ship Them

> Coding agents optimize for the local test suite in front of them—not the mobile app version from three months ago or the 40-million-row Postgres table waiting in production.

- **Published:** 2026-10-12
- **Category:** Code Review
- **Author:** 23step Engineering (Platform & Data Reliability)
- **Reading time:** 6 min
- **Featured 23step offering:** SchemaWatch
- **Canonical URL:** https://23step.com/blog/stopping-breaking-api-changes-and-locking-migrations-from-agent-prs

## Key takeaways

- Local unit tests happily pass when an agent renames a JSON field in both backend and test fixtures—while breaking live external clients and mobile apps.
- Agents frequently generate naive DDL migrations that acquire ACCESS EXCLUSIVE locks or drop columns still read by rolling-deploy containers.
- Automated contract checks across HTTP routes, wire schemas, SQL migrations, and required environment variables stop production incidents before deployment.

## Why local green tests cannot protect production contracts

Ask a coding agent to "clean up the billing response payload and add an index on organization status," and it will gladly rename `plan_tier` to `planTier` across your Go struct, your frontend component, and your unit test fixtures. Every check in CI turns green.

Five minutes after deploy, webhook consumers, Zapier integrations, and pinned mobile builds start throwing deserialization errors. Even worse, the migration file the agent added runs `ALTER TABLE invoices ADD COLUMN tax_region TEXT NOT NULL DEFAULT 'us'` or `CREATE INDEX` without `CONCURRENTLY`, locking writes during peak traffic.

Agents do this because they treat a repository as a self-contained world. Unless a guard explicitly inspects public boundaries and deployment ordering, contract regressions slip straight into `main`.

## The four breaking changes agents introduce most often

Across thousands of recorded engineering runs, four boundary hazards account for the vast majority of post-merge rollbacks:

### High-risk contract changes in autonomous coding sessions

| Hazard class | Typical agent edit | Production blast radius |
| --- | --- | --- |
| HTTP route drift | Removing, renaming, or changing methods on an endpoint | 404/405 spikes for external SDKs and cached frontends |
| JSON wire breaks | Renaming keys, changing field types, tightening validation | Silent client crashes and failed webhook deliveries |
| Locking SQL DDL | Non-concurrent indexes, dropped columns, destructive rewrites | Table locks, query pileups, and rolling-deploy errors |
| Configuration drift | Reading a newly required env var without a safe default | Crash-looping pods in staging or production on boot |

## Inspecting every route, migration, and env var automatically

Manual migration checklists break down whenever multiple agents open pull requests in parallel. **SchemaWatch** plugs directly into your 23step session stream to inspect every modified route handler, API payload definition, SQL migration, and runtime configuration key.

Before a reviewer approves the PR, SchemaWatch flags removed or altered HTTP routes, renamed JSON wire fields, non-backwards-compatible or table-locking DDL statements, and newly introduced environment variables that ops needs to provision prior to rollout.

**Sample SchemaWatch pre-merge alert** (Caught before staging deploy during routine PR triage)

```text
SchemaWatch Findings (2 blocking · 1 advisory)
  [BLOCK] SQL Migration 049_add_org_idx.sql: CREATE INDEX without CONCURRENTLY on table "sessions"
  [BLOCK] Wire Contract: JSON field "billing_cycle" renamed to "billingInterval" in GET /v1/account
  [INFO]  Config Drift: New env var "WEBHOOK_SIGNING_SECRET_V2" referenced in internal/api/webhooks.go
```

## Guard your production boundaries for 1 AI credit per check

Catching one locking migration or silent wire break pays for an entire year of tooling. Turn on [SchemaWatch](/marketplace/schemawatch) inside 23step to inspect every API, schema, and configuration change automatically across your repositories.

## Try SchemaWatch on 23step

**Stop breaking HTTP routes, JSON wire changes, and locking SQL migrations pre-merge.**

SchemaWatch audits every coding session for API compatibility breaks, non-backwards-compatible or table-locking SQL migrations, and newly required environment variables so zero-downtime releases stay zero-downtime.

- Flags removed routes, renamed JSON fields, and tightened request schemas
- Reviews SQL migrations for table locks, dropped columns, and rollout hazards
- Lists newly introduced environment variables and runtime config drift before deploy

*Included in every 23step plan for 1 AI credit per check from your shared monthly pool—no separate per-plugin subscription.*

- [Explore SchemaWatch](https://23step.com/marketplace/schemawatch)
- [See all use cases](https://23step.com/use-cases)
