Developer adds RAG to Claude Code so the AI recalls its own saved corrections

A developer found that their Claude Code agent kept repeating mistakes despite a 32KB index of saved notes, because the agent did not consult the notes at the right moment. To fix this, they added retrieval-augmented generation that searches their stored memory notes and past conversation titles by meaning on every message sent. The closest matches are passed to the AI before it responds, with the amount handed over depending on how strong the top match is and capped at 2,048 bytes. The system runs through a Claude Code hook and uses the bge-m3 embedding model with a local index. The author argues the approach can work for any agent that stores notes, though the current implementation is limited to Claude Code.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in