Memory & contextkitMIT

AgentKits Memory

Persistent semantic memory for your agent — embeddings, search, hooks, and an MCP server.

109 files3.8 MB64 stars on GitHub

Original work

Created by
aitytech
Published on
GitHub
License
MIT

Mirrored on Neura Market with prose references to the original marketplace updated to our name. Install commands and other URLs inside the files are left untouched so they keep working. All credit for the kit belongs to its author.

What's inside

109 files in this kit.

  • .claude-plugin/marketplace.json

    File
  • .dockerignore

    File
  • .github/FUNDING.yml

    File
  • .github/ISSUE_TEMPLATE/bug_report.md

    Documentation
  • .github/ISSUE_TEMPLATE/feature_request.md

    Documentation
  • .github/workflows/ci.yml

    File
  • .gitignore

    File
  • .mcp.json

    File
  • CODEOWNERS

    File
  • CONTRIBUTING.md

    Documentation
  • Dockerfile

    File
  • LICENSE

    File
  • README.md

    Documentation
  • assets/agentkits-memory-add-memory_v2.png

    File
  • assets/agentkits-memory-embedding_v2.png

    File
  • assets/agentkits-memory-memory-detail_v2.png

    File
  • assets/agentkits-memory-memory-list_v2.png

    File
  • assets/agentkits-memory-session-list_v2.png

    File
  • assets/logo.svg

    File
  • coverage-tmp/coverage-final.json

    File
  • hooks.json

    File
  • i18n/.translation-cache.json

    File
  • i18n/README.ar.md

    Documentation
  • i18n/README.de.md

    Documentation
  • i18n/README.es.md

    Documentation
  • i18n/README.fr.md

    Documentation
  • i18n/README.ja.md

    Documentation
  • i18n/README.ko.md

    Documentation
  • i18n/README.pt-br.md

    Documentation
  • i18n/README.ru.md

    Documentation
  • i18n/README.vi.md

    Documentation
  • i18n/README.zh.md

    Documentation
  • package-lock.json

    File
  • package.json

    File
  • plugin/.claude-plugin/plugin.json

    File
  • plugin/.mcp.json

    File
  • plugin/CLAUDE.md

    Documentation
  • plugin/hooks/hooks.json

    File
  • plugin/package.json

    File
  • plugin/scripts/ensure-installed.cjs

    File
  • plugin/skills/memory-workflow/SKILL.md

    Documentation
  • scripts/e2e-test.sh

    File
  • scripts/translate-readme/README.md

    Documentation
  • scripts/translate-readme/cli.cjs

    File
  • scripts/translate-readme/index.cjs

    File
  • skills/memory/SKILL.md

    Documentation
  • src/__tests__/better-sqlite3-backend.test.ts

    File
  • src/__tests__/cache-manager.test.ts

    File
  • src/__tests__/embedding-integration.test.ts

    File
  • src/__tests__/index.test.ts

    File
  • src/__tests__/setup.ts

    File
  • src/better-sqlite3-backend.ts

    File
  • src/cache-manager.ts

    File
  • src/cli/__tests__/platforms.test.ts

    File
  • src/cli/__tests__/rules-generator.test.ts

    File
  • src/cli/main.ts

    File
  • src/cli/platforms.ts

    File
  • src/cli/rules-generator.ts

    File
  • src/cli/save.ts

    File
  • src/cli/setup.ts

    File

…and 49 more files in the download.

About this kit

<p align="center"> <img src="https://raw.githubusercontent.com/aitytech/agentkits-memory/main/assets/logo.svg" alt="AgentKits Logo" width="80" height="80"> </p> <h1 align="center">AgentKits Memory</h1> <p align="center"> <em>by <strong>AityTech</strong></em> </p> <p align="center"> <a href="https://www.npmjs.com/package/@aitytech/agentkits-memory"><img src="https://img.shields.io/npm/v/@aitytech/agentkits-memory.svg" alt="npm"></a> <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"> <img src="https://img.shields.io/badge/Claude_Code-Compatible-blueviolet" alt="Claude Code"> <img src="https://img.shields.io/badge/Cursor-Compatible-blue" alt="Cursor"> <img src="https://img.shields.io/badge/Windsurf-Compatible-cyan" alt="Windsurf"> <img src="https://img.shields.io/badge/Cline-Compatible-orange" alt="Cline"> <img src="https://img.shields.io/badge/OpenCode-Compatible-green" alt="OpenCode"> <br> <img src="https://img.shields.io/badge/tests-970_passed-brightgreen" alt="Tests"> <img src="https://img.shields.io/badge/coverage-91%25-brightgreen" alt="Coverage"> </p> <p align="center"> <strong>Persistent Memory System for AI Coding Assistants</strong> </p> <p align="center"> Your AI assistant forgets everything between sessions. AgentKits Memory fixes that.<br> Decisions, patterns, errors, and context — all persisted locally via MCP. </p> <p align="center"> <a href="https://www.agentkits.net/memory">Website</a> • <a href="https://www.agentkits.net/memory/docs">Docs</a> • <a href="#quick-start">Quick Start</a> • <a href="#how-it-works">How It Works</a> • <a href="#multi-platform-support">Platforms</a> • <a href="#cli-commands">CLI</a> • <a href="#web-viewer">Web Viewer</a> </p> <p align="center"> <strong>English</strong> · <a href="./i18n/README.zh.md">简体中文</a> · <a href="./i18n/README.ja.md">日本語</a> · <a href="./i18n/README.ko.md">한국어</a> · <a href="./i18n/README.es.md">Español</a> · <a href="./i18n/README.de.md">Deutsch</a> · <a href="./i18n/README.fr.md">Français</a> · <a href="./i18n/README.pt-br.md">Português</a> · <a href="./i18n/README.vi.md">Tiếng Việt</a> · <a href="./i18n/README.ru.md">Русский</a> · <a href="./i18n/README.ar.md">العربية</a> </p>

Features

FeatureBenefit
100% LocalAll data stays on your machine. No cloud, no API keys, no accounts
Blazing FastNative SQLite (better-sqlite3) = instant queries, zero latency
Zero ConfigWorks out of the box. No database setup required
Multi-PlatformClaude Code, Cursor, Windsurf, Cline, OpenCode — one setup command
MCP Server9 tools: save, search, timeline, details, recall, list, update, delete, status
Auto-CaptureHooks capture session context, tool usage, summaries automatically
AI EnrichmentBackground workers enrich observations with AI-generated summaries
Vector Searchsqlite-vec semantic similarity with multilingual embeddings (100+ languages)
Web ViewerBrowser UI to view, search, add, edit, delete memories
3-Layer SearchProgressive disclosure saves ~87% tokens vs fetching everything
Lifecycle MgmtAuto-compress, archive, and clean up old sessions
Export/ImportBackup and restore memories as JSON

How It Works

Session 1: "Use JWT for auth"          Session 2: "Add login endpoint"
┌──────────────────────────┐          ┌──────────────────────────┐
│  You code with AI...     │          │  AI already knows:       │
│  AI makes decisions      │          │  ✓ JWT auth decision     │
│  AI encounters errors    │   ───►   │  ✓ Error solutions       │
│  AI learns patterns      │  saved   │  ✓ Code patterns         │
│                          │          │  ✓ Session context        │
└──────────────────────────┘          └──────────────────────────┘
         │                                      ▲
         ▼                                      │
    .claude/memory/memory.db  ──────────────────┘
    (SQLite, 100% local)
  1. Setup oncenpx @aitytech/agentkits-memory configures your platform
  2. Auto-capture — Hooks record decisions, tool usage, and summaries as you work
  3. Context injection — Next session starts with relevant history from past sessions
  4. Background processing — Workers enrich observations with AI, generate embeddings, compress old data
  5. Search anytime — AI uses MCP tools (memory_searchmemory_details) to find past context

All data stays in .claude/memory/memory.db on your machine. No cloud. No API keys required.


Design Decisions That Matter

Most memory tools scatter data across markdown files, require Python runtimes, or send your code to external APIs. AgentKits Memory makes fundamentally different choices:

Design ChoiceWhy It Matters
Single SQLite databaseOne file (memory.db) holds everything — memories, sessions, observations, embeddings. No scattered files to sync, no merge conflicts, no orphaned data. Backup = copy one file
Native Node.js, zero PythonRuns wherever Node runs. No conda, no pip, no virtualenv. Same language as your MCP server — one npx command, done
Token-efficient 3-layer searchSearch index first (~50 tokens/result), then timeline context, then full details. Only fetch what you need. Other tools dump entire memory files into context, burning tokens on irrelevant content
Auto-capture via hooksDecisions, patterns, and errors are recorded as they happen — not after you remember to save them. Session context injection happens automatically on next session start
Local embeddings, no API callsVector search uses a local ONNX model (multilingual-e5-small). Semantic search works offline, costs nothing, and supports 100+ languages
Background workersAI enrichment, embedding generation, and compression run asynchronously. Your coding flow is never blocked
Multi-platform from day oneOne --platform=all flag configures Claude Code, Cursor, Windsurf, Cline, and OpenCode simultaneously. Same memory database, different editors
Structured observation dataTool usage is captured with type classification (read/write/execute/search), file tracking, intent detection, and AI-generated narratives — not raw text dumps
No process leaksBackground workers self-terminate after 5 minutes, use PID-based lock files with stale-lock cleanup, and handle SIGTERM/SIGINT gracefully. No zombie processes, no orphaned workers
No memory leaksHooks run as short-lived processes (not long-running daemons). Database connections close on shutdown. Embedding subprocess has bounded respawn (max 2), pending request timeouts, and graceful cleanup of all timers and queues

Web Viewer

View and manage your memories through a modern web interface.

npx @aitytech/agentkits-memory web

Then open http://localhost:1905 in your browser.

Session List

Browse all sessions with timeline view and activity details.

Session List

Memory List

Browse all stored memories with search and namespace filtering.

Memory List

Add Memory

Create new memories with key, namespace, type, content, and tags.

Add Memory

Memory Details

View full memory details with edit and delete options.

Memory Detail

Manage Embeddings

Generate and manage vector embeddings for semantic search.

Manage Embeddings


Quick Start

Option 1: Claude Code Plugin Marketplace (Recommended for Claude Code)

Install as a plugin with one command — no manual configuration needed:

/plugin marketplace add aitytech/agentkits-memory
/plugin install agentkits-memory@agentkits-memory

This installs hooks, MCP server, and memory workflow skill automatically. Restart Claude Code after installation.

Option 2: Automated Setup (All Platforms)

npx @aitytech/agentkits-memory

This auto-detects your platform and configures everything: MCP server, hooks (Claude Code/OpenCode), rules files (Cursor/Windsurf/Cline), and downloads the embedding model.

Target a specific platform:

npx @aitytech/agentkits-memory --platform=cursor
npx @aitytech/agentkits-memory --platform=windsurf,cline
npx @aitytech/agentkits-memory --platform=all

Option 3: Manual MCP Configuration

If you prefer manual setup, add to your MCP config:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@aitytech/agentkits-memory", "server"]
    }
  }
}

Config file locations:

  • Claude Code: .claude/settings.json (embedded in mcpServers key)
  • Cursor: .cursor/mcp.json
  • Windsurf: .windsurf/mcp.json
  • Cline / OpenCode: .mcp.json (project root)

3. MCP Tools

Once configured, your AI assistant can use these tools:

ToolDescription
memory_statusCheck memory system status (call first!)
memory_saveSave decisions, patterns, errors, or context
memory_search[Step 1] Search index — lightweight IDs + titles (~50 tokens/result)
memory_timeline[Step 2] Get temporal context around a memory
memory_details[Step 3] Get full content for specific IDs
memory_recallQuick topic overview — grouped summary
memory_listList recent memories
memory_updateUpdate existing memory content or tags
memory_deleteRemove outdated memories

Progressive Disclosure (Token-Efficient Search)

AgentKits Memory uses a 3-layer search pattern that saves ~70% tokens compared to fetching full content upfront.

How It Works

┌─────────────────────────────────────────────────────────────┐
│  Step 1: memory_search                                      │
│  Returns: IDs, titles, tags, scores (~50 tokens/item)       │
│  → Review index, pick relevant memories                     │
└─────────────────────────────────────────────────────────────┘
                             ↓
┌─────────────────────────────────────────────────────────────┐
│  Step 2: memory_timeline (optional)                         │
│  Returns: Context ±30 minutes around memory                 │
│  → Understand what happened before/after                    │
└─────────────────────────────────────────────────────────────┘
                             ↓
┌─────────────────────────────────────────────────────────────┐
│  Step 3: memory_details                                     │
│  Returns: Full content for selected IDs only                │
│  → Fetch only what you actually need                        │
└─────────────────────────────────────────────────────────────┘

Example Workflow

// Step 1: Search - get lightweight index
memory_search({ query: "authentication" })
// → Returns: [{ id: "abc", title: "JWT pattern...", score: 85% }]

// Step 2: (Optional) See temporal context
memory_timeline({ anchor: "abc" })
// → Returns: What happened before/after this memory

// Step 3: Get full content only for what you need
memory_details({ ids: ["abc"] })
// → Returns: Full content for selected memory

Token Savings

ApproachTokens Used
Old: Fetch all content~500 tokens × 10 results = 5000 tokens
New: Progressive disclosure50 × 10 + 500 × 2 = 1500 tokens
Savings70% reduction

CLI Commands

# One-command setup (auto-detects platform)
npx @aitytech/agentkits-memory
npx @aitytech/agentkits-memory setup --platform=cursor   # specific platform
npx @aitytech/agentkits-memory setup --platform=all      # all platforms
npx @aitytech/agentkits-memory setup --force             # re-install/update

# Start MCP server
npx @aitytech/agentkits-memory server

# Web viewer (port 1905)
npx @aitytech/agentkits-memory web

# Terminal viewer
npx @aitytech/agentkits-memory viewer
npx @aitytech/agentkits-memory viewer --stats
npx @aitytech/agentkits-memory viewer --json

# Save from CLI
npx @aitytech/agentkits-memory save "Use JWT with refresh tokens" --category pattern --tags auth,security

# Settings
npx @aitytech/agentkits-memory hook settings .
npx @aitytech/agentkits-memory hook settings . --reset
npx @aitytech/agentkits-memory hook settings . aiProvider.provider=openai aiProvider.apiKey=sk-...

# Export / Import
npx @aitytech/agentkits-memory hook export . my-project ./backup.json
npx @aitytech/agentkits-memory hook import . ./backup.json

# Lifecycle management
npx @aitytech/agentkits-memory hook lifecycle . --compress-days=7 --archive-days=30
npx @aitytech/agentkits-memory hook lifecycle-stats .

Programmatic Usage

import { ProjectMemoryService } from '@aitytech/agentkits-memory';

const memory = new ProjectMemoryService({
  baseDir: '.claude/memory',
  dbFilename: 'memory.db',
});
await memory.initialize();

// Store a memory
await memory.storeEntry({
  key: 'auth-pattern',
  content: 'Use JWT with refresh tokens for authentication',
  namespace: 'patterns',
  tags: ['auth', 'security'],
});

// Query memories
const results = await memory.query({
  type: 'hybrid',
  namespace: 'patterns',
  content: 'authentication',
  limit: 10,
});

// Get by key
const entry = await memory.getByKey('patterns', 'auth-pattern');

Auto-Capture Hooks

Hooks automatically capture your AI coding sessions (Claude Code and OpenCode only):

HookTriggerAction
contextSession StartInjects previous session context + memory status
session-initUser PromptInitializes/resumes session, records prompts
observationAfter Tool UseCaptures tool usage with intent detection
summarizeSession EndGenerates structured session summary
user-messageSession StartDisplays memory status to user (stderr)

Setup hooks:

npx @aitytech/agentkits-memory

What gets captured automatically:

  • File reads/writes with paths
  • Code changes as structured diffs (before → after)
  • Developer intent (bugfix, feature, refactor, investigation, etc.)
  • Session summaries with decisions, errors, and next steps
  • Multi-prompt tracking within sessions

Multi-Platform Support

PlatformMCPHooksRules FileSetup
Claude Code.claude/settings.json✅ FullCLAUDE.md (skill)--platform=claude-code
Cursor.cursor/mcp.json.cursorrules--platform=cursor
Windsurf.windsurf/mcp.json.windsurfrules--platform=windsurf
Cline.mcp.json.clinerules--platform=cline
OpenCode.mcp.json✅ Full--platform=opencode
  • MCP Server works with all platforms (memory tools via MCP protocol)
  • Hooks provide auto-capture on Claude Code and OpenCode
  • Rules files teach Cursor/Windsurf/Cline the memory workflow
  • Memory data always stored in .claude/memory/ (single source of truth)

Background Workers

After each session, background workers process queued tasks:

WorkerTaskDescription
embed-sessionEmbeddingsGenerate vector embeddings for semantic search
enrich-sessionAI EnrichmentEnrich observations with AI-generated summaries, facts, concepts
compress-sessionCompressionCompress old observations (10:1–25:1) and generate session digests (20:1–100:1)

Workers run automatically after session end. Each worker:

  • Processes up to 200 items per run
  • Uses lock files to prevent concurrent execution
  • Auto-terminates after 5 minutes (prevents zombies)
  • Retries failed tasks up to 3 times

AI Provider Configuration

AI enrichment uses pluggable providers. Default is claude-cli (no API key needed).

ProviderTypeDefault ModelNotes
Claude CLIclaude-clihaikuUses claude --print, no API key needed
OpenAIopenaigpt-4o-miniAny OpenAI model
Google Geminigeminigemini-2.0-flashGoogle AI Studio key
OpenRouteropenaianySet baseUrl to https://openrouter.ai/api/v1
GLM (Zhipu)openaianySet baseUrl to https://open.bigmodel.cn/api/paas/v4
OllamaopenaianySet baseUrl to http://localhost:11434/v1

Option 1: Environment Variables

# OpenAI
export AGENTKITS_AI_PROVIDER=openai
export AGENTKITS_AI_API_KEY=sk-...

# Google Gemini
export AGENTKITS_AI_PROVIDER=gemini
export AGENTKITS_AI_API_KEY=AIza...

# OpenRouter (uses OpenAI-compatible format)
export AGENTKITS_AI_PROVIDER=openai
export AGENTKITS_AI_API_KEY=sk-or-...
export AGENTKITS_AI_BASE_URL=https://openrouter.ai/api/v1
export AGENTKITS_AI_MODEL=anthropic/claude-3.5-haiku

# Local Ollama (no API key needed)
export AGENTKITS_AI_PROVIDER=openai
export AGENTKITS_AI_BASE_URL=http://localhost:11434/v1
export AGENTKITS_AI_MODEL=llama3.2

# Disable AI enrichment entirely
export AGENTKITS_AI_ENRICHMENT=false

Option 2: Persistent Settings

# Saved to .claude/memory/settings.json — persists across sessions
npx @aitytech/agentkits-memory hook settings . aiProvider.provider=openai aiProvider.apiKey=sk-...
npx @aitytech/agentkits-memory hook settings . aiProvider.provider=gemini aiProvider.apiKey=AIza...
npx @aitytech/agentkits-memory hook settings . aiProvider.baseUrl=https://openrouter.ai/api/v1

# View current settings
npx @aitytech/agentkits-memory hook settings .

# Reset to defaults
npx @aitytech/agentkits-memory hook settings . --reset

Priority: Environment variables override settings.json. Settings.json overrides defaults.


Lifecycle Management

Manage memory growth over time:

# Compress observations older than 7 days, archive sessions older than 30 days
npx @aitytech/agentkits-memory hook lifecycle . --compress-days=7 --archive-days=30

# Also auto-delete archived sessions older than 90 days
npx @aitytech/agentkits-memory hook lifecycle . --compress-days=7 --archive-days=30 --delete --delete-days=90

# View lifecycle statistics
npx @aitytech/agentkits-memory hook lifecycle-stats .
StageWhat Happens
CompressAI-compresses observations, generates session digests
ArchiveMarks old sessions as archived (excluded from context)
DeleteRemoves archived sessions (opt-in, requires --delete)

Export / Import

Backup and restore your project memories:

# Export all sessions for a project
npx @aitytech/agentkits-memory hook export . my-project ./backup.json

# Import from backup (deduplicates automatically)
npx @aitytech/agentkits-memory hook import . ./backup.json

Export format includes sessions, observatio

Related kits