Agency7ai

rag-memory

0
0
# Install this skill:
npx skills add Agency7ai/agent-rag-memories-universal

Or install specific skill: npx add-skill https://github.com/Agency7ai/agent-rag-memories-universal

# Description

Full RAG (Retrieval-Augmented Generation) context memory system. Automatically preserves and retrieves context across sessions using vector search. Framework agnostic - works with any project.

# SKILL.md


name: rag-memory
description: Full RAG (Retrieval-Augmented Generation) context memory system. Automatically preserves and retrieves context across sessions using vector search. Framework agnostic - works with any project.
user_invocable: true


RAG Memory - Persistent Context Across Sessions

A portable, framework-agnostic RAG system for Claude Code that preserves your project context across sessions.

Quick Start

# 1. Copy this skill folder to your project
cp -r .claude/skills/rag-memory /path/to/your/project/.claude/skills/

# 2. Run the setup
/rag-memory setup

# 3. Start using it
/rag-memory load    # Load context at session start
/rag-memory save    # Save context when needed

Commands

Command Description
/rag-memory setup Initialize RAG for this project
/rag-memory load Load relevant context (run at session start)
/rag-memory load [topic] Search for context about a specific topic
/rag-memory save Save current session context
/rag-memory status Show current configuration and stats
/rag-memory clear Clear all stored context (careful!)

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               FRAMEWORK AGNOSTIC RAG                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  /rag-memory load                 /rag-memory save          β”‚
β”‚       β”‚                                β”‚                    β”‚
β”‚       β–Ό                                β–Ό                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚         Convex (Serverless Backend)         β”‚           β”‚
β”‚  β”‚                                             β”‚           β”‚
β”‚  β”‚  β€’ ragMemories table                        β”‚           β”‚
β”‚  β”‚  β€’ OpenAI text-embedding-3-small            β”‚           β”‚
β”‚  β”‚  β€’ Vector similarity search                 β”‚           β”‚
β”‚  β”‚  β€’ No framework code in your app            β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                                                             β”‚
β”‚  Works with: React, Vue, Svelte, Node, Python,             β”‚
β”‚              Go, Rust, or ANY tech stack                   β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How RAG Works

  1. RETRIEVAL - When you run /rag-memory load:
  2. Fetches relevant memories from vector database
  3. Uses semantic search (not just keywords)
  4. Returns decisions, patterns, progress from past sessions

  5. AUGMENTATION - The retrieved context is presented to Claude:

  6. Becomes part of the conversation
  7. Informs all subsequent responses
  8. No need to re-explain your project

  9. GENERATION - Claude uses the context:

  10. References past decisions
  11. Follows established patterns
  12. Continues from where you left off

Configuration

After setup, your .claude/rag-memory.json looks like:

{
  "projectId": "your-project-name",
  "convexUrl": "https://your-deployment.convex.cloud",
  "autoLoad": true
}

Memory Types

Type What to Store
decision Architecture choices, tech stack decisions, trade-offs
code_pattern Reusable patterns, conventions, idioms
progress Completed features, milestones, current state
blocker Known issues, pending questions, limitations
context Project-specific knowledge, business logic
file_summary Key files and their purposes
conversation Important discussions, user preferences

Backend Setup (One-Time)

You need a Convex backend. This can be:
- A dedicated project just for RAG memory
- Part of an existing Convex project
- Shared across multiple projects (different projectIds)

Quick Convex Setup

# Create backend (can be anywhere)
mkdir rag-backend && cd rag-backend
npm init -y
npm install convex
npx convex dev

# Set OpenAI key for embeddings
npx convex env set OPENAI_API_KEY sk-your-key

# Copy schema and functions from templates/convex/

When to Use

/rag-memory load

  • Starting a new session
  • Switching to a feature you've worked on before
  • Need to recall a previous decision
  • After context was summarized/compressed

/rag-memory save

  • Ending a productive session
  • Made important decisions
  • Established new patterns
  • Context window getting full
  • Before switching to a different topic

Example Flow

