AI Coding Agents With Project Memory: 3 Months and 500 Lessons Later
Back in June I wrote that AI coding agents need project memory, not just bigger prompts . The idea was simple. An agent makes a project-specific mistake, you correct it, and next session it makes the same mistake again, because your correction lived in a chat nobody re-reads. So I built a small graph of lessons: one sentence each, tied to the files and commands where they apply, committed with…
In June, I wrote that AI coding agents need project memory, not just larger prompts. An agent might make a project-specific mistake, and if the correction isn't captured, it will repeat the same error in future sessions. To address this issue, I created a graph of lessons tied to specific files and commands, committing them to the repository and presenting them to the agent at the exact moment it needs them.
After three months, the graph in my own repository has grown to hold 542 lessons, with agents recalling them over 5,000 times.
The follow-up report outlines what the memory has learned, its costs, and why it's worth using. The recall system now presents the most specific rule first, understands tasks based on their wording, speaks once and before the action, and can identify which memories are actually useful. All of these improvements occur at approximately ten tokens per recall. The entire system is open-source, using the MIT license and just one command to set up.
A real lesson from the graph shows how to never split a filesystem path on Windows using basename(). This rule, triggered by a specific pattern in certain TypeScript files, is only recalled when needed. The lesson format consists of one imperative sentence, a topic, and a trigger tied to a file glob, command pattern, or keyword. When an agent is about to edit a file matching the trigger, the rule appears in its context, just before the edit.
Capturing lessons is a simple one-line process, and they can be recalled using a PreToolUse hook in Claude Code or at task start in other tools. The most specific rule is given priority in recall, and rules are ranked based on how well they match the specific parts of a file or its context. Keyword triggers have been improved to match whole words, reducing false positives. When an agent suggests a command that has been learned from a lesson, the command trigger is anchored to the command to avoid false alarms.
Previously, conceptual lessons were only surfaced if keywords from the lesson appeared in the user's prompt. This has been addressed by scoring prompts against active rules using the BM25 index, allowing rules to surface even when the specific keywords aren't present. However, there are still some grammatical improvements needed to ensure rules are only triggered when appropriate.
The recall process remains relatively fast, taking about 0.2 seconds. There are two main cost-saving measures implemented: once a rule has been shown, it stays quiet for the rest of the session, and recall now only runs before tool calls, reducing unnecessary spawns and prompts. Averaged over all recalls, the memory adds about ten tokens per tool call, making it significantly cheaper than preloading the entire graph into a prompt.
Additionally, the memory can now inform you which lessons are actually earning their place, providing more value and efficiency.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.