pgbrake: an undo layer for Postgres when AI agents run SQL

The developer describes pgbrake, an open-source MCP server that lets AI coding agents such as Claude Code and Codex work against Postgres databases without direct access. Each statement is parsed with pglast, and before UPDATE or DELETE operations the affected rows are saved locally so they can be restored with an undo command, which refuses if those rows changed afterward. DDL, statements without WHERE clauses, and changes touching more than 100 rows require human approval through the client or a terminal command that cannot run without a TTY. All statements and decisions are recorded in a local audit log, and nothing leaves the user's machine. The tool is MIT-licensed, written in Python, and has been tested only on Postgres 17, with its author noting that undo does not cover TRUNCATE or DDL and is no substitute for backups.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in