feat: bridge Claude auto-memory back to parent project - #3
Merged
Merged
Conversation
Claude's auto-memory writes to ~/.claude/projects/<slug>/memory/ where slug is derived from the git-resolved repo root. Exp branches are isolated APFS clones with their own .git, so each branch gets its own slug — memory written during branch sessions is orphaned the moment the branch is trashed. Originally shaped to write autoMemoryDirectory into the branch's .claude/settings.local.json, but verified empirically that Claude only honors that setting from user-level settings (deliberate security restriction). Symlinking the branch's would-be memory dir to the parent's works below Claude's API surface: Claude resolves its memory dir from cwd as usual and the bytes follow the symlink. End-to-end verified by launching claude in a clean test branch and confirming the written memory file resolves to the parent's slug. Coupling note: the symlink approach is load-bearing on Claude's storage conventions (path under ~/.claude/projects/, slug rule, on-disk markdown). All documented in CLAUDE.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
thebrubaker
force-pushed
the
joel/claude-memory-handler
branch
from
May 20, 2026 20:49
595fab3 to
b15800d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.claude/projects/<branch-slug>/memory/and died when the branch was trashed. Now they're symlinked back to the parent project's memory dir, surviving branch lifecycle.core/memory-bridge.tsmodule with pure functions (claudeProjectSlug,claudeProjectDir,claudeMemoryDir,bridgeMemory); 11 new tests.memory_bridgeconfig key (defaulttrue) +EXP_MEMORY_BRIDGEenv var to disable.exp newJSON output now includesmemoryBridge: "linked" | "exists" | "skipped" | "off".Shape pivot
Originally written as
autoMemoryDirectoryin.claude/settings.local.json. End-to-end verification via cmux + a real Claude session showed Claude ignores that key at the project-local layer (security restriction — only user-level settings are honored). Symlink approach validated end-to-end after pivot: launched Claude in a fresh test branch, asked it to write a memory, confirmed the file landed at the parent's slug viarealpath.Coupling note
The symlink approach is load-bearing on three Claude conventions: memory dir location under
~/.claude/projects/, slug rule (/and.→-), and on-disk markdown storage. No documented hook or API lets a project declare an alias identity today. Documented inCLAUDE.mdso future-me knows where to look if this breaks.Closes DIG-198.
Test plan
bun test— 151/151)🤖 Generated with Claude Code