memory.cpp CLI
memory.cpp compiles repository history into compact agent context and filters out stale items, secrets and contradictions
- 726 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- Reads repository history, traces and tests and builds the text that goes into the agent prompt
- The vault stores agent facts in SQLite, and the write firewall catches only known dangerous-entry patterns
Install
- Works in
Manual install
cargo install --path crates/memory-cliInstalls from a clone of the repository. `./scripts/install.sh` and `./scripts/install.ps1` also exist.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Reads repository history, traces and tests and builds the text that goes into the agent prompt
- The vault stores agent facts in SQLite, and the write firewall catches only known dangerous-entry patterns
This is third-party code. Review the repository files before installing.
What it does
memory.cpp is a local context compiler that works before the model is called. It turns repository history, decisions, fixes, execution traces, tests and rules into a pack of blocks with a source, freshness, sensitivity and token cost. A stable prefix is separated from a volatile suffix and hashed with blake3, so repeated requests hit the provider cache. The `memory remember` and `memory recall` commands keep a vault in SQLite inside `.memory.cpp/`. `memory compile "task" --provider anthropic --budget 1500` builds a pack for a provider, `memory cache-manifest` shows the cacheable regions, and `memory lock` writes a reproducible lockfile with a ledger. Negative memory stores stale docs and failed fixes as exclusions, and freshness proofs tie facts to files, commits and tests. A write firewall screens dangerous entries before they are stored, and secrets are redacted. For agents there is `memory pack --for claude|codex|gemini|cursor|continue|mcp`, the `memory mcp install --client claude` command and an MCP server that is read-only by default. There is no cloud, no account and no telemetry until you enable a connector yourself.
Who it is for. Developers whose agents burn tokens on long tasks by rereading the repository and pulling in outdated decisions.
Good fit when
- An agent on a long task rereads the same files and test results every turn
- Old ADRs and failed fixes land in the prompt and cause wrong patches
- You need to prove what the model received: the ledger and lockfile fix the pack contents
- A stable prefix should earn prompt cache hits at Anthropic, OpenAI or Gemini
- Project rules and invariants need checking in CI with `memory ci-check`
Not a fit when
- You need memory for a general assistant or cloud storage across devices: the vault is local, inside the repository
- You want to compress the provider's KV cache: the project reduces pressure on it through the prompt and does not compress the cache itself
- A hand-written `CLAUDE.md` rules file is enough for a small project
Example request
Use memory compile to build context for the task of fixing the billing export with a 1500 token budget and show what was excluded as staleLimitations
The project builds from Rust source with `cargo build -p memory-cli` or installs with `./scripts/install.sh` and `./scripts/install.ps1`. The savings figures come from the bundled synthetic CAMC-Bench corpus and can differ on real repositories. KV cache load figures are called estimates until measured on a concrete runtime. The README lists no package in registries. The MCP server exposes resources read-only, and writes to the vault go through CLI commands. The last commit dates from 2 November 2026.
How to disable. Delete the `.memory.cpp/` folder in the repository and the `memory` binary installed by the script or `cargo install`. Remove the MCP connection in the agent settings where `memory mcp install` added it.
FAQ
How do I install memory.cpp?
Clone the repository and run `./scripts/install.sh` (`./scripts/install.ps1` on Windows) or `cargo install --path crates/memory-cli`. `cargo build -p memory-cli` builds in place.
How do I connect memory.cpp to Claude Code?
Run `memory mcp install --client claude`. The MCP server exposes read-only resources, so the agent cannot change the vault directly.
How does memory.cpp differ from Mem0 or a vector database?
Instead of retrieving top-k similar chunks it compiles a pack: it excludes stale items, checks freshness, lays out a stable prefix and records the contents in a ledger.
Does memory.cpp compress the model KV cache?
No. It keeps unnecessary, stale and duplicated tokens out of the prompt, and latency and cache figures stay estimates until measured.
Does memory.cpp send data to the cloud?
No. The vault is SQLite inside `.memory.cpp/`, with no accounts, telemetry or network calls until you enable a connector.
Discussion
No questions or reviews yet.
Related
CLI toolsLocal memory for agents with a review queue: SQLite, an audit log and a token ledger, one vault for Claude Code, Codex and Cursor
Local memory for an agent: hooks record facts from conversations and the MCP server brings them back in later sessions from one SQLite file
Shared local memory for AI agents: Claude Code, Codex, Cursor and others find the agreements of past sessions in it and record new ones
Agent memory as a graph of linked facts: decisions and errors outlive the session, with no vector database or paid API calls
Long-term memory for Claude Code, Cursor and Codex: the agent saves decisions and finds them again in later sessions
A long-term memory MCP server for AI agents: facts fade along a forgetting curve and related records are compressed into a summary
README in short
The README presents memory.cpp as a context compiler that decides what goes into the stable prefix, what into the fresh suffix and what to exclude. After a 60-second quickstart it describes a table of long-task agent problems, the compiler design with an intermediate representation and ledger, the CAMC-Bench benchmark and a command table by area. A comparison with memory products, a privacy section and the validation steps follow.