Guides / Shared memory for Claude Code and Cursor.

1731 words | Esment

Shared memory for Claude Code and Cursor.

Claude Code and Cursor keep separate memory. Share rules with one AGENTS.md, then add an MCP memory server for decisions both can recall.

╌╌╌╌

To share memory between Claude Code and Cursor, give both tools something they can read. The simplest version is free: keep your project's rules in one AGENTS.md file, which both tools load. When a file stops being enough, connect both to the same MCP memory server, so a decision saved in one can be found from the other.

A shared file holds rules you wrote on purpose. A memory server holds what came up while you worked. This guide walks through both with one small example and explains why connecting a memory server does not by itself mean it gets used.

What each tool remembers on its own

Claude Code has two memory systems: CLAUDE.md files you write, and auto memory, notes Claude writes itself under ~/.claude/projects/<project>/memory/. Auto memory is local to the machine and belongs to Claude Code. Cursor keeps its instructions in project rules and AGENTS.md, with project rules stored in .cursor/rules.

So a note Claude Code takes for itself does not reach Cursor, and a .mdc rule in Cursor does not reach Claude Code. The overlap is AGENTS.md, an open format for guiding coding agents.

The example: a decision in a recipe app

Say you are working on a recipe app. In a Cursor chat you decide that ingredient quantities are stored as whole grams and converted to cups or ounces only on screen. The next day you open Claude Code to add a shopping list export. You want it to know about that decision without being told again.

Start free: one shared AGENTS.md

Put the decision in a file at the root of the repository:

AGENTS.md
# Recipe app

## Data model
- Ingredient quantities are stored as whole grams.
- Convert to cups and ounces only when displaying them.
- Never store a converted value.

Cursor reads AGENTS.md from the project root and from subdirectories. Claude Code reads it directly from v2.1.277, but by default only when there is no CLAUDE.md or CLAUDE.local.md in your working directory or above it. If your project already has a CLAUDE.md, add this line to it, and both tools will share one source:

CLAUDE.md
@AGENTS.md

Start a new Claude Code session and ask how quantities are stored. It should answer from the file. This costs nothing, lives in git and reaches everyone on the project. For a single repository with a modest set of rules, you can stop here.

Where the shared file breaks

  • Someone has to write it. A decision made in a chat only reaches the file if you stop and move it there, and that step is easy to skip.
  • It has a size budget. Claude Code's docs suggest staying under 200 lines per file, because longer files use more context and reduce adherence. Every line is loaded in every session, relevant or not.
  • It stays in one repository. A preference you hold across five projects has to be copied five times.
  • It is a poor home for some notes. A half-formed idea or a personal preference doesn't belong in a file the whole team reviews.
  • It only reaches tools that read it. A chat assistant you use to think through the same project never sees it.

The MCP approach: one store, two clients

MCP is the protocol both tools use to reach outside programs. A memory server exposes tools for saving and searching. If Claude Code and Cursor connect to the same server, and that server writes to the same store, they share memory.

A memory saved in CURSOR is found later in CLAUDE CODE, because both connect to one storeCURSORCLAUDE CODEONE MEMORY SERVERSAVEFINDQuantities are stored as whole grams

A free way to try this is the reference memory server from the MCP project, which keeps a small knowledge graph in a local file. The important detail is MEMORY_FILE_PATH. Set it to the same absolute path in both tools. The default location sits inside the package's install folder, where an update or cache clear can delete it. The folder must already exist. Check the server's README for its Node.js requirement.

In Cursor, add this to ~/.cursor/mcp.json so it applies to every project:

~/.cursor/mcp.json
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": {
        "MEMORY_FILE_PATH": "/Users/you/ai-memory/memory.jsonl"
      }
    }
  }
}

In Claude Code, add the same server at user scope:

Terminal
claude mcp add --scope user \
  --env MEMORY_FILE_PATH=/Users/you/ai-memory/memory.jsonl \
  --transport stdio memory \
  -- npx -y @modelcontextprotocol/server-memory

Now run the example. In a Cursor chat, say:

Cursor
Save this to memory: in the recipe app, ingredient quantities are stored as whole grams and converted only for display.

By default Cursor asks you to approve each MCP tool call, so expect a prompt. Then open a new Claude Code session, use /mcp to confirm the server is connected, and ask:

Claude Code
Search memory: how does the recipe app store ingredient quantities?

Claude should call the search tool and return the decision saved from Cursor. If you would rather have memory you can open and edit as ordinary notes, Basic Memory stores plain Markdown and connects over MCP.

