DEV Community

Nevals
Nevals

Posted on Originally published at huggingface.co AI-assisted

Stop paying your AI agent to re-learn your codebase

File-anchored memory for coding agents, built on SQLite. No embeddings API, no cloud.

Every new session with a coding agent starts cold. It re-reads the files it read yesterday, asks again which test command to run, and rediscovers that the Stripe webhook needs the raw request body, a decision you already explained. You pay for all of it, every session.

amem is an open-source memory layer for coding agents (Claude Code, Cursor, Codex, Windsurf, Copilot, Gemini CLI, Grok and any MCP client) that keeps what the agent learned in one SQLite file on your machine. This article covers how it works and what we measure.

Why "memory" usually goes wrong

Storing notes isn't the hard part. Serving the right note, and not a stale one, is.

An outdated rule is worse than no rule. If your memory says "deploys go through Heroku pipelines" after you moved to Fly.io, the agent confidently does the wrong thing, and you pay in output tokens and review time to undo it. Most memory tools have no idea when something they stored stopped being true.

Facts anchored to files

amem stores short facts (constraints, gotchas, decisions, how-tos) tied to the source files they describe:

Stripe webhooks must be verified against the raw request body; the JSON body parser breaks the signature check. → src/webhooks/stripe.ts

When a fact is saved, amem records a content hash of each anchored file. If the file changes later, every fact about it is flagged stale in the next context packet until someone re-confirms it. The agent sees "verify before trusting" instead of a silent, possibly wrong rule.

Two more lifecycle tools keep memory honest:

  • Supersession: a new decision can retire the old one (supersedes: [ids]). The old fact stays as history, but it's no longer served.
  • Expiry: debugging notes and incident context get a TTL (ttl_days) and drop out of recall on time.

Retrieval without an embeddings API

Coding-agent memory is a small corpus (hundreds to a few thousand facts) that changes every day. That's a good fit for classic retrieval:

  • SQLite FTS5 with BM25 over facts, skills and tasks, kept in sync on every write.
  • A 256-dimension n-gram encoder that runs in-process. There's nothing to download and no Ollama or Python.
  • Small synonym groups, so natural phrasing reaches the words people wrote: "auth flow" finds "JWT login middleware".
  • Ranking signals: recency, how often a memory was used, pins and task status, blended with relevance.

If a SQLite build lacks FTS5, amem falls back to keyword scoring rather than failing.

What we measure

amem's CI runs a retrieval benchmark on every change, and it's now public: iamem/amem-retrieval-bench. It has 36 memories of a fictional web shop and 40 questions. 32 are phrased the way developers actually ask, often without the memory's words; 8 are vague prompts like "ok sounds good, go ahead".

Path Right memory first In the top 3 Vague prompts given memory
Prompt hook (automatic) 88% 97% 0%
amem_context (agent asks) 81% 94% n/a

The last column matters as much as the first two. Injecting memory into a prompt that names no topic is pure token waste, so amem's automatic hook returns nothing for those.

You can try the same search in the browser: amem demo Space runs the real package against the benchmark data, and shows the exact packet an agent would receive.

Budgets, not dumps

Uncached tool results are the expensive part of every agent turn, so amem is built to send less:

  • max_tokens on recall and context: results are packed in rank order and never cut mid-item, and the reply says what was left out.
  • amem_bootstrap: one call at session start (about 350 tokens) returns the top global rules, the project's key facts, active tasks and skill hints, instead of several lookups.
  • Skills as one-line hints: repeatable procedures (release, deploy, migrations) appear as a name and a summary; the full body loads only when the agent decides it applies.

Three primitives

  1. File-anchored facts, as above.
  2. On-demand skills: procedures stored as SKILL.md outside the system prompt.
  3. A cross-agent task board: backlog → next → doing → done, shared across tools. Start a task in Cursor and pick it up in Claude Code.

Install

App Install
Claude Code /plugin marketplace add sslugic/amem, then /plugin install amem@amem
Codex codex plugin marketplace add sslugic/amem, then /plugins
Gemini CLI gemini extensions install https://github.com/sslugic/amem
Cursor, VS Code, LM Studio one-click buttons at getamem.com
Claude Desktop download amem.mcpb and double-click it
Anything else npx @iamem/amem setup, plus the setup guide

Memory stays in ~/.amem. A local dashboard (amem ui) lets you browse, edit and retire what your agents remember.

What's next

We're running a before/after measurement of real Claude Code spend with amem switched on and off (amem off / amem on exist for exactly this). We'll publish the numbers, good or bad.

amem is MIT-licensed and free. Feedback, issues and stars are welcome: github.com/sslugic/amem · getamem.com · fact sheet

Top comments (1)

Collapse
 
dosaygo profile image
dosaygo •

Anchoring facts to file content hashes solves stale gotchas on files the agent already plans to open; what still burns tokens in multi-session runs is an agent inventing a brand-new module because nothing at session start forced it to name the existing symbol it is extending.