[FEATURE] Branch-aware auto-memory: scope MEMORY.md to git branch

Resolved 💬 5 comments Opened Mar 19, 2026 by mktoho12 Closed May 23, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Auto-memory (MEMORY.md) is currently scoped only by the working directory path. However, when working on different git branches within the same repository, each branch often represents a completely different task with its own context.

For example, on main I might be investigating a bug in the reporting system, while on feature/upgrade-nodejs-24 I'm tracking progress on a multi-day Node.js upgrade. When I switch branches, the same memory is loaded regardless, so memories from unrelated tasks appear — which can be confusing or even misleading.

The code changes when I switch branches, but the memory doesn't follow.

Proposed Solution

Allow auto-memory to be optionally scoped by git branch. For example:

~/.claude/projects/<project-slug>/memory/            # shared across branches (current behavior)
~/.claude/projects/<project-slug>/memory/<branch>/   # branch-specific

Branch-specific memories could take precedence over shared ones, or both could be loaded with branch-specific ones clearly marked. A configuration option to enable/disable this behavior would be ideal.

Alternative Solutions

  • Manually deleting or editing memory files when switching branches, but this is error-prone and defeats the purpose of persistent memory.
  • Using git worktrees to get separate directory paths (and thus separate memory), but this is heavyweight for simple branch switching.
  • Prefixing memory file names with branch names by convention, but Claude has no way to know which ones are relevant to the current branch.

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

  1. I'm on feature/upgrade-nodejs-24, working on a multi-day Node.js upgrade
  2. Claude saves progress notes to memory: "SAM CLI upgraded, compile confirmed, frontend changes remaining"
  3. I switch to main to investigate an urgent bug report
  4. Claude loads the Node.js upgrade memories, which are irrelevant to the bug investigation
  5. Later I switch back to the feature branch — ideally Claude should pick up exactly where we left off, with the right context
  6. With branch-scoped memory, each branch would have its own context and switching would be seamless

Additional Context

Related issues:

  • #18380 - Session segmentation by branch (closed; focused on conversation/session context, not persistent memory)
  • #30667 - Worktree memory path resolution (open; focused on worktree path bugs, not branch-level scoping within the same directory)

This request is distinct from both: it specifically targets persistent auto-memory scoping by branch within the same working directory.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