cavemem

April 18, 2026 · View on GitHub

cavemem

why agent forget when agent can remember

npm Stars Last Commit License

InstallHow it worksCLIMCPSettings

🪨 Caveman Ecosystem  ·  caveman talk less  ·  cavemem remember more (you are here)  ·  cavekit build better


Cross-agent persistent memory for coding assistants. Hooks fire at session boundaries, compress observations with the caveman grammar (~75% fewer prose tokens, code and paths preserved byte-for-byte), and write to local SQLite. Agents query their own history through three MCP tools. No network. No cloud.

Supports: Claude Code · Cursor · Gemini CLI · OpenCode · Codex

  • Persistent memory across sessions. Hooks capture what happened; the store keeps it.
  • Compressed at rest. Deterministic caveman grammar, round-trip-guaranteed expansion for humans.
  • Progressive MCP retrieval. search, timeline, get_observations — agents filter before fetching.
  • Hybrid search. SQLite FTS5 keyword + local vector index, combined with a tunable ranker.
  • Local by default. No network calls. Optional remote embedding providers via config.
  • Web viewer. Read-only UI at http://localhost:37777 for browsing sessions in human-readable form.
  • Cross-IDE installers. Claude Code, Gemini CLI, OpenCode, Codex, Cursor — one command each.
  • Privacy-aware. <private>...</private> stripped at write boundary. Path globs exclude whole directories.

Install

npm install -g cavemem
cavemem install                    # Claude Code
cavemem install --ide cursor       # cursor | gemini-cli | opencode | codex
cavemem status                     # see wiring + embedding backfill
cavemem viewer                     # open http://127.0.0.1:37777

No daemon to start. Hooks write synchronously. A local worker auto-spawns in the background on the first hook to build embeddings; it self-exits when idle. Disable with cavemem config set embedding.autoStart false.


How it works

session event  →  redact <private>  →  compress  →  SQLite + FTS5

                                                MCP queries on demand

What compression looks like in practice:

Input:  "The auth middleware throws a 401 when the session token expires; we should add a refresh path."
Stored: "auth mw throws 401 @ session token expires. add refresh path."
Viewed: "The auth middleware throws a 401 when session token expires. Add refresh path."

Code blocks, URLs, paths, identifiers, and version numbers are never touched. Hook handlers complete in under 150ms. Full bodies fetched on demand via get_observations.


CLI

Command
cavemem install [--ide <name>]Register hooks + MCP for an IDE
cavemem uninstall [--ide <name>]Remove hooks + MCP
cavemem statusSingle dashboard: wiring, DB counts, embedding backfill, worker pid
cavemem config show|get|set|openView/edit settings — schema is self-documenting
cavemem start|stop|restartControl the worker daemon (usually unnecessary — auto-starts)
cavemem viewerOpen the memory viewer in your browser
cavemem doctorVerify installation
cavemem search <query> [--limit N] [--no-semantic]Search memory (BM25 + cosine re-rank)
cavemem compress <file>Compress a file with caveman grammar
cavemem reindexRebuild FTS5 + vector index
cavemem export <out.jsonl>Dump observations to JSONL
cavemem mcpStart MCP server (stdio)

MCP

Progressive disclosure: search and timeline return compact results; get_observations fetches full bodies.

ToolReturns
search(query, limit?)[{id, score, snippet, session_id, ts}] — BM25 + optional cosine re-rank
timeline(session_id, around_id?, limit?)[{id, kind, ts}]
get_observations(ids[], expand?)Full bodies, expanded by default
list_sessions(limit?)[{id, ide, cwd, started_at, ended_at}]

Settings

~/.cavemem/settings.json

KeyDefault
dataDir"~/.cavemem"SQLite location
compression.intensity"full"lite / full / ultra
compression.expandForModelfalseReturn expanded text to model
embedding.provider"local"local / ollama / openai
workerPort37777Local viewer port
search.alpha0.5BM25 / vector blend
search.defaultLimit10Default result count
privacy.excludePatterns[]Paths never captured

Content inside <private>...</private> is stripped before write. Paths matching excludePatterns are never read. The worker binds to 127.0.0.1 only.


🪨 The Caveman Ecosystem

Three tools. One philosophy: agent do more with less.

RepoWhatOne-liner
cavemanOutput compression skillwhy use many token when few do trick — ~75% fewer output tokens across Claude Code, Cursor, Gemini, Codex
cavemem (you are here)Cross-agent persistent memorywhy agent forget when agent can remember — compressed SQLite + MCP, local by default
cavekitSpec-driven autonomous build loopwhy agent guess when agent can know — natural language → kits → parallel build → verified

They compose: cavekit orchestrates the build, caveman compresses what the agent says, cavemem compresses what the agent remembers. Install one, some, or all — each stands alone.

Also by Julius Brussee

  • Revu — local-first macOS study app with FSRS spaced repetition. revu.cards

License

MIT