Menu

My agent ran prisma migrate reset. Here's the hook I wrote so it can't again
📰

My agent ran prisma migrate reset. Here's the hook I wrote so it can't again

DEV Community: postgres·Zhang Lixiang·16 days ago
#gTn1KxMV
#devtopostgresql#devto#dev#pricing#pgbrake
Reading 0:00
15s threshold

Last week I wrote about pgbrake, an MCP server that makes an agent's SQL writes undoable. People pointed out the obvious hole: agents don't only touch the database through SQL. They also run terminal commands, and prisma migrate reset --force wipes everything without a single SQL statement going through the MCP server.

pgbrake 0.2.0 adds a Claude Code PreToolUse hook for that. It watches Bash commands for migration tools doing destructive things: prisma migrate reset --force , drizzle-kit push --force , alembic downgrade base and similar. When it sees one, it takes a pg_dump snapshot first (if PGBRAKE_DSN is set), then stops and asks you.

pgbrake install-hook

Enter fullscreen mode

Exit fullscreen mode

That's the whole setup.

The hook is part of Pro, which is $29 one-time for the first 100 licenses, then $39. No subscription, 14-day refund, and the key is checked offline, so pgbrake never phones home.…

Continue reading — create a free account

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