pg-memory

Store and query AI agent memories in PostgreSQL with full-text search.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/pascalandy/dotfiles --skill pg-memory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pg-memory
Source: https://github.com/pascalandy/dotfiles/tree/main/dot_config/opencode/skill/util-pg-memory
Command: npx skills add https://github.com/pascalandy/dotfiles --skill pg-memory

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The pg-memory skill provides a robust, PostgreSQL-backed store for AI agent memories, enabling durable capture of decisions, observations, and learnings to improve consistency and auditing across sessions.

Core Features & Use Cases

  • Memory lifecycle: store, query, and search memories (including content, tags, and metadata) with fast index-backed lookups.
  • Context reuse: retrieve past decisions and observations to inform current reasoning and planning.
  • Use Case: as you iterate on an AI assistant, accumulate a searchable history of prompts, results, and rationale to drive better responses over time.

Quick Start

Install PostgreSQL 18+, create a database, apply the pg-memory schema, and verify with the included verification script. Then insert a memory and run a search to confirm the system is working.

Frequently Asked Questions about pg-memory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I persist AI memories in PostgreSQL for cross-session context reuse?

To persist AI memories in PostgreSQL, you store decisions, observations, and learnings using a dedicated schema with JSONB metadata and tsvector indexing. This enables durable cross-session context retrieval and full-text search for auditability.

What is the best way to query past AI decisions and observations stored in a database?

Querying past AI decisions and observations is done using full-text search and JSONB metadata filtering within PostgreSQL. This allows you to retrieve specific historical context and rationale to inform current reasoning workflows.

Do I need PostgreSQL 18 to store AI agent memories with full-text search?

PostgreSQL 18+ is required to use this memory storage approach, as the schema relies on advanced indexing features like tsvector for full-text search and JSONB for fast metadata lookups to capture and query AI memories.

How do I set up a PostgreSQL database for AI memory retrieval and auditability?

Setting up PostgreSQL for AI memory retrieval involves installing a PostgreSQL 18+ instance, creating a database, and applying a specific schema with proper indexing. You then verify the setup with a script before inserting searchable memories.

Can I track tokens and cost data when storing AI memories in PostgreSQL?

Yes, token and cost tracking are supported through optional integration points when storing AI memories in PostgreSQL. This allows you to accumulate a searchable history of prompts and results while monitoring usage metrics.

What are the limitations of using PostgreSQL for AI memory lifecycle management?

Using PostgreSQL for AI memory management requires maintaining a PostgreSQL 18+ instance and managing schema indexing like tsvector. It is not a lightweight in-memory store, meaning it requires database administration overhead for memory retrieval.