How it works
your agent (Claude Code, Codex, Cursor)
│ hooks: session start, prompt, tool call, reply, session end
▼
weavekeep hook ──► SQLite database in ~/.weavekeep ◄──► decisions.md, facts.md
│
┌────────────────┼──────────────────┐
▼ ▼ ▼
session start each prompt memory tools
(added to the (added to the recall, remember,
context) prompt) timeline, forget- Your agent runs a Weavekeep hook at fixed points in a session.
- The hook writes what happened to a SQLite database on your machine.
- Weavekeep gives memory back at session start, with matching prompts, and through four tools the agent can call.
Recording
A hook is a command your agent runs at a lifecycle event. weavekeep install adds Weavekeep's hooks to each agent's config. They record:
| Event | What is stored |
|---|---|
| Session start | A session: project folder, agent, start time |
| Prompt | Your prompt |
| After a tool call | The tool's name, its input and its result |
| Agent reply | The agent's final message for the turn |
| Compaction (Claude Code) | The compaction summary |
| Session end | The end time. In Claude Code, the transcript is then read in the background to fill in anything the hooks missed |
The Claude Code, Codex and Cursor pages list the hooks for each agent. All text passes through the secret filter before it is written; see Privacy and security.
Runs started with claude -p, the Claude Agent SDK or codex exec are not recorded and get no memory. Set WEAVEKEEP_HEADLESS=1 in their environment to include them.
Storing
Memory lives in ~/.weavekeep/keep.db, a SQLite file only your user can read. It holds:
- sessions, one per agent session, tied to the folder it ran in,
- events: prompts, replies, tool calls and results, notes,
- decisions and facts: short statements that stay current until replaced or forgotten.
Items over 4 KB are stored in full under ~/.weavekeep/blobs/, with the first 1,024 characters in the database. Decisions and facts are also written to Markdown files you can edit.
A project is the folder the agent runs in, as an absolute path. Two checkouts in different folders are two projects.
Giving memory back
At session start
The block added at session start holds, in this order:
- the guidance lines on when to save and search memory (always, even with nothing stored),
- the project's decisions from its
decisions.md, newest first, - your rules for every project,
- copies of Claude Code's own memory notes, if you share them (Claude Code does not get its own notes twice),
- stored facts for the project and for every project,
- in a new session, the start of the agent's final message from the previous session in this project (at most 700 characters).
An empty part is left out. Decisions, rules, notes and facts are an index: one line each, at most 120 characters, cut after a whole word and ending in "…" when shortened. The agent's recall finds the full text, and when a prompt matches a shortened decision or fact of this project, Weavekeep adds its full text to that prompt. Together they take at most about 4,000 characters (2,800 in Codex). When they do not fit, every line is shortened first, down to 80 characters; only then are the oldest items left out, decisions and rules last, and the part's last line says how many, for example - (12 more decisions in that file; `recall` finds them).
When you resume a session, or when Claude Code compacts a conversation, the decisions, facts and guidance are added again, without the previous session's message. Your first session shows an example.
Memory added to prompts
Each prompt is searched against the decisions and facts saved for this project. Close matches are added to the prompt, best first:
Weavekeep recall for this prompt:
- [fact 01a1600e-…] decision: Cart totals use integer cents, never floats.Most prompts get nothing, on purpose. The rules:
- At most two items, about 600 characters in total. Each is the whole decision, so a decision shortened at session start arrives in full when a prompt matches it. A single decision longer than that is cut to fit, ending in "…". A second item that does not fit is left out.
- Only saved decisions and facts. What was only said in a session (replies, earlier prompts, command output) is never added. The agent finds it with
recall, and you withweavekeep search. To have something come back on its own, save it. - Only close matches. An item must share the specific words of your prompt. How much a word counts depends on how rare it is across everything stored: your sessions as well as your saved decisions and facts. Words common in your conversations count for little, so "yes", "ok" or "looks good" add nothing.
- Some prompts are skipped: prompts under 3 characters, slash commands, and messages the agent's harness sends as if you typed them, such as task notifications.
- Only this project. Your rules for every project are shown at session start, and the agent's
recallfinds them, but they are not added to prompts: they matched everyday words such as "pc" or "install" far more often than they applied. - No repeats. An item shown in full at session start, or added earlier in the session, is not added again in that session, also after the conversation is compacted.
In Cursor, whose prompt hook cannot add context, the prompt's memory arrives after the first tool result of the turn. See Cursor.
The memory tools
Weavekeep runs a small MCP server, weavekeep serve, that your agent starts itself. It offers four tools:
| Tool | What the agent uses it for |
|---|---|
recall | Search memory with a few keywords |
remember | Save a decision (the default), a fact or a note |
timeline | List what happened, in time order |
forget | Hide an item that is wrong or should not be stored |
Parameters and limits are in MCP tools.
Telling the agent when to save
Claude Code and Cursor keep their own memory, and a rule you tell one of them stays there. So Weavekeep tells every agent to save the rules, preferences and decisions you state to Weavekeep as well, with remember. The same guidance reaches the agent in three places:
- the guidance lines at session start,
- the MCP server's instructions, a short version for agents without Weavekeep's hooks, and the tool descriptions,
- the Weavekeep skill that
weavekeep installadds (~/.claude/skills/weavekeepfor Claude Code,~/.agents/skills/weavekeepfor Codex and Cursor).
Weavekeep never edits your CLAUDE.md or AGENTS.md.
The reminder on your prompt
Agents do not always save a rule the moment you say it. In Claude Code and Codex, when your prompt has words that often come with a rule, such as "always", "never", "don't", "from now on", "prefer", "instead", "stop" or "I said", Weavekeep adds one line to that prompt's context: "If this prompt states a lasting rule, preference or decision, save it with Weavekeep remember." Other prompts get no line.
The words only pick the moment. The agent decides what is a lasting rule and what is a one-off instruction, and saves it in the same turn. Weavekeep never stops a turn or asks for an extra one.
The line goes in the same context as the memory recalled for that prompt and counts toward its size limit; the recalled lines make room for it. Cursor's prompt hook cannot add context, so there the skill and the Cursor rule are the reminder.
When you change your mind
Decisions add up, so an old one stays until something retires it. The agent does that:
- When it saves a decision,
rememberreturns up to three similar saved decisions. If the new one replaces one of them, the agent forgets the old one.
Forgetting hides a decision; nothing is deleted. You can do it yourself too; see Forget and export.
Search
Search is keyword search on your machine. It matches word beginnings and simple word forms, parts of file names and identifiers, and corrects small typos. Rare words count for more than common ones. See Search your memory.
Semantic search adds a local embedding model that finds memory by meaning. It is on by default; weavekeep embeddings off turns it off.
It never blocks your agent
Hooks fail open:
- Each hook gives up after 2 seconds (1.2 seconds at session end).
- If anything goes wrong or time runs out, the hook prints one line to stderr and exits with code 0. Your agent carries on without memory for that step.
- Slow work, such as reading a transcript after a session or importing a large memory file, runs in the background.
weavekeep doctor runs a test hook and reports how long it took.