Sync Claude Code memory between machines
Claude Code's auto memory is machine-local and keyed by your repo's path. Point autoMemoryDirectory at a synced folder, and leave credentials and transcripts out.
On this page
To sync Claude Code memory between machines, set autoMemoryDirectory on each machine to the same synced folder, one per project, and sync that folder with git or a file sync tool. Claude Code has no sync of its own: auto memory lives in ~/.claude/projects/<project>/memory/, and the <project> name comes from where the repository sits on disk, so copying ~/.claude/projects between machines often lands in the wrong folder. Your own instructions, ~/.claude/CLAUDE.md, rules and skills, are safe to sync. Credentials, ~/.claude.json and session transcripts are not.
Everything about Claude Code below is from its memory, settings, .claude directory and authentication docs, as of November 2026.
What is per machine by default?
Almost everything Claude Code keeps outside your repository is per machine. The memory docs say it plainly: “Auto memory is machine-local”, and its files “are not shared across machines or cloud environments.”
| What | Where | Sync it? |
|---|---|---|
| Your instructions | ~/.claude/CLAUDE.md, ~/.claude/rules/ |
Yes |
| Your skills, commands, agents | ~/.claude/skills/, commands/, agents/ |
Yes |
| User settings | ~/.claude/settings.json |
Yes, minus paths that differ per machine |
| Auto memory | ~/.claude/projects/<project>/memory/ |
Yes, through autoMemoryDirectory |
| Session transcripts | ~/.claude/projects/<project>/<session>.jsonl |
No |
| Account, MCP servers, trust decisions | ~/.claude.json |
No |
| Login | ~/.claude/.credentials.json, or the macOS Keychain |
Never |
The project’s own CLAUDE.md, .claude/settings.json and .claude/rules/ don’t need syncing: they travel with the repository. A CLAUDE.local.md doesn’t, because you add it to .gitignore.
Why copying ~/.claude/projects doesn’t work
Claude Code names each project’s memory folder after the repository’s location. The docs say the <project> path “is derived from the git repository”, and the .claude directory page says the folder is “keyed by the repository path”. All worktrees of one repository on one machine share it.
So the same repository at C:\dev\app on your Windows desktop and at ~/code/app on your laptop gets two different folders. Sync ~/.claude/projects between them and each machine keeps writing to its own, and neither sees the other’s notes. It works only when every machine keeps the repository at the same path, with the same user name.
Many of the guides that rank for this question work around it with symlinks or a sync tool for all of ~/.claude. Claude Code now has a setting for it, so you don’t need either.
Sync Claude Code memory with autoMemoryDirectory
autoMemoryDirectory tells Claude Code where to keep auto memory instead of the default folder. The value “must be an absolute path or start with ~/”. It names the memory folder itself, so set it per project, not once in your user settings, or every project writes into the same folder.
- Make a synced folder for memory, for example
~/Sync/claude-memory/. Git, Syncthing, Dropbox or iCloud all work, as long as both machines see the same files. - Move each project’s existing notes in: copy
~/.claude/projects/<project>/memory/to~/Sync/claude-memory/app/. - On each machine, in the project, put the setting in
.claude/settings.local.json, which stays out of git:
{
"autoMemoryDirectory": "~/Sync/claude-memory/app"
}- Start a session and run
/memoryto check Claude sees the notes.
Because the path starts with ~/, the same line works on Windows, macOS and Linux, wherever the repository sits.
Two limits to know. Claude Code honors this key from a project’s settings files only “under the same workspace trust rule as hooks”, because a cloned repository can supply those files, so trust the folder first. And while permissions.blockReadsOutsideWorkingDirectories is on, it loads and saves no auto memory in a folder that a repository’s settings file chose. If you use that permission, set the folder in a way it allows, or leave it off for this project.
You could commit the setting to the shared .claude/settings.json instead, but then it applies to everyone who clones the repository. Keep it local.
There is also a launch-time variable, CLAUDE_CODE_PROJECT_DIR_NAME, which the docs describe for use beside CLAUDE_CONFIG_DIR to fix the <project> name. It needs Claude Code v2.1.234 or later and is read only from the environment you launch from. For syncing memory, autoMemoryDirectory is simpler.
What should never be synced?
Three things in your Claude Code folders should stay on the machine that made them.
- Your login. On Linux and Windows, credentials are in
~/.claude/.credentials.json. On macOS they’re in the Keychain, and fall back to that file when the Keychain refuses the write. Syncing all of~/.claudecopies your login with it. Sign in on each machine instead. ~/.claude.json. Claude Code writes it for itself. The settings docs say it holds “your account details, MCP server configurations, per-project state such as trust decisions”. Trust given on one machine shouldn’t be given on another by a file sync. Add your MCP servers on each machine, or put shared ones in the project’s.mcp.json.- Session transcripts. Each
.jsonlfile holds the conversation, tool calls and their results, stored as plain text. Claude Code deletes them aftercleanupPeriodDays, 30 days by default, and that sweep skips the memory folder. Syncing them spreads every file and command output a session saw to every machine.
One more rule for any sync: avoid two sessions on two machines writing the same memory folder at the same moment. Git will show you the conflict. A file sync tool may quietly keep one version, or both side by side.
If you use more than one agent
autoMemoryDirectory syncs what Claude Code learned between your machines. It doesn’t share it with Codex, Cursor or Gemini CLI on the same machine, which never read Claude’s folder. AGENTS.md shares rules, not memory covers that split.
Memorinth puts every agent’s memory in one cortex, a folder of Markdown notes you choose. Memorinth has no sync of its own either: you sync the cortex yourself, the same way as above. Two things make it easier.
- One folder for every project. A cortex isn’t named after a repository path, so there is nothing to line up between machines. Each machine just needs to know where the folder is.
- Leave
.memorinth/out. That folder holds the search index, which Memorinth rebuilds from the notes, and a log of which agent called which tool on this machine. Put it in.gitignore, or exclude it in your sync tool, and sync the notes.
On the second machine, after the cortex folder has synced:
$ memorinth init ~/MemorinthIt makes that folder the cortex agents use on this machine, and connects the agents you pick, as Set up your cortex describes. Notes any agent writes on one machine reach the other with your next sync.
Next step
Set autoMemoryDirectory in one project on both machines, and check with /memory that each sees the other’s notes. If you want more than Claude Code to remember, start with Give Claude Code a long-term memory, or read Claude Code memory: built in, or a server? first.