Help us improve
Share bugs, ideas, or general feedback.
Share bugs, ideas, or general feedback.
Share bugs, ideas, or general feedback.
By Davidcreador
Automatically switch Claude Code context when changing git branches by saving and loading branch-specific CLAUDE.md memory files, with CLI commands to list, save, load, and check memory status per branch.
npx claudepluginhub davidcreador/claude-code-branch-memory-managerList all stored branch memories with their sizes and last modified dates.
Load a branch-specific CLAUDE.md memory file. Use when the user wants to load context from a different branch.
Save the current CLAUDE.md to branch-specific memory. Use when the user wants to save their current branch context.
Show the current branch memory status including active memory, saved memory, and configuration.
Automatic branch-specific CLAUDE.md memory management for Claude Code. When you switch git branches, your Claude Code context switches with you.
When working across multiple git branches, your CLAUDE.md file contains context specific to one branch. Switching branches means Claude Code loses that context, or worse, has the wrong context for your current work.
Branch Memory Manager saves and loads branch-specific CLAUDE.md files automatically. Each branch gets its own memory, stored in .claude/memories/.
As a Claude Code plugin — memories switch automatically when you run git checkout or git switch inside Claude Code. No manual intervention needed.
As a CLI — manually save, load, and manage branch memories from your terminal.
# Install the npm package in your project
npm install --save-dev claude-code-branch-memory-manager
# Or install globally
npm install -g claude-code-branch-memory-manager
Then load as a plugin:
claude --plugin-dir ./node_modules/claude-code-branch-memory-manager
Once installed, branch memory switching happens automatically:
git checkout feature/auth inside Claude CodeCLAUDE.md to .claude/memories/main.md.claude/memories/feature_auth.md into CLAUDE.mdfeature/auth work# Initialize in your repo
branch-memory init
# Save current context
branch-memory save "Implemented user auth"
# Switch branches (saves + loads automatically)
branch-memory switch feature/api
# List all saved memories
branch-memory list
# Check status
branch-memory status
| Command | Description |
|---|---|
branch-memory save [description] | Save current CLAUDE.md to branch memory |
branch-memory load <branch> | Load memory from a specific branch |
branch-memory list | List all stored branch memories |
branch-memory status | Show current branch and memory status |
branch-memory switch <branch> | Git switch + memory swap in one command |
branch-memory copy <src> <dst> | Copy memory between branches |
branch-memory clean | Remove memories for deleted branches |
branch-memory restore [branch] | Restore from backup |
branch-memory init | Set up branch memory in current repo |
branch-memory version | Show version |
Branch memories are stored in .claude/memories/ within your repository:
your-repo/
├── CLAUDE.md # Active memory (read by Claude Code)
├── .claude/
│ └── memories/
│ ├── main.md # Memory for main branch
│ ├── feature_auth.md # Memory for feature/auth
│ ├── feature_api.md # Memory for feature/api
│ └── .backups/ # Automatic backups
│ └── main.2025-03-18T...md
When installed as a Claude Code plugin, two hooks handle automatic switching:
SessionStart — Loads the correct branch memory when Claude Code startsPostToolUse (Bash) — Detects git checkout / git switch commands and swaps memoriesWhen switching to a branch with no saved memory, the tool looks for a fallback in this order: main → master → develop. This is configurable.
Create a .branch-memory.json in your repo root:
{
"memoryDir": ".claude/memories",
"memoryFileName": "CLAUDE.md",
"autoSaveOnSwitch": true,
"fallbackToDefault": true,
"fallbackBranches": ["main", "master", "develop"]
}
| Variable | Description |
|---|---|
BRANCH_MEMORY_DIR | Memory storage directory |
BRANCH_MEMORY_FILE | Memory file name |
BRANCH_MEMORY_AUTO_SAVE | Enable/disable auto-save (true/false) |
BRANCH_MEMORY_FALLBACK | Enable/disable fallback (true/false) |
BRANCH_MEMORY_FALLBACK_BRANCHES | Comma-separated fallback branches |
When installed as a Claude Code plugin, these skills are available:
/branch-memory:save — Save current context/branch-memory:load — Load a branch's context/branch-memory:status — Show memory status/branch-memory:list — List all memories.claude/memories/ to .gitignore if you don't want to share memories across the team.claude/memories/ if you want shared branch contextbranch-memory clean periodically to remove memories for deleted branchesfeature/auth becomes feature_auth.mdMIT
Executes bash commands
Hook triggers when Bash tool is used
Share bugs, ideas, or general feedback.
Based on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Git-versioned, taxonomy-structured memory for Claude Code — recall by path, branch to isolate, time-travel to audit.
Automatically maintains CLAUDE.md files as codebases evolve using hooks, agents, and skills
Auto-capture high-signal coding context into memctl memory
Memory compression system for Claude Code - persist context across sessions
Persistent memory for Claude Code. Capture work across sessions and recall relevant context.
Persistent memory across Claude Code sessions using Supermemory
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge.
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge.
Sign in to claim