Building a branch-and-merge database guardrail so LLM agents can't wreck production

Antique-Willow-5841 · reddit · 2026-10-17

After an LLM agent with write access deleted all their CRM lead lists, the author built a sidecar database: agents work on copied-table branches, merges go back to Postgres in one transaction, gated by per-row three-way merge, read tracking, SQL checks, no-delete rules and held side effects. Post dives into hard-won lessons: text-based row comparison to avoid false conflicts, reserving serial ids from production sequences, SET LOCAL under PgBouncer, and crash-safe merge id pre-writing. Beta status, 10k rows per merge max.

Related event: Developer Builds Git-Style Branched Postgres After AI Agent Wipes CRM Data(3 posts)→

Original post →

More from coding & agent

coding & agent channel →