From claude-brain-surgery
Externalize Claude's auto-memory into your project directory so it's git-committable and survives across machines
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-brain-surgery:brain-surgeryThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Externalizes Claude's auto-memory into `.context/memory/` in the project root, replacing the auto-memory directory with a symlink. This makes Claude's memory git-trackable, portable, and collaboratively editable.
Externalizes Claude's auto-memory into .context/memory/ in the project root, replacing the auto-memory directory with a symlink. This makes Claude's memory git-trackable, portable, and collaboratively editable.
/brain-surgery — Set up the symlink (safe, non-destructive)/brain-surgery --undo — Restore the default auto-memory directoryUse $PWD as the project root.
Safety check: If $PWD is $HOME, /home, /tmp, /, or any path with fewer than 3 components, STOP and warn the user:
"This doesn't look like a project directory. Run this from inside a project root."
Claude's auto-memory lives at:
~/.claude/projects/<encoded-path>/memory/
The encoded path replaces all / with -, including the leading slash. So /home/jocel/projects/foo becomes -home-jocel-projects-foo.
Compute it:
encoded="$(echo "$PWD" | tr '/' '-')"
auto_memory="$HOME/.claude/projects/${encoded}/memory"
Check if the user passed --undo. If so, skip to the Undo section below.
ls -la "$auto_memory" 2>/dev/null
.context/memory/ → Tell the user "Already set up!" and show the symlink. Done.This is the delicate part. Existing memory files must be preserved.
Back up first:
backup="/tmp/claude-memory-backup-$(date +%s)"
cp -a "$auto_memory" "$backup"
Create .context/memory/ if needed:
mkdir -p .context/memory
Copy files (no-clobber — don't overwrite existing .context/memory/ files):
cp -n "$auto_memory"/* .context/memory/ 2>/dev/null
Verify the merge:
src_count=$(ls -1 "$auto_memory" 2>/dev/null | wc -l)
dst_count=$(ls -1 .context/memory 2>/dev/null | wc -l)
The destination count should be >= the source count. If dst_count < src_count, ABORT and tell the user:
"Merge verification failed. Your backup is at: $backup"
Remove the original directory:
rm -rf "$auto_memory"
Tell the user how many files were merged and that the backup is at $backup.
mkdir -p "$(dirname "$auto_memory")"
mkdir -p .context/memory
ln -s "$PWD/.context/memory" "$auto_memory"
Verify it worked:
readlink "$auto_memory"
Only if .context/memory/MEMORY.md doesn't already exist:
# Project Memory
> Auto-memory externalized by claude-brain-surgery.
> This file is loaded into Claude's system prompt at the start of every session.
> Keep it under 200 lines — overflow gets truncated.
Tell the user:
$auto_memory → .context/memory/)git add .context/memory/ to start tracking it.context/ is a good place for other project context files tooWhen --undo is passed:
readlink "$auto_memory"
target="$(readlink "$auto_memory")"
rm "$auto_memory"
mkdir -p "$auto_memory"
cp -a "$target"/* "$auto_memory/" 2>/dev/null
Tell the user:
$auto_memory.context/memory/ was left intact (they can delete it manually if they want)npx claudepluginhub ellyseum/claude-brain-surgery --plugin claude-brain-surgeryManages Claude Code persistent memory: CLAUDE.md hierarchy, rules in .claude/rules/, auto memory files, imports, bootstrap setup, debugging, and best practices.
Organizes, extracts, prunes, and verifies Claude Code persistent memory files to keep MEMORY.md under the 200-line truncation limit and topic files up to date with project state.
Configures Claude for proactive mnemonic memory with automatic recall/capture, git org/project detection, bash setup of store paths and config.json.