Day 1:
User: Let's build an auth system
Claude: [Works on auth, makes decisions about Stack Auth, patterns, etc.]
User: /rag-memory save
Claude: Saved 4 memories: Stack Auth decision, auth patterns, progress, config notes

Day 2:
User: /rag-memory load
Claude: Loaded context - you're using Stack Auth with email/OAuth,
        middleware pattern for protected routes, auth is complete.

User: Add profile settings
Claude: I'll add profile settings that integrates with your Stack Auth
        setup, following your established patterns...

Sharing

Share Just the Skill

zip -r rag-memory.zip .claude/skills/rag-memory/
# Friends unzip to their .claude/skills/
# They set up their own Convex backend

Share Everything

  1. Add friends to your Convex team
  2. Share the convexUrl
  3. They use unique projectIds

Files

rag-memory/
β”œβ”€β”€ README.md              # Detailed documentation
β”œβ”€β”€ SKILL.md               # This file
β”œβ”€β”€ commands/
β”‚   β”œβ”€β”€ setup.md           # Setup flow
β”‚   β”œβ”€β”€ load.md            # Retrieval logic
β”‚   β”œβ”€β”€ save.md            # Extraction logic
β”‚   └── status.md          # Status display
└── templates/
    └── convex/
        β”œβ”€β”€ ragMemories.ts      # Copy to convex/
        └── schema-addition.ts  # Add to schema.ts

# README.md

RAG Memory - Portable Context Preservation for Claude Agent Skills or Agents.md Memories

RAG Memory Demo

Never forget what your building

A complete RAG (Retrieval-Augmented Generation) system that preserves your project context across Claude Code or Agent sessions.

Framework Agnostic - Works with any tech stack. Only requires Convex for storage.

What It Does

  • Saves important decisions, code patterns, progress, and blockers
  • Retrieves relevant context at the start of new sessions
  • Augments Claude's responses with your project history
  • Prevents repeating yourself or losing track of decisions

Quick Install

Non Claude Agents start

npm i -g openskills
touch .agent/skills
mv rag-memory .agent/skills/rag-memory
openskills sync

claude agents start

same for both

# 1. Copy to your project
cp -r /path/to/rag-memory /your/project/.claude/skills/

# 2. Start Claude Code in your project
cd /your/project
claude

# 3. Run setup
/rag-memory setup

Commands

Command What It Does
/rag-memory setup Initialize RAG for this project
/rag-memory load Load context at session start
/rag-memory load auth Search for context about "auth"
/rag-memory save Save current session context
/rag-memory status Show configuration and stats
/rag-memory clear Delete all stored context

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRAMEWORK AGNOSTIC                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚   Your Project          Claude Code            Convex       β”‚
β”‚   (Any Stack)           Skills                 (Storage)    β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ React     β”‚       β”‚ /rag-memory │──────▢│ Vector DB β”‚   β”‚
β”‚  β”‚ Vue       │◀─────▢│ load / save │◀──────│ Embeddingsβ”‚   β”‚
β”‚  β”‚ Svelte    β”‚       β”‚             β”‚       β”‚ Search    β”‚   β”‚
β”‚  β”‚ Node      β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚  β”‚ Python    β”‚                                              β”‚
β”‚  β”‚ Go        β”‚       No framework code                      β”‚
β”‚  β”‚ Anything! β”‚       needed in your app                     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                              β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Setup (One-Time)

1. Create a Convex Project

# In any directory (can be separate from your main project)
mkdir rag-memory-backend && cd rag-memory-backend
npm init -y
npm install convex
npx convex dev

2. Add Schema

Create convex/schema.ts:

import { defineSchema, defineTable } from 'convex/server';
import { v } from 'convex/values';

