This skill provides a PostgreSQL-based memory solution for AI agents, ensuring optimal data retrieval. It's ideal for developers looking to enhance AI agent performance with structured memory storage.
$ npx skills add https://github.com/arthur0824hao/skills --skill skill-system-memorySkill System Memory is a PostgreSQL-based memory management solution designed for AI agents that require reliable, structured data storage and retrieval. This skill enables developers to implement persistent memory systems that optimize agent performance through efficient database-backed storage. By leveraging PostgreSQL's robust architecture, it provides a foundation for agents that need to access and manage information consistently across sessions.
Install using the command provided below.
Store and retrieve memory for AI agents
Support project-scoped data isolation
Enhance AI decision-making with persistent memory
$ npx skills add https://github.com/arthur0824hao/skills --skill skill-system-memorygit clone https://github.com/arthur0824hao/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Design a PostgreSQL-based memory system for my AI agent to store and retrieve [AGENT_TYPE] interactions. Include schema for tables like 'conversations', 'user_profiles', and 'memory_entries'. Ensure the design supports fast retrieval of [MEMORY_TYPE] data, such as past decisions or user preferences. Optimize for [QUERY_TYPE] queries like similarity search or time-based filtering.
**PostgreSQL Schema Design for AI Agent Memory System**
```sql
-- Core tables for structured memory storage
CREATE TABLE user_profiles (
user_id SERIAL PRIMARY KEY,
agent_id VARCHAR(255) NOT NULL,
preferences JSONB,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE conversations (
conversation_id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES user_profiles(user_id),
agent_id VARCHAR(255) NOT NULL,
context JSONB,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE memory_entries (
entry_id SERIAL PRIMARY KEY,
conversation_id INTEGER REFERENCES conversations(conversation_id),
memory_type VARCHAR(50) NOT NULL, -- e.g., 'decision', 'preference', 'context'
content TEXT,
metadata JSONB,
created_at TIMESTAMP DEFAULT NOW(),
similarity_vector VECTOR(1536) -- For vector similarity search
);
-- Indexes for optimized retrieval
CREATE INDEX idx_memory_entries_similarity ON memory_entries USING ivfflat (similarity_vector vector_cosine_ops);
CREATE INDEX idx_conversations_agent ON conversations(agent_id);
CREATE INDEX idx_memory_entries_type ON memory_entries(memory_type);
```
**Key Features:**
- **Structured Storage**: JSONB columns for flexible data handling (user preferences, conversation context)
- **Vector Search**: Enables semantic similarity for memory retrieval
- **Time-Based Filtering**: Optimized for retrieving recent interactions
- **Scalable Schema**: Supports incremental updates and growth
**Example Query:**
```sql
-- Retrieve past decisions for an agent
SELECT content
FROM memory_entries
WHERE agent_id = 'customer_support_bot'
AND memory_type = 'decision'
AND created_at > NOW() - INTERVAL '7 days'
ORDER BY created_at DESC
LIMIT 5;
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan