{"slug": "claude-code-forgets-everything-between-sessions-i-built-a-fix", "title": "Claude Code Forgets Everything Between Sessions. I Built a Fix.", "summary": "A developer built an open-source tool called memcp that gives Claude Code persistent memory across sessions by storing conversation logs in a local SQLite database and making them searchable via the Model Context Protocol (MCP). The tool automatically ingests session logs and provides MCP tools for full-text search, reading past sessions, and listing recent sessions, with all data stored locally and no external services.", "body_md": "If you use Claude Code every day, you've probably found yourself repeating the same explanations over and over again.\n\nEven when you're working on the same project, Claude Code forgets everything once a session ends.\n\nThe 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.\n\nGit 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.\n\nTo solve this problem, I built an open source tool called memcp.\n\n[https://github.com/nnyannya-tech/memcp](https://github.com/nnyannya-tech/memcp)\n\nIn short, **memcp stores Claude Code session logs locally and lets Claude search them through MCP (Model Context Protocol).**\n\nWhen 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.\n\n**Before**\n\n```\nUser:\nWhy did we decide to store refresh tokens in Redis for this authentication service?\n\nClaude:\nI don't have access to previous sessions.\nCould you explain the reasoning behind that decision again?\n```\n\n**After**\n\n```\nUser:\nWhy did we decide to store refresh tokens in Redis for this authentication service?\n\nClaude:\n[search_memory(\"refresh token design\")]\n\nFound a session from June 10.\n\n- Easier TTL management than PostgreSQL\n- Better suited for high-frequency access\n- Automatically removes expired tokens\n\nThat's why we chose Redis.\n```\n\nThe goal is simple: let Claude search and remember its own past code, discussions, and design decisions instead of starting from scratch every time.\n\nThe idea is simple.\n\n```\nSession ends\n      │ (automatically)\n      ▼\nIngest session log\n      │\n      ▼\nStore it in a local SQLite database\n      │\n      ▼\nClaude searches it when needed in future sessions\n```\n\nAll data is stored locally in SQLite and is **never** sent to external services. There is no cloud synchronization and no telemetry.\n\nCurrently, memcp provides four MCP tools:\n\n| Tool | Description |\n|---|---|\n`search_memory(query, limit)` |\nFull-text search across all previous sessions |\n`read_session(session_id, query, max_messages)` |\nRead a specific session (optionally filtered by a query) |\n`list_recent_sessions(limit)` |\nList recently ingested sessions |\n`ingest_session(path)` |\nManually ingest a JSONL session log |\n\nWhen users say things like \"earlier...\", \"last week...\", or \"we discussed this before...\", Claude can proactively call `search_memory`\n\nto retrieve relevant context. You can also invoke these tools explicitly by asking Claude to do so.\n\nInstallation takes just a single command if you already have `uv`\n\ninstalled.\n\n```\ngit clone https://github.com/nnyannya-tech/memcp.git\ncd memcp\nuv tool install .\nmemcp setup\n```\n\nRunning `memcp setup`\n\nwill automatically:\n\n`~/.agent-memory/`\n\nand initialize the SQLite database.`~/.agent-memory/config.yaml`\n\n.`~/.claude.json`\n\n.`SessionEnd`\n\nhook to `~/.claude/settings.json`\n\nso logs are ingested automatically when a Claude Code session ends.During setup, you'll be asked whether you'd like to import your existing session logs. If you choose **Yes**, memcp will backfill the history from all of your existing Claude Code projects.\n\nAfter that, simply restart Claude Code. Your previous sessions will become searchable in future conversations.\n\nCoding 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.\n\nAll data is stored in SQLite, with no external services, no cloud synchronization, no telemetry, and minimal dependencies.\n\nI considered using a vector database or an external search engine, but for the MVP I wanted something that would work **without any additional infrastructure**.\n\nSQLite 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.\n\nAt 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.\n\nTo make that possible, parsers are implemented as simple pure functions with the following signature:\n\n```\nParseFn = Callable[[Path], tuple[Session, list[Message], list[ToolCall]]]\n```\n\nSupporting a new agent is simply a matter of implementing this interface.\n\nmemcp is still an MVP, so here's what it can—and can't—do today.\n\n`memcp status`\n\n— View ingestion statistics (session count, last ingestion time, database size)`memcp search <query>`\n\n— Search memories directly from the CLI without opening Claude CodeI believe persistent memory across sessions will become a standard capability for AI coding agents.\n\nmemcp is my attempt at a simple, local-first implementation of that idea.\n\nThe project is still in its early days, and I'd love to hear your feedback.\n\nIf you find the project interesting, I'd really appreciate a ⭐ on GitHub, as well as any Issues or PRs.", "url": "https://wpnews.pro/news/claude-code-forgets-everything-between-sessions-i-built-a-fix", "canonical_source": "https://dev.to/_548fe7f9c7fcd1125fd/claude-code-forgets-everything-between-sessions-i-built-a-fix-59n5", "published_at": "2026-07-18 07:51:31+00:00", "updated_at": "2026-07-18 07:57:57.867108+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-agents"], "entities": ["Claude Code", "memcp", "MCP", "SQLite", "nnyannya-tech"], "alternates": {"html": "https://wpnews.pro/news/claude-code-forgets-everything-between-sessions-i-built-a-fix", "markdown": "https://wpnews.pro/news/claude-code-forgets-everything-between-sessions-i-built-a-fix.md", "text": "https://wpnews.pro/news/claude-code-forgets-everything-between-sessions-i-built-a-fix.txt", "jsonld": "https://wpnews.pro/news/claude-code-forgets-everything-between-sessions-i-built-a-fix.jsonld"}}