August 21, 2026

How to Give Claude Long-Term Memory Without Losing Control

Give Claude long-term memory with CLAUDE.md, native auto memory, and a working MCP setup for readable, testable, self-hosted knowledge.

Claude starts each session with a fresh context window. That is useful isolation, but it also means the model can forget the architecture decision, debugging lesson, or personal preference you explained yesterday. The reliable answer is not to paste every old transcript into every prompt. Give Claude a small, deliberate memory system with clear scope, an explicit write policy, and a test that proves the next session can retrieve the right fact.

There are three useful layers. CLAUDE.md holds instructions that should shape behavior. Claude Code auto memory records useful repository-specific learnings. A shared MCP memory server holds knowledge that should be readable and editable outside one repository or one client. Meshnote takes that third path: your agent's memory is a markdown wiki you can inspect, edit, back up, and self-host rather than an opaque vector index.

What the current guides cover

The official Claude Code memory documentation explains the two native mechanisms: authored instruction files and auto memory. It is the right reference for scope and file locations, but it does not turn memory into a shared, cross-tool knowledge base. Product Talk's guide focuses on using local files as Claude's memory, with practical advice for project notes and prompts. XTrace explains Claude's account-level memory setting and the kinds of personal context it can retain. Together, the top results explain native memory well; they do not give you a portable write contract plus a repeatable cross-session acceptance test.

This article adds that missing operational layer. The goal is not to replace native Claude memory. It is to decide what belongs in each layer, connect Claude Code to a readable MCP wiki, and verify that a correction survives a new session without leaking between projects.

Choose the right memory layer

LayerUse it forStrengthBoundary
CLAUDE.mdCommands, conventions, safety rulesLoaded as instructions and easy to reviewUsually repository or user scoped
Claude auto memoryRecurring discoveries in one repositoryLow-friction accumulation inside Claude CodeClaude-specific and not a team wiki
Meshnote over MCPDecisions, domain facts, runbooks, handoffsReadable markdown, agent-agnostic access, self-hostingRequires deliberate retrieval and write discipline
Mem0 or ZepProgrammatic semantic retrieval at application scaleAPIs and automatic extraction can reduce integration workMemory is commonly mediated by a service and retrieval layer
LettaStateful agents with managed memory blocksMemory is part of the agent runtime itselfLess useful when several unrelated clients must share plain files

Native memory in Claude is convenient for a single user and repository. Mem0 and Zep are sensible choices when your application needs an API-first memory pipeline, embeddings, or structured retrieval. Letta is a strong fit when you want the agent runtime and its stateful memory designed together. A file-backed wiki is a better fit when humans need to audit a decision, correct it with a normal editor, diff changes in Git, or let multiple MCP-compatible tools use the same source. Those trade-offs are real; readable memory is not automatically better for every workload.

Working setup: connect Claude Code to Meshnote

Create a Meshnote project first, then create an API key in the hosted dashboard. Keep the key secret; it grants access to the projects available to that account. Claude Code accepts an HTTP MCP server in its settings. Add this to ~/.claude/settings.json and replace the placeholder:

{
  "mcpServers": {
    "meshnote": {
      "type": "http",
      "url": "https://meshnote.io/mcp",
      "headers": {
        "Authorization": "Bearer mnk_REPLACE_WITH_YOUR_API_KEY"
      }
    }
  }
}

Restart Claude Code, then ask it to list Meshnote projects. Select the project you want and ask for its schema or index before writing anything. A good first request is: “Read the project schema and index. Do not write. Tell me which page should hold deployment decisions.” This confirms authentication and scope without creating unreviewed content. For a self-hosted instance, keep the same configuration shape and change the URL to your server's /mcp endpoint.

Use a memory contract, not “remember everything”

Long-term memory becomes noisy when every conversational detail is promoted. Put a short contract in CLAUDE.md or the wiki schema:

  1. Write only durable facts: decisions, constraints, stable preferences, and verified fixes.
  2. Include provenance: repository, date, source issue or document, and confidence.
  3. Separate facts from hypotheses. Never turn an unverified guess into a team rule.
  4. Use project scope for project facts and a personal scope for personal preferences.
  5. When a fact changes, edit or supersede the old page; do not leave two conflicting “truths.”
  6. Retrieve narrowly before acting: search the relevant topic, read the page, then cite the decision in the work.

This is the practical difference between persistence and memory hoarding. The agent has somewhere to put knowledge, but the contract controls what deserves to survive.

The five-minute acceptance test

Run this after setup, and repeat it after changing servers or clients:

  1. Session A: write one harmless, project-specific fact with a date and source, such as a confirmed test command.
  2. Session B: search for that fact by concept, not by copying the original sentence. Confirm the result identifies the right project.
  3. Correction: update the fact to a deliberately different, verified value. Search again and confirm the old value is marked obsolete or gone.
  4. Isolation: ask from a second project for the first project's fact. The result should be empty or explicitly inaccessible.
  5. Recovery: export or inspect the markdown page, edit it with a normal text editor, and retrieve the correction from Claude.

A passing test demonstrates more than “the model remembered.” It checks write permission, retrieval, correction semantics, tenant or project boundaries, and human portability. If the test fails, do not compensate by stuffing more context into prompts; fix scope, indexing, or the memory contract.

Bottom line

To give Claude long-term memory, start with CLAUDE.md for instructions and native auto memory for repository-local learnings. Add MCP memory when knowledge must survive the repository, the client, or the model session. Meshnote is designed for that boundary: a markdown wiki that Claude and other agents can maintain while people retain the files and the final edit.

Start with one project, five durable facts, and the acceptance test above. Start syncing — $8/mo, or choose self-hosted for teams from $10/seat/month when your organization needs its own deployment and storage.

Related Reading

Your agent's memory should be files you can read and own

Meshnote is readable, self-hosted memory for AI agents — markdown wikis your agents maintain over MCP. Hosted from $8/month.

Start syncing — $8/mo

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.