| Crates.io | pg_guard |
| lib.rs | pg_guard |
| version | 0.1.3 |
| created_at | 2025-09-04 20:12:11.825422+00 |
| updated_at | 2025-09-04 21:22:54.806772+00 |
| description | A Postgres proxy with built-in safety features |
| homepage | https://github.com/johannes/pg_guard |
| repository | https://github.com/johannes/pg_guard |
| max_upload_size | |
| id | 1824723 |
| size | 326,859 |
A Postgres proxy with built-in safety features and row-level damage limiting

pg_guard is a Postgres proxy server that sits between your applications and your database, providing real-time query analysis and protection against dangerous operations. It implements transparent TCP proxying with PostgreSQL wire protocol support with human readable messages to help claude/cursor understand how to better make DB calls.
cargo install pg_guard
pg_guard \
--listen 0.0.0.0:6543 \
--db-url postgres://postgres:postgres@localhost:5432/postgres \
--max-rows 500 \
--strict
-- ❌ BLOCKED: These queries are automatically blocked
DROP TABLE users;
TRUNCATE users;
DELETE FROM users; -- No WHERE clause
-- ✅ ALLOWED: Affects few rows
DELETE FROM users WHERE id = 123;
-- ❌ BLOCKED: Would affect 1000+ rows (exceeds --max-rows limit)
DELETE FROM users WHERE created_at < '2020-01-01';
-- ❌ BLOCKED: Any access to canary tables
SELECT * FROM _pg_guard_canary;
Before allowing destructive operations, pg_guard logs:
[snapshot] Would take backup here
[ALLOW] DELETE FROM users WHERE role = 'inactive' → 12 rows