loading…
Search for a command to run...
loading…
A fully local persistent memory layer for LLM coding agents (Claude Code, Codex, Gemini CLI, OpenCode). A shell wrapper intercepts tool invocations, fires hooks
A fully local persistent memory layer for LLM coding agents (Claude Code, Codex, Gemini CLI, OpenCode). A shell wrapper intercepts tool invocations, fires hooks on every tool call, then runs a 3-layer pipeline (extract → compress to ≤500-token digest → merge into project memory doc) at session end. The next session gets prior context injected automatically.
Persistent memory for LLM coding agents — Claude Code, Codex, Gemini CLI, OpenCode.
When you start a new session, the agent already knows what you worked on last time: decisions made, files touched, errors hit, conventions learned. No cloud. No telemetry. Everything lives in a local SQLite database at ~/.ctx-memory/store.db.
Session starts
│
Shell wrapper intercepts 'claude' (or codex/gemini/opencode)
│
MCP server starts alongside — injects prior context, exposes memory tools
│
During session: hooks fire on every tool call, messages buffered
│
Session ends (clean exit / Ctrl-C / crash)
│
Layer 1 → Layer 2 → Layer 3 pipeline runs
│
├── Layer 1: extract weighted messages, events, decisions, errors, keywords
├── Layer 2: compress to ≤500-token digest, store in DB
└── Layer 3: merge digest into project memory doc (markdown)
Next session: agent reads prior context automatically
npm install -g ctx-memory
ctx-memory setup
The setup wizard:
claude, codex, gemini, opencode)~/.ctx-memory/bin/~/.ctx-memory/bin to your PATH via ~/.bashrc / ~/.zshrcRestart your shell (or source ~/.bashrc), then use your tools as normal — memory is automatic.
ctx-memory setup # interactive setup wizard
ctx-memory status # show configuration and stats
ctx-memory projects list # list all projects
ctx-memory projects show <name> # print full memory doc for a project
ctx-memory projects forget <name> # reset memory (keeps sessions)
ctx-memory projects forget <name> --hard # delete all sessions + data
The MCP server runs as a sidecar alongside each tool session and exposes six tools:
| Tool | Description |
|---|---|
store_message |
Buffer a conversation message for processing at session end |
store_event |
Record a tool call event (file edit, bash command, etc.) |
search_context |
Search past sessions by semantic similarity or keywords |
get_project_memory |
Return the full project memory doc |
list_sessions |
List recent sessions with goals and outcomes |
end_session |
Finalize a session and run the Layer 1 → Layer 2 → Layer 3 pipeline |
To use the MCP server standalone with Claude Code, add to ~/.claude/settings.json:
{
"mcpServers": {
"ctx-memory": {
"command": "node",
"args": ["/path/to/ctx-memory/dist/src/mcp/index.js"]
}
}
}
src/
cli/ — setup wizard, status, projects commands
db/ — SQLite schema + CRUD (projects, sessions, events, digests, memory)
layer1/ — pure message/event processing → weighted Layer1Output
layer2/ — digest compression to ≤500 tokens → Layer2Digest
layer3/ — merge digest into ProjectMemory markdown
mcp/ — MCP server (handlers + stdio entry point)
wrapper/ — shell wrapper (intercepts tool invocation, manages session lifecycle)
hooks/ — hook config writers for Claude / Gemini / OpenCode
Key constraints:
sqlite-vec (384-dim)npm run build # tsc → dist/
npm run dev # tsc --watch
npm run test:run # vitest (single-shot, 476+ tests)
npm test # vitest (watch mode)
DB path defaults to ~/.ctx-memory/store.db. Override with CTX_MEMORY_DB_PATH.
MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"ctx-memory": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.