<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nnyannya</title>
    <description>The latest articles on DEV Community by nnyannya (@_548fe7f9c7fcd1125fd).</description>
    <link>https://dev.to/_548fe7f9c7fcd1125fd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4034880%2F82af7035-7094-40b9-8e64-07ef37af44ef.jpg</url>
      <title>DEV Community: nnyannya</title>
      <link>https://dev.to/_548fe7f9c7fcd1125fd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_548fe7f9c7fcd1125fd"/>
    <language>en</language>
    <item>
      <title>Claude Code Forgets Everything Between Sessions. I Built a Fix.</title>
      <dc:creator>nnyannya</dc:creator>
      <pubDate>Sat, 18 Jul 2026 07:51:31 +0000</pubDate>
      <link>https://dev.to/_548fe7f9c7fcd1125fd/claude-code-forgets-everything-between-sessions-i-built-a-fix-59n5</link>
      <guid>https://dev.to/_548fe7f9c7fcd1125fd/claude-code-forgets-everything-between-sessions-i-built-a-fix-59n5</guid>
      <description>&lt;h2&gt;
  
  
  Claude Code Starts From Scratch Every Session
&lt;/h2&gt;

&lt;p&gt;If you use Claude Code every day, you've probably found yourself repeating the same explanations over and over again.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why did we choose this architecture?&lt;/li&gt;
&lt;li&gt;Why did we reject that implementation?&lt;/li&gt;
&lt;li&gt;What parts are we planning to improve later?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even when you're working on the same project, Claude Code forgets everything once a session ends.&lt;/p&gt;

&lt;p&gt;The conversation logs are still there—they're stored as JSONL files under ~/.claude/projects/—but Claude doesn't use them in future sessions. In other words, the memory exists, but the agent can't access it.&lt;/p&gt;

&lt;p&gt;Git can tell you what changed, but it can't tell you why. The design decisions, trade-offs, and discussions that happened during development are often lost, even though they're some of the most valuable context for future work.&lt;/p&gt;

&lt;p&gt;To solve this problem, I built an open source tool called memcp.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nnyannya-tech/memcp" rel="noopener noreferrer"&gt;https://github.com/nnyannya-tech/memcp&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is memcp?
&lt;/h2&gt;

&lt;p&gt;In short, &lt;strong&gt;memcp stores Claude Code session logs locally and lets Claude search them through MCP (Model Context Protocol).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a session ends, its log is automatically ingested into a local SQLite database. In future sessions, Claude can call MCP tools such as search_memory to retrieve relevant context from previous conversations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User:
Why did we decide to store refresh tokens in Redis for this authentication service?

Claude:
I don't have access to previous sessions.
Could you explain the reasoning behind that decision again?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User:
Why did we decide to store refresh tokens in Redis for this authentication service?

Claude:
[search_memory("refresh token design")]

Found a session from June 10.

- Easier TTL management than PostgreSQL
- Better suited for high-frequency access
- Automatically removes expired tokens

That's why we chose Redis.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal is simple: let Claude search and remember its own past code, discussions, and design decisions instead of starting from scratch every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The idea is simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Session ends
      │ (automatically)
      ▼
Ingest session log
      │
      ▼
Store it in a local SQLite database
      │
      ▼
Claude searches it when needed in future sessions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All data is stored locally in SQLite and is &lt;strong&gt;never&lt;/strong&gt; sent to external services. There is no cloud synchronization and no telemetry.&lt;/p&gt;

&lt;p&gt;Currently, memcp provides four MCP tools:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;search_memory(query, limit)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Full-text search across all previous sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;read_session(session_id, query, max_messages)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Read a specific session (optionally filtered by a query)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;list_recent_sessions(limit)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List recently ingested sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ingest_session(path)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Manually ingest a JSONL session log&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When users say things like "earlier...", "last week...", or "we discussed this before...", Claude can proactively call &lt;code&gt;search_memory&lt;/code&gt; to retrieve relevant context. You can also invoke these tools explicitly by asking Claude to do so.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Installation takes just a single command if you already have &lt;code&gt;uv&lt;/code&gt; installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/nnyannya-tech/memcp.git
&lt;span class="nb"&gt;cd &lt;/span&gt;memcp
uv tool &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
memcp setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;code&gt;memcp setup&lt;/code&gt; will automatically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create &lt;code&gt;~/.agent-memory/&lt;/code&gt; and initialize the SQLite database.&lt;/li&gt;
&lt;li&gt;Generate a default &lt;code&gt;~/.agent-memory/config.yaml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Register the MCP server in &lt;code&gt;~/.claude.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add a &lt;code&gt;SessionEnd&lt;/code&gt; hook to &lt;code&gt;~/.claude/settings.json&lt;/code&gt; so logs are ingested automatically when a Claude Code session ends.&lt;/li&gt;
&lt;li&gt;Enable automatic ingestion for all future sessions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;During setup, you'll be asked whether you'd like to import your existing session logs. If you choose &lt;strong&gt;Yes&lt;/strong&gt;, memcp will backfill the history from all of your existing Claude Code projects.&lt;/p&gt;

&lt;p&gt;After that, simply restart Claude Code. Your previous sessions will become searchable in future conversations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design Principles
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Local-First, Zero Cloud
&lt;/h3&gt;

&lt;p&gt;Coding session logs often contain project-specific context and, in some cases, sensitive information. Because of that, I decided from the beginning that everything should stay on the local machine.&lt;/p&gt;

&lt;p&gt;All data is stored in SQLite, with no external services, no cloud synchronization, no telemetry, and minimal dependencies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why SQLite FTS5?
&lt;/h3&gt;

&lt;p&gt;I considered using a vector database or an external search engine, but for the MVP I wanted something that would work &lt;strong&gt;without any additional infrastructure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;SQLite FTS5 provides fast and practical full-text search out of the box, with no extra services to run. Semantic search using embeddings is certainly appealing, but I first want to validate whether traditional full-text search is sufficient before introducing additional complexity.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Pluggable Parser Architecture
&lt;/h3&gt;

&lt;p&gt;At the moment, memcp only supports Claude Code session logs. However, I'd like to support other coding agents such as Cursor and Codex CLI in the future.&lt;/p&gt;

&lt;p&gt;To make that possible, parsers are implemented as simple pure functions with the following signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;ParseFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Callable&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ToolCall&lt;/span&gt;&lt;span class="p"&gt;]]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Supporting a new agent is simply a matter of implementing this interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Status
&lt;/h2&gt;

&lt;p&gt;memcp is still an MVP, so here's what it can—and can't—do today.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it can do
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Automatically ingest Claude Code session logs&lt;/li&gt;
&lt;li&gt;Perform full-text search using SQLite FTS5&lt;/li&gt;
&lt;li&gt;Search across sessions and read specific sessions through MCP&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What it can't do (yet)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Support agents other than Claude Code (e.g. Cursor, Codex)&lt;/li&gt;
&lt;li&gt;Semantic search (embedding-based retrieval)&lt;/li&gt;
&lt;li&gt;Automatically extract long-term memories or key decisions from sessions (currently it searches the raw logs)&lt;/li&gt;
&lt;li&gt;Windows support (currently macOS and Linux only)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;memcp status&lt;/code&gt; — View ingestion statistics (session count, last ingestion time, database size)&lt;/li&gt;
&lt;li&gt;Support additional coding agents such as Cursor, Codex, and Cline&lt;/li&gt;
&lt;li&gt;Hybrid search (FTS + embeddings)&lt;/li&gt;
&lt;li&gt;Automatic memory extraction (summarize and store key decisions)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;memcp search &amp;lt;query&amp;gt;&lt;/code&gt; — Search memories directly from the CLI without opening Claude Code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Closing Thoughts
&lt;/h2&gt;

&lt;p&gt;I believe persistent memory across sessions will become a standard capability for AI coding agents.&lt;/p&gt;

&lt;p&gt;memcp is my attempt at a simple, local-first implementation of that idea.&lt;/p&gt;

&lt;p&gt;The project is still in its early days, and I'd love to hear your feedback.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What worked well?&lt;/li&gt;
&lt;li&gt;What felt inconvenient?&lt;/li&gt;
&lt;li&gt;Pull requests for supporting additional coding agents are always welcome.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you find the project interesting, I'd really appreciate a ⭐ on GitHub, as well as any Issues or PRs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nnyannya-tech/memcp" rel="noopener noreferrer"&gt;https://github.com/nnyannya-tech/memcp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>claude</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
