Menu

pgbrake: an undo button for Postgres when an AI agent is driving
📰

pgbrake: an undo button for Postgres when an AI agent is driving

DEV Community: postgres·Zhang Lixiang·22 days ago
#yHVSalEv
#devtopostgresql#devto#dev#pgbrake#claude
Reading 0:00
15s threshold

I've started letting Claude Code and Codex work against my dev databases, and the part that worried me was the database itself. Claude Code checkpoints rewind files. A bad DELETE stays done. Permission prompts help, but they live in the client, and an agent can always reach for psql instead.

pgbrake is a small MCP server the agent uses in place of direct database access. Every statement goes through the real Postgres parser (pglast). Normal writes run and return a change id. Before an UPDATE or DELETE it saves the affected rows locally, so pgbrake undo <id> puts them back, and it refuses if those rows changed since.

DDL, UPDATE/DELETE without WHERE, and anything touching more than 100 rows wait for a human: the client's own prompt, or pgbrake approve <id> in a terminal. That command refuses to run without a TTY, so the agent can't approve its own SQL. Every statement and decision lands in a local audit log.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.