export default defineSchema({
  ragMemories: defineTable({
    projectId: v.string(),
    sessionId: v.optional(v.string()),
    type: v.union(
      v.literal('decision'),
      v.literal('code_pattern'),
      v.literal('progress'),
      v.literal('blocker'),
      v.literal('context'),
      v.literal('file_summary'),
      v.literal('conversation')
    ),
    title: v.string(),
    content: v.string(),
    tags: v.array(v.string()),
    embedding: v.array(v.float64()),
    createdAt: v.number()
  })
    .index('by_project', ['projectId'])
    .index('by_type', ['projectId', 'type'])
    .vectorIndex('by_embedding', {
      vectorField: 'embedding',
      dimensions: 1536,
      filterFields: ['projectId', 'type']
    })
});

3. Add Functions

Copy templates/convex/ragMemories.ts to convex/ragMemories.ts

4. Set OpenAI Key

npx convex env set OPENAI_API_KEY sk-your-key-here

5. Get Your Convex URL

After npx convex dev, note your deployment URL:

https://your-project-123.convex.cloud

6. Configure the Skill

Create .claude/rag-memory.json in your actual project:

{
  "projectId": "my-project-name",
  "convexUrl": "https://your-project-123.convex.cloud"
}

Memory Types

Type Use For
decision Tech choices, architecture decisions, trade-offs
code_pattern Reusable patterns, conventions, idioms
progress Completed features, milestones, current state
blocker Known issues, pending questions, limitations
context Project knowledge, business logic, requirements
file_summary Key files and their purposes
conversation Important discussions, user preferences

Example Session

User: /rag-memory load

Claude: RAG Context Loaded
        ==================
        Retrieved 5 relevant memories:

        Decisions:
          β€’ Using PostgreSQL for main database
          β€’ Chose Tailwind over styled-components

        Patterns:
          β€’ API error handling pattern
          β€’ Form validation approach

        Progress:
          β€’ User authentication complete
          β€’ Dashboard layout done

        I'm ready to continue. What would you like to work on?

User: Add user profile editing

Claude: I'll add profile editing. Based on your existing patterns,
        I'll follow the same form validation approach and use the
        established API error handling...

Sharing With Friends

Option A: Share Just the Skill

# Zip the skill folder
cd .claude/skills
zip -r rag-memory.zip rag-memory/
# Share the zip file

They'll need to:
1. Set up their own Convex backend
2. Configure .claude/rag-memory.json with their URL

Option B: Share Backend Too

If you want friends to use the same backend (shared context):
1. Add them as team members in Convex dashboard
2. Share the convexUrl
3. They use a different projectId for their projects

Troubleshooting

"Convex not configured"

Create a Convex project and set the URL in .claude/rag-memory.json

"No OPENAI_API_KEY"

In your Convex project: npx convex env set OPENAI_API_KEY sk-...

Low quality search results

Clear old memories and re-save after setting OpenAI key:

/rag-memory clear
/rag-memory save

Auto-Load Hook (True RAG)

To make context loading automatic at session start:

  1. Copy the hook script:
    bash mkdir -p .claude/hooks cp .claude/skills/rag-memory/templates/hooks/rag-session-start.sh .claude/hooks/ chmod +x .claude/hooks/rag-session-start.sh

  2. Add to settings (.claude/settings.json or settings.local.json):
    json { "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/rag-session-start.sh" } ] } ] } }

Now Claude will automatically be instructed to load context at session start!

Files Included

rag-memory/
β”œβ”€β”€ README.md              # This file
β”œβ”€β”€ SKILL.md               # Main skill definition
β”œβ”€β”€ commands/
β”‚   β”œβ”€β”€ setup.md           # Setup instructions
β”‚   β”œβ”€β”€ load.md            # Load context logic
β”‚   β”œβ”€β”€ save.md            # Save context logic
β”‚   └── status.md          # Status display
└── templates/
    β”œβ”€β”€ convex/
    β”‚   β”œβ”€β”€ ragMemories.ts      # Convex functions
    β”‚   └── schema-addition.ts  # Schema to add
    └── hooks/
        └── rag-session-start.sh  # Auto-load hook

Why Convex?

  • Free tier - Plenty for personal/small team use
  • Built-in vector search - No additional setup
  • Serverless - No server to maintain
  • Works anywhere - Just an HTTP API

License

MIT - Use freely, share with friends.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.