<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Long-Term Memory on KnightLi Blog</title>
        <link>https://www.knightli.com/en/tags/long-term-memory/</link>
        <description>Recent content in Long-Term Memory on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Fri, 01 May 2026 03:01:02 +0800</lastBuildDate><atom:link href="https://www.knightli.com/en/tags/long-term-memory/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Claude-Mem: Adding Cross-Session Long-Term Memory to Claude Code</title>
        <link>https://www.knightli.com/en/2026/05/01/claude-mem-persistent-memory-for-claude-code/</link>
        <pubDate>Fri, 01 May 2026 03:01:02 +0800</pubDate>
        
        <guid>https://www.knightli.com/en/2026/05/01/claude-mem-persistent-memory-for-claude-code/</guid>
        <description>&lt;p&gt;&lt;code&gt;Claude-Mem&lt;/code&gt; is a persistent memory system for &lt;code&gt;Claude Code&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It tries to solve a very specific problem: every time an AI coding assistant starts a new session, it often forgets earlier architecture decisions, past pitfalls, project preferences, and implementation context.&lt;br&gt;
If a project lasts for a long time, repeatedly explaining the same background becomes a waste of time.&lt;/p&gt;
&lt;p&gt;The idea behind &lt;code&gt;Claude-Mem&lt;/code&gt; is to compress Claude Code conversations into memories, store them in a local database and vector store, and then retrieve them later through a search tool.&lt;/p&gt;
&lt;h2 id=&#34;what-problem-does-it-solve&#34;&gt;What Problem Does It Solve?
&lt;/h2&gt;&lt;p&gt;Claude Code is good at code tasks, but session context is still limited.&lt;/p&gt;
&lt;p&gt;Common pain points include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A new session does not know what previous sessions did&lt;/li&gt;
&lt;li&gt;Project design decisions need to be explained repeatedly&lt;/li&gt;
&lt;li&gt;Problems that were already debugged are easy to repeat&lt;/li&gt;
&lt;li&gt;Long-running tasks lack continuity&lt;/li&gt;
&lt;li&gt;Project knowledge is hard to accumulate across conversations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;Claude-Mem&lt;/code&gt; is designed around these problems.&lt;/p&gt;
&lt;p&gt;It is not simply saving chat logs. Instead, it compresses conversations into memory fragments that are easier to retrieve. When needed later, semantic search can bring the relevant context back.&lt;/p&gt;
&lt;h2 id=&#34;how-it-works&#34;&gt;How It Works
&lt;/h2&gt;&lt;p&gt;From the README design, &lt;code&gt;Claude-Mem&lt;/code&gt; mainly consists of several parts.&lt;/p&gt;
&lt;p&gt;The first part is hooks.&lt;/p&gt;
&lt;p&gt;It integrates with the Claude Code session flow and captures conversation data at the right time.&lt;/p&gt;
&lt;p&gt;The second part is a background worker.&lt;/p&gt;
&lt;p&gt;The worker processes raw conversation content into shorter, more searchable memories.&lt;/p&gt;
&lt;p&gt;The third part is local storage.&lt;/p&gt;
&lt;p&gt;The project uses &lt;code&gt;SQLite&lt;/code&gt; for structured metadata and &lt;code&gt;Chroma&lt;/code&gt; for vector indexing. This preserves basic session information while supporting semantic retrieval.&lt;/p&gt;
&lt;p&gt;The fourth part is &lt;code&gt;mem-search&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is the query entry point for Claude Code. When old context is needed, it can search relevant memories through this tool.&lt;/p&gt;
&lt;p&gt;The overall flow can be understood like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Claude Code sessions generate content&lt;/li&gt;
&lt;li&gt;Hooks capture session data&lt;/li&gt;
&lt;li&gt;The worker asynchronously compresses and organizes it&lt;/li&gt;
&lt;li&gt;Memories are written to SQLite and Chroma&lt;/li&gt;
&lt;li&gt;Later sessions retrieve them through &lt;code&gt;mem-search&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;when-is-it-useful&#34;&gt;When Is It Useful?
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;Claude-Mem&lt;/code&gt; is suitable for long-running projects, not one-off small tasks.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A repository is developed over many days&lt;/li&gt;
&lt;li&gt;The code structure is complex and has a lot of background&lt;/li&gt;
&lt;li&gt;Project conventions, naming habits, and architecture choices need to be remembered&lt;/li&gt;
&lt;li&gt;Claude Code is often used for bug fixes, features, and documentation&lt;/li&gt;
&lt;li&gt;You want the AI to remember why something was changed earlier&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you only ask Claude Code to make a one-line change, long-term memory is not very meaningful.&lt;br&gt;
But if you treat Claude Code as a long-term collaborator, it becomes useful.&lt;/p&gt;
&lt;h2 id=&#34;installation-and-startup&#34;&gt;Installation and Startup
&lt;/h2&gt;&lt;p&gt;The README gives a direct installation flow:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;npm install -g claude-mem
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;claude-mem install
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Start it with:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;claude-mem start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Check status:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;claude-mem status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Stop it when needed:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;claude-mem stop
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The goal behind these commands is to connect the memory system as a long-running local service to the Claude Code workflow.&lt;/p&gt;
&lt;h2 id=&#34;how-to-use-mem-search&#34;&gt;How to Use &lt;code&gt;mem-search&lt;/code&gt;
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;mem-search&lt;/code&gt; is the key entry point for retrieving memory.&lt;/p&gt;
&lt;p&gt;It is not meant to replace ordinary search. It lets Claude Code query past conversations by meaning.&lt;/p&gt;
&lt;p&gt;For example, Claude Code can search for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why a module was designed in a certain way&lt;/li&gt;
&lt;li&gt;How a bug was debugged earlier&lt;/li&gt;
&lt;li&gt;Naming rules agreed on in the project&lt;/li&gt;
&lt;li&gt;Technical trade-offs discussed before&lt;/li&gt;
&lt;li&gt;The background behind a refactor&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is different from simple keyword search.&lt;br&gt;
If memory compression and vector indexing work well, you can retrieve semantically related content even if you do not remember the exact wording.&lt;/p&gt;
&lt;h2 id=&#34;how-is-it-different-from-project-documentation&#34;&gt;How Is It Different from Project Documentation?
&lt;/h2&gt;&lt;p&gt;Project documentation is good for stable conclusions.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Architecture notes&lt;/li&gt;
&lt;li&gt;Deployment procedures&lt;/li&gt;
&lt;li&gt;API conventions&lt;/li&gt;
&lt;li&gt;Database structure&lt;/li&gt;
&lt;li&gt;Development rules&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;Claude-Mem&lt;/code&gt; is better for context created during conversations.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Why a plan was rejected&lt;/li&gt;
&lt;li&gt;How a temporary issue was worked around&lt;/li&gt;
&lt;li&gt;The discussion behind an implementation&lt;/li&gt;
&lt;li&gt;Project preferences not yet written into docs&lt;/li&gt;
&lt;li&gt;Task background accumulated across multiple conversations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The two are not replacements for each other.&lt;br&gt;
A good workflow is to write stable knowledge into project docs and use the memory system to help retrieve conversational context.&lt;/p&gt;
&lt;h2 id=&#34;things-to-watch-out-for&#34;&gt;Things to Watch Out For
&lt;/h2&gt;&lt;p&gt;First, more long-term memory is not always better.&lt;/p&gt;
&lt;p&gt;If every conversation is saved without distinction, later retrieval can become noisy. The most valuable memories are project decisions, implementation background, debugging history, and long-term preferences.&lt;/p&gt;
&lt;p&gt;Second, memory cannot replace code and documentation.&lt;/p&gt;
&lt;p&gt;Old context found by AI is only a reference. Final judgment still depends on the current code, test results, and latest requirements.&lt;/p&gt;
&lt;p&gt;Third, pay attention to privacy and local data.&lt;/p&gt;
&lt;p&gt;Since it stores conversation content, you should know which projects are suitable for it and which sensitive information should not enter the conversation.&lt;/p&gt;
&lt;p&gt;Fourth, memory systems need maintenance.&lt;/p&gt;
&lt;p&gt;As a project moves forward, old memories may become outdated. If outdated context is reused incorrectly, it can mislead later tasks.&lt;/p&gt;
&lt;h2 id=&#34;why-this-kind-of-tool-matters&#34;&gt;Why This Kind of Tool Matters
&lt;/h2&gt;&lt;p&gt;AI coding tools are moving from one-off Q&amp;amp;A toward long-term collaboration.&lt;/p&gt;
&lt;p&gt;In one-off Q&amp;amp;A, the model only needs to answer the current question.&lt;br&gt;
In long-term collaboration, it needs to know project history, earlier decisions, team preferences, and pitfalls that have already been found.&lt;/p&gt;
&lt;p&gt;This is where tools like &lt;code&gt;Claude-Mem&lt;/code&gt; matter: they turn &amp;ldquo;remembering context&amp;rdquo; from a temporary chat capability into a local system that can be installed, run, and searched.&lt;/p&gt;
&lt;p&gt;For real engineering projects, this is more practical than simply making the model context window longer.&lt;br&gt;
Much information does not need to be stuffed into context all at once; it needs to be retrieved at the right time.&lt;/p&gt;
&lt;h2 id=&#34;who-should-try-it&#34;&gt;Who Should Try It?
&lt;/h2&gt;&lt;p&gt;You may want to try it if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You use Claude Code frequently&lt;/li&gt;
&lt;li&gt;You often work on the same project across multiple days&lt;/li&gt;
&lt;li&gt;The project context is complex&lt;/li&gt;
&lt;li&gt;You repeatedly explain the same background to AI&lt;/li&gt;
&lt;li&gt;You want to preserve experience from conversations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you only use Claude Code occasionally, or the project is small, you may not need this kind of system yet.&lt;/p&gt;
&lt;h2 id=&#34;reference&#34;&gt;Reference
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/thedotmack/claude-mem&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;thedotmack/claude-mem&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;final-thought&#34;&gt;Final Thought
&lt;/h2&gt;&lt;p&gt;The point of &lt;code&gt;Claude-Mem&lt;/code&gt; is not &amp;ldquo;saving chat logs.&amp;rdquo; It is helping Claude Code retrieve useful context in later tasks.&lt;/p&gt;
&lt;p&gt;As AI coding moves from one-off tasks to long-running project collaboration, memory systems will become increasingly important.&lt;br&gt;
They cannot replace documentation and tests, but they can reduce repeated explanations and make the AI feel more like an assistant that understands project history.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
