How to give Claude Code memory that lasts between sessions
Last updated
Every Claude Code session starts with an empty context window, so anything you explained yesterday is gone unless it was written down. To give Claude Code a memory it can search, add the Memlo MCP server with claude mcp add --transport http --scope user memlo https://memlo.ai/mcp, sign in once with /mcp, and start a new session. Claude Code can then save decisions as memories and find them again in any later session, in any project.
What Claude Code remembers on its own
Claude Code carries two things from one session to the next, and both are files on your computer:
- CLAUDE.md files. Instructions you write. Claude Code reads them at the start of every session. Its documentation suggests keeping each one under 200 lines, because longer files use more context and are followed less closely.
- Auto memory. Notes Claude Code writes for itself in
~/.claude/projects/<project>/memory/. It loads the first 200 lines or 25KB of the index file,MEMORY.md, at the start of each session. Auto memory is machine-local: it is not shared with other computers or with other agents.
Both work well for a short set of rules. They get harder to use when the notes grow, when you work on more than one computer, or when you also use Codex or another agent. The guide CLAUDE.md and AGENTS.md vs a memory server compares them in detail.
What a memory server adds
A memory server keeps notes outside the session and outside any one computer. Claude Code reaches it through MCP (the Model Context Protocol) and gets tools to save, search, read and change memories. Instead of loading every note at the start, the agent searches for the few that matter to the task in front of it.
With Memlo:
- Each memory is a short note with a name and a title, stored in your account.
- Search matches what a memory means, not only its exact words.
- Every change is kept as a version, so an old answer can be restored.
- The same memories are available to Claude Code, Codex, claude.ai, ChatGPT and other MCP apps you sign in to.
Set up Memlo in Claude Code
You need a Memlo account. Accounts are by invitation for now; you can join the waitlist on the home page.
Step 1: Add the server
Run this in a terminal to add it for every project:
claude mcp add --transport http --scope user memlo https://memlo.ai/mcp
Leave out --scope user to add it to the current project only.
Step 2: Sign in
Start Claude Code, type /mcp, choose memlo, then choose Authenticate. A browser page opens at auth.memlo.ai. Sign in, and choose Continue on the page that asks to allow Claude Code to use Memlo.
Step 3: Check the connection
Run:
claude mcp get memlo
It should say "Status: ✔ Connected". Before sign-in it says "Needs authentication".
Step 4: Start a new session
Claude Code loads MCP servers when a session starts, so type /exit and run claude again. Then ask it to use the whoami tool; it answers with your Memlo account.
Share the setup with a team
Use --scope project. That writes a .mcp.json file you can commit, and each person still signs in with their own account:
{
"mcpServers": {
"memlo": {
"type": "http",
"url": "https://memlo.ai/mcp"
}
}
}
Load your memory at the start of every session
Claude Code works best with Memlo when the first thing it does in a session is call the get_prime_directive tool. That tool returns how to use Memlo well and your space's own prime_memory: what the space is for and its key memories.
A SessionStart hook makes this automatic. Hooks cannot call MCP tools themselves, so the hook prints a line that tells Claude to call it. Add this to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "echo 'Before anything else in this session, call the memlo MCP tool get_prime_directive (mcp__memlo__get_prime_directive) and follow what it returns.'"
}
]
}
]
}
}
With no matcher, the hook runs when a session starts or resumes, and after /clear or a compaction. If the file already has a "hooks" section, add the "SessionStart" entry to it.
Tell Claude Code what to remember
You don't need special commands. Talk to Claude Code as you would to a teammate:
- "Remember that this repo uses pnpm, not npm." Claude Code calls
create_memory. - "What did we decide about webhook retries?" It calls
search_memoriesand reads the best match. - "That memory is out of date: retries are 3 now, not 5." It calls
edit_memory, and the old text stays in the memory's history.
Good memories are short, have a plain title and hold one fact or decision each. Save decisions and the reasons for them, preferences, how things work and mistakes not to repeat. Never save passwords, API keys or tokens.
Frequently asked questions
Does Claude Code have persistent memory built in?
Yes, in two forms: CLAUDE.md files you write and auto memory that Claude Code writes. Both load at the start of each session from files on your computer. A memory server such as Memlo adds memory that is searched instead of loaded in full, and that other computers and other agents can use too.
Why does Claude Code forget what I told it yesterday?
Each session starts with a fresh context window. Only what is in CLAUDE.md, auto memory or a connected tool reaches the new session. A conversation that was never saved to one of those is gone. See Why your coding agent forgets.
Should I use claude mcp login to sign in?
Use /mcp inside Claude Code, choose memlo, then Authenticate. Some Claude Code versions stop after the sign-in page when you use claude mcp login memlo instead, and the server stays at "Needs authentication".
Do I need an API key?
No. There is nothing to install and no API key. Each person signs in with their own Memlo account in the browser.
The memlo tools don't show up. What should I check?
Start a new session first: a session that was open during setup does not have the tools. Then check that the URL ends in /mcp, that claude mcp get memlo says Connected, and that the server was added for this folder or with --scope user.
Try Memlo
Memlo is invitation only for now. Join the waitlist and we'll email you when your invitation is ready.
Join the waitlist