Hooks and model-chosen recall

That request works because it says "search memory". Real work rarely sounds like that. Ask for a shopping list export and nothing in the sentence points at memory, so the model may start coding without looking.

This is model-chosen recall. A connected MCP tool is an option the model has, not a step that always runs. Cursor's docs say the agent uses MCP tools when it judges them relevant. Claude Code, by default, finds MCP tools on demand rather than loading them all upfront. A line in AGENTS.md such as "search memory before changing the data model" improves the odds, but it remains an instruction the model can miss.

A hook is different. It is a program the app itself runs at a fixed moment, whatever the model intends, and some hooks can add text to the conversation. A hook that fetches relevant memories puts them in front of the model before it answers. The two tools do not offer the same moments:

MomentClaude CodeCursor
Session startSessionStart can add contextsessionStart can return additional_context
Each promptUserPromptSubmit can add context alongside the promptbeforeSubmitPrompt can block a prompt, but has no field for adding context

So Claude Code can load memory on every turn, while Cursor's documented route for adding it before you start is once per session. Cursor's session hooks also do not run in cloud agents. Hooks have limits of their own: they add only what the script selects, and that text uses context on every run. Without hooks, keep a line in your rules and ask directly when a past decision matters.

Where Esment fits

Esment is a memory layer that does this wiring for you. It contains no model of its own: your assistants connect over MCP and share one memory. On a Mac, open Assistants, click Configure on the Claude Code card and on the Cursor card, then quit and reopen each app. Both receive instructions on when to use memory automatically, so there is nothing to paste.

For recall that does not depend on the model, enable the Claude Code hooks card, which loads memory into every turn. For Cursor, Configure installs the Agent Plugin (a local memory server, a skill and hooks) where supported, and Cursor can also run Claude Code's hooks if you turn on third-party configs in its settings. The session brief is what gets added, and What gets injected on the Assistants page lets you preview it. In apps without hooks, recall still depends on the assistant calling the tool.

Saving works as above: the assistant decides what to save, or you tell it. Esment does not watch your editor. Each memory shows which assistant saved it, which helps when a Cursor note looks wrong in Claude Code. If you are connecting by hand, or from the cloud, the snippet has this shape:

mcp.json
{
  "mcpServers": {
    "esment": {
      "url": "<your memory address>/mcp",
      "headers": { "Authorization": "Bearer <access key>" }
    }
  }
}

In the Mac app with sync off, memories are stored on your Mac and don't reach Esment's servers. Claude and Cursor's vendors still process whatever those assistants read, as the privacy page explains. The Mac app needs a paid plan and there is no Windows or Linux desktop app; see pricing.

Which option to use

Your situationGood fit
You use only one of the two toolsThat tool's own files and memory. Nothing to share.
One repository, stable rules, a team that reviews themAGENTS.md alone
You want shared recall for free and can maintain the configA local MCP server, such as the reference server
You want your memory as Markdown notes you editBasic Memory
Several assistants beyond these two, with hooks set up for you and a place to review memoriesEsment

You can use both. Rules that must always apply stay in AGENTS.md, and the running record of decisions lives in memory. When a remembered decision has held up for a while, promote it to the file.

Save your first memory →

Common questions

In:

Does Claude Code read AGENTS.md?

Out:

Yes, from v2.1.277. By default it reads AGENTS.md only when there is no CLAUDE.md or CLAUDE.local.md in your working directory or above it. If you have a CLAUDE.md, add an @AGENTS.md import to it so both files load.

In:

Can Claude Code and Cursor use the same MCP server at the same time?

Out:

Yes, but each app needs its own configuration entry. With a local server that each app starts for itself, point both at the same data file. The reference memory server uses a lock file so writes from several processes happen one at a time.

In:

Will my assistant use shared memory automatically?

Out:

Not unless something makes it. A connected MCP tool is used when the model judges it relevant. A hook can add memory to the conversation without the model choosing to, and instructions in your rules raise the chance of a search but do not guarantee it.

In:

Can a team share memory this way?

Out:

AGENTS.md is shared through git. A project .mcp.json can share a server definition, and Claude Code asks each person to approve it, but keep access keys out of committed files. The reference server stores data on one machine, so a team needs a shared store. In Esment, multi-person workspaces are part of the Teams and Enterprise plans.

Written by the team that builds Esment, so we are not a neutral party. Tools change quickly: check each one before you rely on it.

Get the next chapter by email.

One email per new chapter. Nothing else.

0.00