Claude Code Memory
Persistent Long-Term Memory Plugin.
TL;DR
Give Claude Code persistent memory across every session. The Memwyre plugin auto-injects past project context when you start a session and auto-captures decisions when you exit — no manual CLAUDE.md management needed.
The Problem: Claude Code Forgets Everything
Every time you close a Claude Code session, the context window resets. Your debugging breakthroughs, architecture decisions, database schema notes, and style conventions — all gone. You spend the first 5 minutes of every session re-explaining your project.
Anthropic provides CLAUDE.md and auto-memory as built-in solutions, but they require manual maintenance, are limited to flat Markdown files, and don't share context across tools. If you use Claude Code and Claude Desktop and Cursor, each tool maintains its own isolated silo.
Four Approaches to Claude Code Memory
There is no single "right" approach — each method suits a different workflow. If you've researched this space, you've likely seen claude-mem (89K+ GitHub stars) alongside Anthropic's built-in options. Here is an honest breakdown of all four.
| Feature | CLAUDE.md / Auto-Memory | claude-mem (OSS) | MCP Memory Server | Memwyre Plugin |
|---|---|---|---|---|
| Automation | Manual edits | Predictive (LLM decides when to save) | Predictive (LLM decides when to use tool) | Deterministic (Always runs on SessionStart/Stop) |
| Storage | Flat Markdown file | Local SQLite + ChromaDB | Varies (cloud or local) | Cloud vault + entity graph |
| Setup | Manual file creation | npx claude-mem install | JSON config + API key | claude plugin install |
| Cross-Session | ✅ Loads on startup | ✅ Local DB persistence | ✅ Via tool calls | ✅ Auto-injected on startup |
| Cross-Tool | ❌ Claude Code only | ⚠️ SSH sync (claude-mem-sync) | ✅ Any MCP client | ✅ Shared vault (Cursor, VS Code, Claude Desktop) |
| License | N/A (built-in) | AGPL-3.0 | Varies | Apache-2.0 |
| Best For | Static project rules | Local-first power users | Real-time tool access | Hands-free cross-tool memory |
These approaches are complementary, not exclusive. Use CLAUDE.md for static project rules and Memwyre for dynamic session memory — they work together.
Memwyre vs. claude-mem: The Key Differences
claude-mem is an excellent open-source tool for local-first, single-machine memory. It stores observations in a local SQLite database with ChromaDB for semantic search, and it's earned 89K+ GitHub stars for good reason — it works.
Where the two tools diverge:
- Cross-tool sync: claude-mem stores data locally. To share context between machines, you need to set up SSH-based sync via
claude-mem-sync. Memwyre uses a shared cloud vault — install the plugin on Claude Code, connect the MCP server on Cursor, and both read from the same memory layer instantly. No SSH keys, no SCP scripts, no manual replication. - Retrieval quality: claude-mem uses flat vector search (ChromaDB). Memwyre's engine uses two-stage cross-encoder re-ranking with Ebbinghaus logarithmic recency decay, scoring 73.5% on the LoCoMo-10 benchmark vs. 43.7% for flat vector RAG baselines — a 68% accuracy improvement with 88.5% fewer tokens.
- License: claude-mem ships under AGPL-3.0, which requires teams to open-source modifications if they serve the software over a network. Memwyre ships under Apache-2.0 — no copyleft obligations, safe for proprietary enterprise deployments. (See our detailed comparison pages for deeper dives vs. Mem0, Supermemory, and Zep.)
How Cross-Tool Sync Actually Works
"Shared with Cursor, VS Code, Claude Desktop" is a claim that deserves explanation. Here's the mechanism:
- Claude Code (plugin): The Memwyre plugin hooks into
SessionStartandStoplifecycle events. On start, it calls the retrieval API to pull relevant memories. On stop, itPOSTs the session transcript to the capture endpoint. Both operations hit your authenticated cloud vault. - Cursor / VS Code / Claude Desktop (MCP): These tools connect via the Memwyre MCP server. The
search_memwyreandsave_memorytools read from and write to the same vault as the Claude Code plugin. - Same API key = same vault. There's no sync step, no export/import, no SSH tunnel. A memory captured in a Claude Code terminal session at 2pm is available in your Cursor sidebar at 2:01pm.
How the Memwyre Claude Code Plugin Works
The plugin hooks into Claude Code's lifecycle events — two hooks, zero configuration after install. It reads your project directory name and handles everything automatically.
① SessionStart — Context Injection
When you open a Claude Code session, the plugin fires before the first prompt. It reads your working directory, queries the Memwyre retrieval engine for past memories matching that project, and injects them directly into Claude's system prompt.
<memwyre-context>
## Past Memories for my-project
- Database uses PostgreSQL 15 with pgvector
- Auth flow: JWT + refresh tokens in httpOnly cookies
- Fixed: race condition in worker queue (use Redis lock)
</memwyre-context>② Stop — Session Capture
When you exit Claude Code (or the session ends), the plugin reads the full JSONL session transcript, sends it to Memwyre's background worker, and extracts structured memories — architecture decisions, debugging solutions, code patterns, and configuration choices.
Troubleshooting & Edge Cases
No extraction model is perfect. Here's how to handle the edge cases:
- Misclassified memory: If the extraction model captures something irrelevant or incorrect, you can view, edit, or delete any individual memory from the Memwyre dashboard or via the API (
DELETE /api/v1/memories/:id). Every memory is individually addressable. - Stale facts: Decided to switch from PostgreSQL to CockroachDB? The Ebbinghaus logarithmic recency decay model automatically deprioritizes older, superseded facts. The most recent observation wins in retrieval ranking — you don't need to manually clean up outdated context.
- Deduplication: If consecutive sessions produce near-identical observations (e.g., "project uses Tailwind" captured in sessions #4, #5, and #6), the extraction model deduplicates them during ingestion. Your vault stays lean.
- Project exclusion: Don't want to capture sessions for a specific repo? Unset the
MEMWYRE_API_KEYenvironment variable for that terminal session, or configure project-level exclusions in your Memwyre dashboard settings.
Install in 60 Seconds
Choose between standard CLI plugin installation or manual hooks configuration:
Option A: Direct Plugin Install (Recommended)
- 1. Install the plugin package:
claude plugin install @memwyre/claude-code-plugin - 2. Export your API key:
export MEMWYRE_API_KEY="bv_sk_your_api_key_here"Add to your
~/.zshrc,~/.bashrc, or system environment variables.
Option B: Manual Hooks Configuration (Custom Setup)
If configuring hooks manually in ~/.claude/hooks.json:
{
"description": "Memwyre: Persistent autonomous memory",
"hooks": {
"SessionStart": [{ "hooks": [{ "type": "command", "command": "node \"/path/to/node_modules/@memwyre/claude-memwyre/dist/inject-memory.cjs\"", "timeout": 30 }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "node \"/path/to/node_modules/@memwyre/claude-memwyre/dist/capture-session.cjs\"", "timeout": 30 }] }]
}
}What Claude Remembers With Memwyre
- 🧠 Architecture Decisions: Database choices, API patterns, deployment configs, and framework decisions from past sessions.
- 🐛 Debugging Solutions: Race conditions fixed, environment variable gotchas, and edge cases you already solved once.
- 🔗 Entity Relationships: Connections between database tables, files, services, and APIs — enabling multi-hop reasoning.
- ✂️ Dynamic Pruning: Filters out duplicate CLI logs, compiler errors, and noise — keeping memory lean and token costs low.
Benchmark: Why Retrieval Quality Matters
Generic memory plugins dump raw vectors into Claude's context window. That approach fails on the queries that actually matter in a codebase — temporal reasoning ("when did we switch from REST to GraphQL?"), multi-hop connections ("which services depend on the auth token format we changed last week?"), and adversarial edge cases ("we never discussed Redis" → the system should abstain, not hallucinate).
We evaluated Memwyre's retrieval engine against a flat vector RAG baseline on the LoCoMo-10 benchmark (Snap Research, 2024) — 1,540 questions across 10 long conversations spanning 200,000+ tokens:
| Category | Flat Vector RAG | Memwyre Engine | Improvement |
|---|---|---|---|
| Single-Hop Recall | 53.0% | 80.0% | +51% |
| Multi-Hop Reasoning | 24.0% | 45.0% | +87.5% |
| Temporal Alignment | 48.0% | 74.0% | +54% |
| Open-Domain Reasoning | 50.0% | 76.0% | +52% |
| Overall Accuracy | 43.7% | 73.5% | +68% |
| Context Tokens Sent | ~26,000 | ~3,000 | −88.5% |
The improvement comes from three architectural choices: dynamic context pruning during ingestion (strips conversational filler), two-stage cross-encoder re-ranking (high-recall vector fetch → precision cross-encoder scoring), and Ebbinghaus logarithmic recency decay (automatically deprioritizes stale observations).
View the full LoCoMo-10 benchmark results →
Real-World Workflow: Large Codebase Refactoring
To understand the depth of this integration, consider a common scenario: migrating a large React SPA to Next.js App Router.
In a standard Claude Code setup, you might tackle routing on Monday, API endpoints on Tuesday, and state management on Wednesday. By Wednesday, Claude has forgotten that you decided to use Server Actions for mutations instead of traditional API routes. It will start generating standard REST calls, requiring you to manually correct it and burn through tokens.
With the Memwyre Plugin, Monday's architectural decision ("we are exclusively using Server Actions for Next.js mutations") is extracted during the session stop hook. When you open Claude on Wednesday, that context is automatically injected. Claude inherently knows the project's boundaries, saving you countless prompt-correction cycles and significantly reducing your token usage by preventing hallucinated code paths.
Token Costs, Noise, & Security
Sending large conversational contexts directly impacts both billing and privacy. The plugin employs several strategies to mitigate this:
Algorithmic Noise Filtration
Not every CLI error needs to be remembered. Memwyre's backend uses a specialized extraction model that differentiates between ephemeral noise (e.g., a typo in a git commit command) and structural knowledge (e.g., adding a new enum to a Prisma schema). Only the structural knowledge is saved to your vector vault, keeping your persistent memory highly relevant and dense.
Predictable Token Usage
By summarizing and deduplicating past sessions, the plugin injects a concise <memwyre-context> block that rarely exceeds 1,500 tokens. Compared to manually pasting in megabytes of old transcript logs, this targeted injection saves Anthropic API costs while providing superior context.
Zero-Retention & Self-Hosting
Your code is yours. The Memwyre extraction engine uses zero-retention policies—meaning your transcripts are processed in memory and immediately discarded. For enterprise environments with strict compliance requirements, the entire Memwyre backend can be self-hosted behind your firewall, ensuring your proprietary source code never leaves your VPC.
License & Requirements
- License: Apache-2.0 — no copyleft obligations. You can use, modify, and deploy Memwyre in proprietary environments without open-sourcing your changes. This matters for teams: claude-mem's AGPL-3.0 license requires that any modifications served over a network be made open-source, which creates real compliance friction in enterprise environments.
- System requirements: Node.js 18+ (for the plugin runtime). Works on macOS, Linux, and Windows. No local database required — unlike claude-mem (SQLite + ChromaDB dependency), Memwyre stores data in a managed cloud vault.
- Self-hosting: For teams that need full data sovereignty, the entire Memwyre backend is available for self-hosted Docker deployment. See the GitHub repo for instructions.
Why Not Just Use CLAUDE.md?
CLAUDE.md is genuinely useful — and you should keep using it. It's the right place for static project rules like "use TypeScript strict mode" or "prefer Tailwind over inline styles."
But it has real limitations:
- Manual maintenance — you have to remember to update it.
- Flat storage — everything goes into one Markdown file. No semantic search or entity relationships.
- Tool-locked — CLAUDE.md only works in Claude Code. Your Cursor and Claude Desktop sessions can't access it.
FAQ
Does Claude Code have built-in memory?
~/.claude/projects/.../memory/. Both are useful for static rules but limited for dynamic, searchable, cross-tool memory.How do I give Claude Code persistent memory across sessions?
claude plugin install @memwyre/claude-code-plugin. Set your MEMWYRE_API_KEY environment variable, and every session will automatically load relevant past context on start and save new insights on exit.What is the best Claude Code memory plugin?
How is Memwyre different from claude-mem?
Does the plugin work with Claude Desktop too?
What license is Memwyre released under?
What happens if Memwyre captures something wrong?
DELETE /api/v1/memories/:id). The Ebbinghaus decay model also automatically deprioritizes stale facts over time, so outdated context naturally fades from retrieval results.Is my memory data private?
Give Claude Code Persistent Memory
One plugin install. Automatic context injection. Automatic session capture. Memory that works across Claude Code, Claude Desktop, Cursor, and VS Code.
Start Free