Production-grade PostgreSQL backbone for AI agents. Persistent storage, safe SQL execution, versioned schema migrations, agent memory, audit logging, health checks, and backups. Use this skill when you need a database, persistent storage, SQL queries, data migrations, audit trails, or agent state management. Also trigger for "database", "postgres", "SQL", "migration", "backup", or "persistent storage."
Production-grade PostgreSQL backbone for AI agents. Provides persistent storage, safe SQL execution, versioned schema migrations, agent memory (JSONB KV), append-only audit logging, health verification, and backup creation.
This is the foundational persistence layer for distributed systems that need durable, auditable state shared across multiple agents and services.
Use this skill when an agent needs:
Do NOT use this skill to:
pg migrate up with the built-in migration system (skills that own their own storage may create and use their own tables; see boundary clarification below)NOT for:
Boundary clarification: Core schema (tables shared across multiple skills, like agent_memory and events) must be managed through pg migrate up with versioned migration files. Skills that own their own storage (e.g., analytics dashboards with watchlist_items and portfolio_holdings) may create their own tables and use them (INSERT, UPDATE, DELETE, SELECT) directly. However, ALTER TABLE is blocked regardless of ownership — schema modifications always require a new migration. When in doubt, prefer the migration system — it provides version history and safe rollback.
You need a running PostgreSQL instance (version 14+, 16+ recommended). Options:
Local development (macOS):
brew install postgresql@16
brew services start postgresql@16
Local development (Linux):
sudo apt-get install postgresql postgresql-contrib
sudo systemctl start postgresql
Docker (any platform):
docker run -d \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=openclaw \
-p 5432:5432 \
postgres:16-alpine
Create or obtain a connection string in this format: