·

Is Claude Code Auto Memory Shared Between Worktrees?

Prepared and checked using AI. Sources are linked in the article.

claude-code git-worktrees parallel-development ai-coding

Yes, Claude Code auto memory is shared between worktrees of the same Git repository by default. Its default directory is ~/.claude/projects/<project>/memory/, with <project> derived from the repository. To keep parallel tasks’ notes separate, pass a different autoMemoryDirectory value when launching each session.

Give each task its own memory directory

Use an installed Claude Code version that supports the setting: autoMemoryDirectory was added in v2.1.74. Check your installed version with claude --version.

The --settings flag accepts inline JSON or a path to a JSON settings file. The memory directory must be an absolute path or start with ~/; avoid relative paths.

For example, suppose you are working on authentication and billing tasks in a repository called shop. Start these commands from the repository root in separate terminals:

claude --worktree auth --settings '{"autoMemoryDirectory":"~/.claude/task-memory/shop/auth"}'
claude --worktree billing --settings '{"autoMemoryDirectory":"~/.claude/task-memory/shop/billing"}'

--worktree starts Claude in a named worktree under the repository’s .claude/worktrees/ directory. The separate memory paths provide the task-specific memory storage; choosing different worktree names alone leaves the default shared memory behavior in place.

Keep the same memory path when returning to a task, and include the override on every launch that should use it. For the broader session workflow, see running multiple Claude Code agents in parallel.

Check the directory before starting work

Inside each session, run:

/memory

Use the option to open the auto memory folder, and check that each session points to its intended directory. The folder contains a MEMORY.md index and memory topic files.

Treat this as a launch check: verify the destination before asking Claude to remember task-specific decisions.

Avoid settings that accidentally share memory again

Session settings override user, project and local settings, but managed settings take precedence. If an organization sets the same key through managed settings, your launch override cannot replace it.

Two configuration choices deserve attention:

  • ~/.claude/settings.json applies to every project on your machine. A single fixed memory directory there is a poor choice when your goal is a different destination for each task.
  • In current Claude Code worktree sessions, .claude/settings.local.json normally comes from the main checkout’s root. Do not assume that placing a different local settings file inside every worktree will isolate this setting. Explicit launch overrides make the intended destination clearer.

Choose what should remain shared

Keep the default directory when repository-wide corrections and preferences should carry between tasks. Choose separate directories when temporary assumptions or competing approaches should remain task-specific; the trade-off is that useful lessons will also be separated.

Put deliberate, reusable project instructions in CLAUDE.md, rather than relying on Claude to save them automatically. See AGENTS.md and CLAUDE.md for organizing agent instructions.

If a session should not use auto memory, disable it for that launch:

CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 claude

Where Parallel Code fits

Parallel Code is our free, open-source desktop app for macOS and Linux that runs several AI coding agents in parallel, each in its own Git worktree. It provides a diff-first review surface; pair that workflow with an explicit memory destination for each Claude Code task.