Memory
Stop paying for the same trap twice
- Module
- Module 04
- Deliverable
- A memoire/ folder with five entries in the module's format, and an INDEX.md that your tool has every session read at launch
- Access
- preview
Before you read
- What you will be able to do
By the end, you write each solved trap in an entry your agents find by its symptom, and on a fixed date you delete the entries that have become false or belong to a single project.
- What you will do
- Action 1: Put the entry template in your repository
- Action 2: Title your last incident by its symptom
- Action 3: Have the index read at launch
- Action 4: Search the memory for secrets and private names
- Action 5: Put the six-month test to an agent
- Action 6: Date the next purge
Then the exercise: Cinq fiches et un index, pour arrêter de payer deux fois le même piège (in French)
- Time
26 min reading, 75 min exercise
- Updated on
- Before you start
Nothing in particular: the module stands on its own.
- Words used in this module
- toolThe software that runs your coding agents.
- agentA session you open in your tool, or a subagent: a secondary session that a session starts and hands part of the work to.
- instructions fileThe file your tool has every session read at launch: AGENTS.md, CLAUDE.md or its equivalent.
- fresh sessionA session opened without the history of your earlier sessions: it knows only what the tool has it read.
- trapA failure whose cause does not show at first glance, and that you, or an agent, can fall into again.
- incidentOne time you, or an agent, fell into a trap.
- symptomWhat the person who falls into a trap sees: the error message, or what is displayed.
- false leadThe cause suspected first, wrongly, with the reason it seemed right.
- entryA file that records a single trap you ran into, in seven sections: what was seen, the false lead, the cause, the fix, the checking command, the rule that avoids it, and where else it hides.
- noteAny text your agents reread from one session to the next, outside the instructions file: an entry, or any other remark kept for them, by you or by the agent itself.
- factWhat a note states and that could be checked: a trap and its cause, or the progress of a project.
- memoryThe versioned folder where you keep your entries, and that your agents reread from one session to the next.
- six-month testThe question put to each entry before keeping it: will this fact still be true in six months, on another project? It takes both: lasting, and holding outside the project where you learned it.
- purgeA reread of the memory, on a date noted in advance: each entry that is false, or fails the six-month test, is deleted, with no archive; what is still useful first goes to your tickets or the repository.
- indexThe file that lists the entries, one line each (the symptom, the path, and when to read it), under a line that gives the date of the next purge; your tool has every session read it at launch.
The same trap, the third time
Take a service whose database rejects the password. Yet the password is the right one: it is the one in the secrets manager, and it works when you type it by hand. You suspect the network, because a connection that reaches the wrong server gets the same rejection. Then you compare, byte by byte, the password written in the service's configuration with the one in the manager: they are identical.
The cause is elsewhere. The generated password contains a % followed by two hexadecimal digits
(the digits 0 to 9 and the letters A to F): %41, for example. The service's configuration
assembles it into a connection string, the text that gives the application the host, the user and
the password of its database, written like a web address:
scheme://user:password@host/database. In a web address, a % followed by two hexadecimal digits
encodes another character: %41 encodes the letter A.
At launch, the library that opens the connection reads the string, and decodes the password before
sending it: x%41y becomes xAy. So the database receives a different password from the one in
the manager, and rejects it.
The safest fix: a new password, with none of the characters that mean something in the string
(%, /, #, ? and @, among others). The command openssl rand -hex 32 generates one, made
only of digits and the letters a to f.
In this scene, it is the third time you fall into this trap: a failure whose cause does not show at first glance, and that you, or an agent, can fall into again. Each fall into a trap is an incident. The first two times, you had fixed the failure, then moved on without writing anything down.
As soon as a trap is solved, write it in an entry, and put the entry where your agents will read it.
An entry is written within the hour after the fix. The error trace is still in front of you: everything the terminal or the logs displayed at the moment of the error. And you remember the false lead: the cause suspected first, wrongly, with the reason it seemed right. Without an entry, the next diagnosis starts from zero. If the trap comes back, the entry hands you the diagnosis already done.
With agents, the entry matters even more. You, on the third pass, at least keep a feeling of having seen this before. An agent has none: of the past, it knows only what it is given to read.
This module calls memory the versioned folder where you keep the entries and their index, and
that your agents reread from one session to the next. An entry records a single trap you ran
into, in seven sections: what was seen, the false lead, the cause, the fix, the checking command,
the rule that avoids it, and where else it hides. The index lists the entries, one line each.
Your agents are the sessions you open in your tool, and the subagents they launch, meaning the
secondary sessions that a session starts and hands part of the work to. Your tool, the software
that runs your agents, has them read this index at the launch of every session. It does so through
its instructions file, the one it has every session read at launch: AGENTS.md, CLAUDE.md or
its equivalent.
This module calls note any text your agents reread from one session to the next, outside the
instructions file. An entry is a note. A line in a notes file, the file where you keep remarks for
your agents (a NOTES.md, for example), is one too. Some tools also keep their own notes folder,
which the agent fills in itself over the sessions: its items are notes. If your tool keeps one,
create memoire/ anyway, with the action "Put the entry template in your repository", further
down. Keep both: memoire/, versioned, for your entries; the tool's folder for what it puts there.
A trap the agent noted in the tool's folder also goes, as an entry, into memoire/. When you
reread the tool's notes, apply the same writing rules to them as to the entries.
I am the author of this manual, the set of modules this one belongs to: in the evidence that follows, and everywhere else, "I" refers to my own practice.
When this module is useless
Do you open fewer than about ten sessions a month? Writing entries will cost you more than the diagnoses they would spare you. The same trap is unlikely to come back, and the index will stay too short for your agents to often find what they are looking for in it. This threshold of ten sessions is an order of magnitude, not a measurement.
Second case: your way of working with agents still changes every two weeks. Entries written now would describe habits you are in the middle of dropping. Wait until your practice settles.
In both cases, do only the action "Put the entry template in your repository", further down. You will have the template at hand the day a trap costs you a diagnosis you do not want to redo.
One entry, one fact
A fact, here, is what a note states and that could be checked. For example: "in a connection
string, a %41 in the password reaches the database as an A", or "such and such a migration is
finished". The first belongs in an entry. The second will go elsewhere, in your task list, meaning
wherever you track your work: a ticket, a tracking file. The reason comes later. An entry records
only one fact, and that fact is a trap: its seven sections describe that one trap. The entry notes
the date of each incident, and keeps only what the repository does not already say through its code
or its history. Four rules keep an entry right, and each one avoids a specific defect.
Do not write what the repository already knows. The structure of the code, the git history, the list of dependencies can be reread on demand, and move with every commit. An entry that describes the project's file tree becomes false with the first folder moved, and nothing in it says so: the agent reading it cannot tell it from an entry that is right.
Write absolute dates. "Last week" means nothing in a file reread six months later. Each entry carries the date of each incident, in YYYY-MM-DD format.
Delete what becomes false. Do not archive it, do not comment it out, do not move it to an
obsolete/ folder: delete it. A memory that grows without ever shrinking becomes too long for
anyone, you or an agent, to read in full. Delete an entry as soon as you know it is false. The
purge, further on, catches the ones that became false without you seeing it.
One fact per entry. An entry that mixes two traps has only one title, which speaks of only one of the two: whoever looks for the other does not find it. Split it into two entries, and have each one point to the other in its last section, the one for related cases, shown in the template further down. The boundary is the cause: several messages produced by the same cause stay in a single entry. A fact about progress, for its part, never becomes an entry: it goes in your task list.
The title and format of an entry
Title each entry by its symptom, never by its cause. Nobody searches for "special character in
the connection string password". In the opening scene, people search for "password authentication
failed", the start of the message that is displayed. The title says what the person who falls into
the trap sees, in the words they see it in: the error message copied as is, or what is displayed.
If the error message itself names the cause, copy it as is anyway. The rule forbids titling by your
diagnosis; it does not forbid repeating what the screen displays. One edit only is allowed, in the
title as in the error trace: replacing what must stay private. Private names, meaning anything that
identifies your machines, your clients or yourself, become neutral names, like host-a for a
machine, example.test for a domain, ~/project/ for a path. A secret becomes <password> or
<token>. If you saw several messages for the same cause, put them all in the title and in the
index line. An agent searching your entries also starts from the message it has in front of it.
The rest of the entry fits in seven sections, in this order:
# <the symptom, as it is displayed>
**Observed on**: YYYY-MM-DD, one date per incident · **Time lost**: <in hours, honestly>
## Symptom
What is seen: the raw error trace, neither cut nor reworded,
private names replaced by neutral names.
## False lead
The cause suspected first, and why it seemed right.
To be filled in BEFORE the actual cause.
## Actual cause
The mechanism, and why it produces this particular symptom.
## Fix
What was done, exactly: the command, or the commit that carries the fix and its repository.
## Verification
A binary command: it answers yes or no. Never "it should work".
## Prevention
The general rule that, applied beforehand, would have avoided the incident.
## Related cases
Where else this trap can hide, and the links to nearby entries.
Action 1: Put the entry template in your repository
Create a memoire/ folder at the root of a repository of your own, one your sessions open often.
Avoid a shared repository: your entries would be read by everyone there, and the instructions file
you are about to change is theirs too. Copy the template above into it, under the name
modele-de-fiche.md. Check that nothing was dropped in the copy, by counting the section titles
from the root of the repository:
grep -c '^## ' memoire/modele-de-fiche.md
Expected result: The grep -c command from the action displays 7: the seven sections of the template are in place.
The "False lead" section is the one people skip, and the most useful: it alone says why the wrong diagnosis was reasonable. Next time, it makes you recognise that you are taking the same wrong road again. It also serves the agent, which may follow the same false lead. According to the failure log page, faced with a refused authentication, an agent goes looking in permissions and the network. That is the author's opinion, not a measurement, and it does not come from the three incidents: none of them gave that rejection. Fill in the "False lead" section before the actual cause, while you still remember what made it believable.
The verification is a binary command: it answers yes or no, through its exit code (success or
failure) or through a fixed word it displays, with nobody having to interpret. For the password,
the command checks that the password goes through the connection string without being altered. It
reads the string the way a Node.js client does, extracts the password from it, and decodes it, as
that client does before sending it. It compares the result with the expected password, read where
the application reads it, in its environment variable for example. It exits with success if they
are equal. So it accepts a new password made of digits and the letters a to f, and also the old
one, if it was encoded when the string was built. A %41 left as is makes it fail, since decoding
changes the password. It lets an unencoded @ through: pg and postgres, two Node.js clients,
read it correctly, but not psql, the PostgreSQL command-line client. The failure log page,
further up, gives it in full.
The index is the file memoire/INDEX.md. It lists the entries, one line each: the symptom, the
path of the entry, and the moment when it should be read.
- 'password authentication failed for user "app"', 'TypeError: Invalid URL' or 'getaddrinfo ENOTFOUND app' on a connection string: memoire/connexion-base-refusee.md, to be read when a connection to a database or a cache fails although its parameters look right.
Each line gives the path of the entry from the root of the repository where memoire/ lives. The
messages in this example come from the failure log page, which reproduced them; in your entries,
copy your own.
Your tool must have every session read the index, at launch. So bring the index into the tool's
instructions file. Some tools can import a file: you write a line that points to it, and the tool
itself loads it, without the agent having to decide. If yours can, import memoire/INDEX.md into
it; your tool's documentation says whether your tool can import, and how. Otherwise, copy the index
into it, and copy it again at every change: INDEX.md remains the reference copy. A plain sentence
asking the agent to read INDEX.md is not enough: then it is the agent that decides, and it may
not do it. Never put the full entries in it: the instructions file is reread in full at every
session, and each entry added lengthens what the agent reads before starting.
The index only points to the entries. The agent may open one if it recognises, in a line, the symptom it has in front of it; nothing guarantees it in advance. The module's exercise checks that this happens on your side.
With a single repository, there is nothing more to do. If you work in several repositories, keep
memoire/ in only one of them. Then write in the index the path of each entry from your home
folder (~/…). That path leads to the entry from any repository, without containing your user
name. Some tools read, on top of the repository's instructions file, an instructions file common to
all your projects, kept in your home folder. If yours does, import or copy the index into it, also
referred to by its ~/… path. Otherwise, import or copy the index into the instructions file of
each repository of your own, never into that of a shared repository. In the texts this module has
you send to agents, then replace memoire/ with that ~/… path.
Action 2: Title your last incident by its symptom
Take the last incident you solved, as recent as possible so that its error trace is still there.
Copy the template under a short name, memoire/<short-name>.md. On its first line, keep the #
and replace the rest with the title of the entry. That title is the error message copied as is from
the terminal or the logs, private names replaced, or what you saw on the screen. Reread it. If it
contains your diagnosis, meaning the cause or a component you only found by searching, replace it
with what you had seen. An error message copied as is stays, even if it names the cause. Then add to
memoire/INDEX.md, or create it, the line for this entry, following the example line above: the
title, the path of the entry, then the moment when it should be read.
Expected result: An entry created from the template, whose title repeats what you saw (the error message or the screen), not your diagnosis; and its line in memoire/INDEX.md, which says when to read it.
Action 3: Have the index read at launch
Connect memoire/INDEX.md to your tool's instructions file, by import or by copy, as above. Then
open a fresh session, meaning one without the history of your earlier sessions. Send it this
message:
Without opening any file or running any command, quote the lines of memoire/INDEX.md
(or of its copy in your instructions) that you received at launch.
Compare its answer with the line of your entry in memoire/INDEX.md. Only a word-for-word quote
proves that the index was read at launch. A paraphrase, a forgotten line or no answer prove
nothing, one way or the other. In that case redo the test in another fresh session; if the quote is
still missing, treat the index as unread to be safe, and change the way you connect it. If what the
session displays shows that it opened a file to answer, its quote proves nothing either. In that
case look, in what your tool displays at the launch of a session, for the list of files it loaded,
if it shows one. The index or the instructions file that contains it must be in it. Finally, if
your tool keeps its own notes folder, check that the quoted line is not in there too: it could come
from there.
Expected result: A fresh session quotes the line of your entry word for word, without having opened any file to answer.
Still in this module:
- What you must never write
- Memory or task list: the six-month test
- The purge
- In practice
That is about 1,708 words, and the exercise with its deliverable template.