Skip to content

srinath2098/ai-memory-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Memory Layer

AI Memory Layer

A universal persistent memory layer for AI chat platforms.
Your personal context — automatically injected into every conversation.

Manifest V3 4 Platforms Zero Dependencies No Backend


The Problem

Every time you open a new conversation on Claude, ChatGPT, Grok, or Gemini, the AI has zero context about who you are, what you're working on, or what you prefer. You end up repeating yourself — your tech stack, your project details, your preferences — over and over.

The Solution

AI Memory Layer maintains a persistent store of your personal context and automatically prepends it to your messages across all major AI chat platforms. The AI always knows who you are without you typing it every time.

[MY CONTEXT - ignore if not relevant]
[work] Senior full-stack developer at Acme Corp, working with TypeScript and Next.js
[projects] Building an e-commerce platform with Stripe integration
[preferences] Prefer concise answers with code examples. Use functional patterns.
[END CONTEXT]

How should I structure my checkout flow?

The AI sees your context. You just type your question.


✨ Features

  • 🧠 Persistent Memory — Store facts about yourself, your work, projects, and preferences
  • 🔄 Auto-Injection — Context is prepended to your messages automatically before submission
  • 📌 Pinned Memories — Pin important context so it's always included first
  • 🏷️ Tagged Organization — Categorize memories as Work, Projects, Personal, Preferences, or Other
  • Token Budget — Capped at 800 tokens (~3,200 chars) to avoid bloating prompts
  • 🔒 Fully Local — All data stored via chrome.storage.sync. No backend, no API calls, no tracking
  • 🌐 Cross-Platform — Works on Claude, ChatGPT, Grok, and Gemini
  • 🎛️ Granular Control — Master toggle + per-site toggles to control where injection happens
  • 📤 Export / Import — Backup and restore your memories as JSON

🌐 Supported Platforms

Platform Domain Status
Claude claude.ai ✅ Supported
ChatGPT chatgpt.com ✅ Supported
Grok grok.com ✅ Supported
Gemini gemini.google.com ✅ Supported

🚀 Installation

This is an unpacked Chrome extension — no web store needed.

  1. Clone the repository

    git clone https://github.com/srinath2098/ai-memory-layer.git
  2. Open Chrome Extensions

    • Navigate to chrome://extensions
    • Enable Developer mode (toggle in the top-right corner)
  3. Load the extension

    • Click Load unpacked
    • Select the cloned ai-memory-layer folder
  4. Pin the extension

    • Click the puzzle icon in Chrome's toolbar
    • Pin AI Memory Layer for easy access

📖 Usage

Adding Memories

  1. Click the 🧠 extension icon
  2. Go to the Add tab
  3. Type your memory (e.g., "I'm building a SaaS dashboard with React and Supabase")
  4. Select a tag and optionally toggle Pin
  5. Click Save Memory

How Injection Works

  1. Navigate to any supported AI chat platform
  2. Focus the chat input and type your message
  3. Press Enter — the extension prepends your memory context automatically
  4. The AI receives your context + your message as a single prompt

Managing Memories

  • Memory tab — View all saved memories, pin/unpin, or delete
  • Settings tab — Toggle injection on/off globally or per-site
  • Export — Download all memories as a .json backup
  • Import — Restore memories from a previously exported file

🏗️ Architecture

ai-memory-layer/
├── manifest.json        # Manifest V3 configuration
├── background.js        # Service worker — storage CRUD, payload builder
├── content.js           # Content script — input detection & injection
├── popup.html           # Popup UI markup
├── popup.css            # Dark theme with glassmorphism
├── popup.js             # Popup logic — tabs, CRUD, settings
└── icons/
    ├── icon16.png
    ├── icon48.png
    └── icon128.png

Data Flow

┌──────────┐     chrome.runtime      ┌────────────────────┐     chrome.storage.sync
│  Popup   │ ◄──── sendMessage ────► │  Background Worker  │ ◄──────────────────► Storage
│  (UI)    │                          │  (Service Worker)   │
└──────────┘                          └────────────────────┘
                                              ▲
                                              │ chrome.runtime
                                              │ sendMessage
                                              ▼
                                      ┌────────────────────┐
                                      │   Content Script    │ ──► DOM (chat input)
                                      │  (claude/chatgpt/  │
                                      │   grok/gemini)     │
                                      └────────────────────┘

Key Design Decisions

Decision Rationale
chrome.storage.sync Data syncs across devices where the user is signed into Chrome
800-token cap Prevents prompt bloat while keeping enough room for meaningful context
Pinned + recency sorting Ensures the most important and recently-used memories are prioritized when trimming
Capture-phase keydown Runs before the site's own submit handler so injection happens pre-submission
execCommand('insertText') Works with React/framework state management in contenteditable inputs
MutationObserver + interval Handles SPA navigation where the input element may be swapped dynamically

🔧 Development

No build step. No dependencies. Just plain HTML/CSS/JS.

To make changes:

  1. Edit any file in the project
  2. Go to chrome://extensions
  3. Click the reload icon on the AI Memory Layer card
  4. Changes are applied immediately

Debugging

  • Popup: Right-click the extension icon → Inspect Popup
  • Content Script: Open DevTools on the AI chat page → Console → look for [AI Memory Layer] logs
  • Service Worker: chrome://extensions → click Service Worker link on the extension card

📝 License

MIT — use it however you like.

About

Universal persistent memory layer for AI chat platforms — Claude, ChatGPT, Grok & Gemini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors