Local cross-session memory for Claude Code and OpenCode. Indexes your coding sessions into SQLite and auto-summarizes key decisions so your next session starts with full context.
No cloud. No auth. No telemetry. Everything runs on your machine.
AI coding agents forget everything between sessions. You re-explain the same architecture, the same conventions, the same bugs. This tool fixes that:
- Watches
~/.claude/projects/for session JSONL files - Indexes every user/assistant turn into a local SQLite database
- Summarizes recent sessions via Claude Haiku — extracts decisions, file paths, patterns, bugs
- Writes summaries to memory files that Claude Code and OpenCode auto-load on next session start
Your agents get smarter over time, automatically.
git clone https://github.com/takhir-iota/agent-memory.git
cd agent-memory
npm install
npm link # makes `agent-memory` available globallyRequires Node.js 18+ and an Anthropic API key for summarization.
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.zshrc
source ~/.zshrcagent-memory index
# Found 83 session files
# Done: 66 sessions, 5507 new turns
# Total: 79 sessions, 5925 turns across 8 projectsagent-memory search "auth|token|jwt"
agent-memory search "refactor" --type user --project speak
agent-memory search "skeleton" --limit 5Options:
--type <all|user|assistant|sessions>— filter by role--project <name>— filter by project (substring match)--limit <n>— max results (default: 20)--context <n>— characters around match (default: 120)
agent-memory summarize # last 24 hours
agent-memory summarize 48 # last 48 hoursCalls Claude Haiku to distill sessions into per-project memory files at ~/.agent-memory/projects/. These get symlinked to:
~/.claude/projects/{project}/memory/MEMORY.md— Claude Code reads this automatically~/{project}/OPENCODE.md— OpenCode reads this automatically
agent-memory sessions # list all indexed sessions
agent-memory sessions --project speak # filter by project
agent-memory stats # show totalsTwo launchd services keep everything up to date automatically:
# Install
cp com.agent-memory.watcher.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.agent-memory.watcher.plist
# Check
cat ~/.agent-memory/watcher.log# Install (requires ANTHROPIC_API_KEY in the plist)
cp com.agent-memory.summarizer.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.agent-memory.summarizer.plist
# Check
cat ~/.agent-memory/summarizer.logYou use Claude Code / OpenCode
│
▼
Claude writes ~/.claude/projects/…/session.jsonl
│
▼
Watcher detects change (chokidar, 2s debounce)
│
▼
Parser streams JSONL line-by-line → SQLite
│
▼
Summarizer (hourly) calls Claude Haiku
│
▼
Writes ~/.agent-memory/projects/{project}.md
│
├──▶ symlink → Claude Code MEMORY.md
└──▶ symlink → OpenCode OPENCODE.md
│
▼
Next session auto-loads memory → better context
src/watcher.js— chokidar file watcher on~/.claude/projects/**/*.jsonlsrc/parser.js— streams JSONL line-by-line (handles 500MB+ files), extracts user/assistant turnssrc/db.js— SQLite via better-sqlite3 (WAL mode), stores sessions + turnssrc/search.js— regex search across all indexed turns with project/role filteringsrc/summarizer.js— calls Claude Haiku to distill recent turns into memory bulletsbin/cli.js— CLI entrypoint
Data lives at ~/.agent-memory/sessions.db. Delete it and re-run agent-memory index to rebuild.
Built as a replacement for onecontext-ai (aline-ai) which requires Supabase auth, sends session data to a third-party Vercel backend, includes remote kill switches, and tracks LLM usage for billing. This project does the same useful things — indexing, search, summarization — with zero cloud dependencies.
MIT