MCPcopy Index your code
hub / github.com/JuliusBrussee/cavemem

github.com/JuliusBrussee/cavemem @v0.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.1 ↗ · + Follow
220 symbols 722 edges 86 files 4 documented · 2% updated 4d agov0.2.1 · 2026-05-06★ 6064 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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 status Single dashboard: wiring, DB counts, embedding backfill, worker pid
cavemem config show\|get\|set\|open View/edit settings — schema is self-documenting
cavemem start\|stop\|restart Control the worker daemon (usually unnecessary — auto-starts)
cavemem viewer Open the memory viewer in your browser
cavemem doctor Verify installation
cavemem search <query> [--limit N] [--no-semantic] Search memory (BM25 + cosine re-rank)
cavemem compress <file> Compress a file with caveman grammar
cavemem reindex Rebuild FTS5 + vector index
cavemem export <out.jsonl> Dump observations to JSONL
cavemem mcp Start MCP server (stdio)

MCP

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

Tool Returns
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

Key Default
dataDir "~/.cavemem" SQLite location
compression.intensity "full" lite / full / ultra
compression.expandForModel false Return expanded text to model
embedding.provider "local" local / ollama / openai
workerPort 37777 Local viewer port
search.alpha 0.5 BM25 / vector blend
search.defaultLimit 10 Default 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.

Repo What One-liner
caveman Output compression skill why use many token when few do trick — ~75% fewer output tokens across Claude Code, Cursor, Gemini, Codex
cavemem (you are here) Cross-agent persistent memory why agent forget when agent can remember — compressed SQLite + MCP, local by default
cavekit Spec-driven autonomous build loop why 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

Extension points exported contracts — how you extend this code

RankItem (Interface)
(no doc)
packages/core/src/ranker.ts
StorageOptions (Interface)
(no doc)
packages/storage/src/storage.ts
Embedder (Interface)
(no doc)
packages/embedding/src/types.ts
CompressOptions (Interface)
(no doc)
packages/compress/src/compress.ts
RunHookOptions (Interface)
(no doc)
packages/hooks/src/runner.ts
SettingDoc (Interface)
(no doc)
packages/config/src/docs.ts
ClaudeSettings (Interface)
(no doc)
packages/installers/src/claude-code.ts
WorkerState (Interface)
(no doc)
apps/cli/src/commands/status.ts

Core symbols most depended-on inside this repo

runHook
called by 24
packages/hooks/src/runner.ts
loadSettings
called by 21
packages/config/src/loader.ts
resolveDataDir
called by 18
packages/config/src/loader.ts
close
called by 15
packages/storage/src/storage.ts
compress
called by 14
packages/compress/src/compress.ts
countEmbeddings
called by 13
packages/storage/src/storage.ts
putEmbedding
called by 12
packages/storage/src/storage.ts
addObservation
called by 11
packages/core/src/memory-store.ts

Shape

Function 145
Interface 36
Method 35
Class 4

Languages

TypeScript100%

Modules by API surface

packages/storage/src/storage.ts24 symbols
packages/core/src/memory-store.ts17 symbols
packages/compress/src/compress.ts8 symbols
apps/worker/src/embed-loop.ts8 symbols
packages/config/src/docs.ts7 symbols
apps/worker/src/server.ts7 symbols
packages/storage/src/types.ts6 symbols
packages/compress/src/lexicon.ts6 symbols
apps/cli/src/commands/status.ts6 symbols
apps/cli/src/commands/lifecycle.ts6 symbols
apps/cli/src/commands/config.ts6 symbols
packages/installers/src/types.ts5 symbols

For agents

$ claude mcp add cavemem \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact