I realised something while building agent memory for Claude Code: it already trusts git as the substrate for a bunch of “memory”:
CLAUDE.md and the hierarchy walked up your tree
- .claude/commands/ (slash commands)
- .claude/agents/ (subagents)
- .claude/skills/ All git-committed by convention. Nobody calls these “memory” but they 100% are — they shape what the model sees every turn. What’s not git-tracked:
- ~/.claude/projects/<cwd>/memory/ (the auto-memory MEMORY.md that gets injected into the system prompt)
- Session transcripts (~/.claude/projects/<cwd>/*.jsonl)
- Tool-call observations, session summaries, decisions So the design I’m sketching is just: extend the convention that already exists. Put the un-tracked half into a dedicated ~/.claude/memory.git, append-only, files-with-frontmatter, plumbing-level writes so it’s ~5ms per record. ~/.claude/memory.git/ ├── conversations/2026/05/11/20260511T143022Z-coding-memory-design.md ├── sessions/<uuid>.md ├── summaries/daily/2026-05-11.md ├── decisions/20260511-use-git-as-substrate.md └── observations/2026/05/11.jsonl Front matter has code_sha (HEAD of the code repo at capture) so memory cross-references code state cheaply. What you get for free that everyone else builds from scratch:
- git log -S “thing” (pickaxe) replaces 80% of vector search at 1/1000th the cost, instant on 10k commits
- git blame on a decision doc tells you which session said it
- git bisect for “when did I start writing X about Y”
- git notes --ref=intents for off-tree metadata that doesn’t pollute history
- git push private-remote = free cross-machine sync + offsite backup
- git gc = automatic compaction
- Plumbing writes (hash-object + commit-tree + update-ref) bypass the working tree — no checkout race, no .git/index.lock fights Hooks I want to register:
- SessionStart → create session skeleton with code HEAD captured
- UserPromptSubmit → append user turn to session file
- PostToolUse → append line to today’s observations/YYYY/MM/DD.jsonl
- Stop → LLM-summarise, write summaries/sessions/<uuid>.md, commit
- PreCompact → force-flush before context reset Rules to enforce via pre-commit hooks: Append-only — no rebases, no force-pushes Frontmatter required: code_sha, domain, created_at Secrets scan (this repo may get pushed) Filenames lexically sortable: YYYYMMDDTHHMMSSZ-<domain>-<slug>.md Date sharding — no dir exceeds 1000 files Prior art the pattern leans on:
- git-bug stores issues in custom git refs
- git-appraise stores code reviews as git notes
- fossil treats tickets + wiki as first-class VCS objects
- Half the Obsidian community commits their vaults to git So the architectural move (structured non-code data in git refs/notes) is well-established. The “port it to AI agent memory” step is what I can’t find a public package for. What I’m asking: Is anyone applying the git-bug / git-appraise pattern specifically to AI agent memory? Surveyed mem0, Letta, Zep, claude-mem, Cognee, Continue, cline, aider, all use vector DB / SQL / graph backends. Aider git-commits code changes but not memory. Has someone made the leap? Claude Code hook recipes anyone willing to share a hooks.json that does memory capture beyond what claude-mem ships? Plumbing-level git writers in JS/Python — child_process.execFile(‘git’, [‘hash-object’]) works but feels like leaving performance on the table. nodegit / isomorphic-git / pygit2 alternatives that handle update-ref atomically? Privacy. A single git push to the wrong remote leaks everything. git-crypt on sensitive paths is the obvious answer but feels heavy. Anyone landed on something lighter? The blind spot I’m not seeing — has someone tried this and bounced off something? Filesystem inode pressure? Repo size after a year of dense use? Hook ordering interacting badly with claude-mem or other plugins? Trying to find out whether the architecture is novel or I’m rediscovering something with an established name. submitted by /u/Relative_Register_79
Originally posted by u/Relative_Register_79 on r/ClaudeCode
You must log in or # to comment.
