Entry 04
Giving the AI a memory, and making it use it
Every new session started blank, so I built the AI a memory database called Jarvis. Then I spent months learning that a rule written in a chat is a wish, not a rule. How to give your AI a memory that works.
Every morning in May, I explained night-outs to a machine that had understood them perfectly the afternoon before.
That is how these tools work out of the box. Each new session starts blank. I would spend an hour teaching Claude how our drivers are paid for nights away, close the window, and the next day it knew nothing. My complaint at the time, close to verbatim: every time I close its terminal, it doesn’t have it in its memory.
Notes first
The first fix was plain text. From 31 May each project got a set of note files (what it is, what changed, known bugs, decisions), and Claude read them at the start of every session. It helped. It also grew into a pile of files that only covered one project at a time.
On 2 June we planned something bigger: one memory database that every session on either of my PCs reads from and writes to. I called it Jarvis. Then it sat unbuilt for eleven days, because the free database plan I was on allowed two projects and both were taken by live apps. I was not going to take a live app down to make room. On 13 June we put Jarvis on a different provider, Neon, and carried on.
How Jarvis works
After a session ends, a small, cheap AI model reads the transcript and pulls out what is worth keeping: decisions, fixes, rules, facts about the business. A larger model removes duplicates. Each memory is stored with a numeric fingerprint of its meaning (an “embedding”), so a later session can search for “how do night-outs work” and find the right note even when the words differ.
The first week brought two bugs worth knowing about. The small model kept carrying on the conversation it was meant to summarise, as if it were one of the speakers, until we forced it to answer in a fixed structure. And a command that cut its output at a hundred lines quietly killed the first bulk import after 7 of 82 old sessions. On 14 June the full import ran and Jarvis gained 602 memories in a day. Today it holds close to two thousand.
Remembering is not the same as using
Having a memory did not mean Claude looked at it. The rule was “connect to Jarvis at the start of every session”, written in the instructions. Claude kept skipping it. I kept catching it out, and I got fed up.
On 27 June we changed the start-up script so that it syncs the memory itself, without asking the AI to remember. On 2 July we went further and added a gate: every tool stays blocked until the session has contacted Jarvis. Claude is not allowed to change its own permission settings, which I think is right, so I installed the gate by hand. It still runs. The session that drafted this entry started with three blocked attempts until it had connected.
The quiet failures
The memory system broke in ways that taught me more than building it did.
- 30 June: the job that refreshes each PC’s copy of Jarvis every ten minutes had been dead for a day, while Windows reported every run as a success. The launcher started the job and never checked that it finished. A database connection with no time limit had hung after the laptop went to sleep.
- 3 July: Claude found 437 orphaned processes on my laptop. My PowerShell profile started Claude every time any PowerShell window opened, including the hidden one the ten-minute sync used.
- End of August: the database locked. The sync was downloading every memory in full, every ten minutes, on two PCs: about 5.9 GB a month against a free allowance of 5.5 GB. A small local queue saved the twenty memories written while it was down. We rewrote the sync to ask “has anything changed?” first, and I moved to a paid plan.
- 24 September: the index Claude loads at the start of each session was being cut off at about 24 KB. Anything past that point did not exist for the AI, including a note on how our paper delivery notes move through the office. The index now stays under 16.5 KB.
Build it yourself: three levels of memory
Level 1: a notes file (an afternoon). Claude Code automatically reads a file called CLAUDE.md in your project folder at the start of every session. Put the things you keep re-explaining in it: what the business does, the vocabulary (“a trip is everything between leaving the depot and coming back”), the rules, where files live. Keep it short and current. This alone fixes most of the “it forgot” problem for a single project.
Level 2: a memory database (a weekend with the AI’s help). When you have several projects or two PCs, give the memory one home. Ours is a single table with these columns:
| Column | What it holds |
|---|---|
| domain, type | which project, and whether it is a rule, a fix, a decision or a fact |
| title, content | a one-line summary and the detail |
| tags, embedding | keywords, and the meaning-fingerprint for search |
| device, created_at | which PC wrote it, and when |
Any hosted Postgres database with the pgvector extension can hold it. Ask the AI to write the extraction step (summarise a finished session into memories) and a search step (find the memories closest in meaning to a question).
Level 3: enforcement. If something must happen every session, do not leave it to an instruction. Claude Code supports hooks: small scripts that run at set moments, such as when a session starts or before a tool runs. We use one at start-up to sync the memory, and one that blocks tools until the memory has been checked. Give any blocking hook an escape hatch (ours opens after three refusals), or one outage will lock you out of everything.
And check it is alive. A scheduler’s green tick only proves the job started. Have the job write a “last finished at” time somewhere you will see it.
What I took from it
Give the AI a memory early. You will explain your business once instead of fifty times. Then assume your rules will be ignored unless something enforces them.
One distinction took me until September to put into words. Memory holds the findings: what happened, what we decided. The method for a recurring job belongs in a written procedure the AI follows. Those procedures get their own entry.
Next: the day my laptop deleted my work, and a missing load that was never missing.
Written from my build notes. I keep a running memory of every session with the AI, and each entry is drafted from those notes with Claude's help, then checked and edited by me.
Get the next entry by email
One short email when an entry goes live, Tuesday and Friday. Nothing else, and one click to stop.
Your address is used for these emails only. It is not shared or sold.