Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

git-memory

Persistent memory for AI coding agents where everything is git. There is no server, no database, no account and no config file.

git-memory is git, pointed at one repository: the memory repository, the .git-memory folder of the folder you are in (as a project's repository is its .git).

git-memory add . && git-memory commit -m "note about retries"     # = git -C .git-memory add . && … commit …
git-memory log --oneline
git-memory grep -n -i "retry"
git-memory remote add origin git@github.com:me/memory.git && git-memory push

Whatever you type goes to git, unchanged, inside that repository: arguments, flags, stdin, exit codes and the terminal are git's own. Because it is git, there is nothing to learn that git does not already teach, and nothing to sync that git push does not already sync.

Tools like akitaonrails/ai-memory give agents long-term memory, but they need a running service (a Rust server, SQLite, Docker). git-memory keeps the same core loop (capture → compile into a wiki → recall) and replaces the infrastructure with a repository you already know how to use. Around it, agent hooks for Claude Code and GitHub Copilot capture each session as a markdown page, brief the next session from what is stored, and save "remember that …" lines from your prompts. They write plain files and plain commits into the same repository.

Install

From the project's GitHub releases page, once a release is published (none yet). No root or administrator rights needed, and nothing outside your home directory changes.

Linux (x86-64 and ARM64):

curl -fsSL https://github.com/Rickedb/git-memory/releases/latest/download/install.sh | sh

Windows (PowerShell, x86-64 and ARM64):

irm https://github.com/Rickedb/git-memory/releases/latest/download/install.ps1 | iex

Each script downloads the right binary for your machine, checks it against the release's SHA256SUMS (and refuses to install on a mismatch), installs it, and adds its folder to your PATH:

Linux (install.sh) Windows (install.ps1)
Installs to ~/.local/bin/git-memory %LOCALAPPDATA%\Programs\git-memory\git-memory.exe
PATH a marked block in ~/.bashrc, ~/.zshrc or ~/.profile by your shell, or fish_add_path for fish; skipped if the folder is already on your PATH your user PATH (the registry, keeping any %VARIABLES% in it); also this session's
Running it again upgrades in place; the PATH entry is added once upgrades in place (a running copy is renamed aside, not an error)

Options, to pick a release or a folder, or to leave your PATH alone:

curl -fsSL https://github.com/Rickedb/git-memory/releases/latest/download/install.sh | sh -s -- --version 0.0.1 --dir ~/bin --no-path
& ([scriptblock]::Create((irm https://github.com/Rickedb/git-memory/releases/latest/download/install.ps1))) -Version 0.0.1 -Dir C:\tools -NoPath

Or by hand: download git-memory_linux_amd64, git-memory_linux_arm64, git-memory_windows_amd64.exe or git-memory_windows_arm64.exe from the releases page, rename it to git-memory (git-memory.exe) and put it on your PATH. Or build it (Go ≥ 1.22):

make build        # bin/git-memory for this machine
make release      # release/: git-memory_<os>_<arch> for Linux and Windows (amd64, arm64), SHA256SUMS, install.sh, install.ps1

The only requirement is git. Having git-memory on your PATH also makes git memory add . work: git runs any git-<name> program it finds as git <name>. There is no macOS build in the releases yet.

Quick start

cd your-project
git-memory clone git@github.com:me/memory.git     # optional: bring an existing memory repository (into ./.git-memory)
git-memory agent init claude                      # wire this project for Claude Code (or: copilot, codex, cursor, gemini, or all; naming none is an error). Creates ./.git-memory if there is none

That is the whole setup, and it adds nothing to your project's tracked files: the hook wiring, the slash commands and the .git-memory folder itself are git-excluded (.git/info/exclude, not your .gitignore).

The memory repository

A plain git repository, and its location is not configurable: it is the .git-memory folder in the folder you are in (what is configurable is the folder inside it that holds the memories, below). git-memory never searches for it, up the tree or anywhere else: be in the folder that has it (for a project, its root) and every command runs git there. Nothing creates it by accident: git-memory init makes one here, git-memory clone <url> clones one here, and git-memory agent init makes the project's own; any other command in a folder without one says so and does nothing. The agent hooks use the .git-memory of the project's root.

.git-memory/
  sessions/2026/11/2026-11-12-claude-ab12cd34.md     one page per agent session (written by the hooks; local, kept out of git)
  memories/<kind>/<title>.md                         decisions, procedures, facts, notes
  core/<title>.md                                    pinned: opens every briefing
  scopes/<scope>/{memories,core}/                    the same, for one part of the project (a module)
  global/
    memories/<kind>/<title>.md                       read in every scope, apart from the project's own

The memory root folder. The layout above starts at the repository's top by default. A repository that keeps its memories in a folder of it (a team repository with other things in it, say) names that folder in a small file at the top of the project, .git-memory.json (next to the .git-memory folder, not inside it), which you commit with the project like any other file, so everyone who clones the project gets the same layout and nobody configures anything:

{ "root": "docs/memory" }
git-memory agent init claude --root docs/memory    # writes .git-memory.json in the project, then wires it; or edit the file; commit it with the project

With it, the layout above starts in docs/memory/ (docs/memory/memories/, docs/memory/global/…); there is no projects/<name> level, because one memory repository holds one project, and a repository that holds several gives each its own root folder (and scopes for its modules): pages, briefings, the .gitignore for sessions, list, promote, doctor and the paths the agents are taught all follow. No file, no root, "." or "" all mean the repository's top. The value must be a folder inside the repository (no .., no absolute path). Page paths, in briefings and everywhere else, are the usual git ones and include the folder (docs/memory/memories/...).

The same file can turn on "autoCommit": true: the hooks then commit every change under the memory root folder, not only the pages they write (hand edits, global/), when a session starts, a turn ends or a session ends.

Scopes. A project's memories can also be split into scopes, such as a module of an app: scopes/checkout/memories/.... Everything is in the repository, but each checkout chooses, locally, the one it works in, and reads only that scope, the project's own memories and the global ones:

git-memory agent scope checkout                   # local to this checkout, never committed; --clear reads every scope again (also: agent init <agent> --scope checkout)

Staying in the scope is the rule; reading beyond it is something you ask for, in the prompt (across all scopes, ignore the scope, or another scope's name: in the search scope), and only for that prompt.

Pages are markdown with a small frontmatter, so you can browse, edit and review them anywhere git repositories go:

---
kind: decision        # decision | procedure | fact | note   (sessions are written by the hooks)
tier: semantic        # core pins it into every briefing
tags: [api]
created: 2026-11-12T10:00:00Z
---

# Public APIs are REST

Because external clients cannot speak GraphQL.

Curating is git:

You want to Do
Find something git-memory grep -n -i "retry"
Read a page git-memory show HEAD:memories/decision/rest.md
Share a memory with all your projects git-memory promote rest --to global (moves the page and commits)
Narrow a global memory to one project git-memory demote rest (the opposite of the line above)
Bring in what Claude Code or Copilot remember git-memory doctor lists them; git-memory promote claude:<file> --to project copies one in
Retire a decision that changed add status: superseded to its frontmatter and commit: it stays in git but leaves briefings and recall
Forget a mistake git-memory rm <page> and commit; history keeps it
Sync between machines git-memory remote add origin <url>, then git-memory sync
Share with a team clone the same remote on every machine (git-memory clone <url>); everyone commits to a branch named after their git user name, and git-memory sync merges the team's work into it and pushes it to main (/memory-sync settles conflicts)

What the hooks do

 agent hooks ──► spool (.git/git-memory/spool/*.jsonl, in the project's .git)    cheap append, ~13 ms per hook
                    │  Stop / PreCompact / SessionEnd
                    ▼
        session page  sessions/YYYY/MM/<date>-<agent>-<id>.md   a local file: the memory repository's .gitignore keeps it out of git
                    │
   SessionStart ◄───┴── briefing: pinned notes + every decision + recent memories and sessions (≤ 6 KB)
   UserPromptSubmit ◄── recall: BM25 hits for this prompt          (Claude Code only, see below)
   the agent ◄───────── git-memory grep / show / list / add / commit      (both agents, via the briefing and the slash commands)
  • Capture records intent, not output. Prompts, files edited, shell commands, failures and the agent's final message. Tool output is never stored.

  • Privacy. Secrets are redacted before anything is written (API keys, tokens, JWTs, private keys, KEY=value assignments, URL credentials). Text inside <private>…</private> is dropped. Files such as .env, *.pem, *.key and secrets/** are never recorded.

  • Remembering from the prompt. A line like remember that we deploy on Tuesdays or decision: use pnpm, never npm is saved as a page and committed. No model is involved. Only unambiguous markers count, one memory per line:

    remember that we deploy on Tuesdays     → note        remember: staging is rebuilt nightly   → note
    decision: use pnpm, never npm           → decision    #decision public APIs are REST         → decision
    #fact the API listens on 8081           → fact        #procedure run make migrate first      → procedure
    

    (remember to run the tests is an instruction for the current task, not a memory.)

  • Sessions stay local. The memory repository's .gitignore (/sessions/, added by git-memory init and agent init, and restored by the hooks if it goes missing) keeps session pages out of git, so they are never committed, pushed or shared. The briefing, git-memory list sessions and doctor read them from disk. Because git does not search ignored files, git-memory grep does not find them: use list sessions. A repository that already tracks session pages keeps tracking them until you git-memory rm -r --cached sessions.

  • Commits are scoped. A hook commits only its own folder, so whatever else you have staged in the memory repository stays staged.

  • Fail-open. A hook error is logged to the project's .git/git-memory/errors.log and the hook exits 0; it never blocks the agent.

Slash commands

git-memory agent init also installs seven commands for each agent you wire, in its own format (Claude Code and Codex skills, Copilot prompt files, Cursor commands, Gemini CLI commands), git-excluded like the hooks. They teach the agent to use git on the memory repository:

Command What it does
/memory-remember <text> writes a page for the project (or for every project) and commits it
/memory-decide reviews the conversation, proposes the decisions, procedures and facts worth keeping, and saves the ones you approve
/memory-recall <topic> git greps the memory and answers from it, citing pages by path
/memory-status where the memory is, what changed recently, anything uncommitted
/memory-list [scope] lists the memories of a scope (claude, copilot, personal for the global ones, project, or any folder of the memory repository), or the project's sessions (optionally of one date), and says what each one is for
/memory-promote promotes a memory to this project or to every project (also the agents' own memories)
/memory-refine rewrites one memory to be clearer, self-contained or current, keeping its meaning, and commits it after you approve the diff
/memory-forget retires a decision (status: superseded) or deletes a page
/memory-sync merges the team's memory into your branch, settles page conflicts (asking only when in doubt) and pushes

The text of every command is a markdown file in skills/ (one file per command, plus the notes they share), embedded in the binary: edit a file and rebuild to change a command. Commands that write are user-only (the model never invokes them on its own). The files are the same on every machine: they call the CLI as ./.git/git-memory/gm (relative to the repository root) and contain no home directory or memory location. To share them with the team, git add -f .claude/skills .github/prompts: a teammate's agent init regenerates byte-identical files, so nothing shows up as modified. A file of yours with the same name is never overwritten.

If ./.git/git-memory/gm is missing (a fresh clone, a new machine), every command tells the agent to say what is missing, show how to install it (install.sh / install.ps1, then git-memory agent init) and ask before running anything. The commands use no ! shell injection on purpose: Claude Code aborts the whole skill when an injected command fails, which is what happened on a repository with no commits yet.

Commands

The full guide, with the everyday recipes (cloning, committing, searching, syncing), is in COMMANDS.md. In short:

git-memory <git command> [args…]     git <git command> [args…], inside the memory repository
git-memory clone <url>               clone an existing memory repository into ./.git-memory
git-memory init                      git init here: creates ./.git-memory

git-memory doctor [--report]         the version and a health report: repository, project folder, hooks, activity, errors,
                                     and the agents' own memories it finds (Claude Code, Copilot)
git-memory list [repo|claude|copilot|sessions] [date]…
                                     every memory, grouped: the memory repository, Claude Code's own, Copilot's;
                                     `sessions` lists the project's session pages, optionally of one day, month or year
git-memory promote <source>… --to project|global     copy or move memories into this project's folder or the global one
git-memory demote <page>…                            the opposite: narrow a global memory to this project

git-memory agent init <claude|copilot|codex|cursor|gemini|all>… [--no-commands] [--no-instructions]  wire this project for the agents you name (`all` = every agent; none is an error)
git-memory agent hook <claude|copilot|codex|cursor|gemini> <event>  what the agents' hook files call
git-memory agent version

agent, doctor, list, promote and demote are the only words git-memory keeps for itself. Git has no such commands (a test checks them against the git on the machine running the tests), so nothing you type for git is ever intercepted, including init, hook and version, which are git's. There is nothing to configure: no config files and no environment variables.

The project's .git/git-memory/gm is the launcher the hook files call. On Linux and macOS it is a two-line sh script that execs the installed binary (so upgrading the binary needs no re-run); on Windows it is a copy of the .exe, so re-run agent init after upgrading. It is the one file with a machine-specific path, it lives under .git, and it is never committed.

Agent support

Claude Code (CLI + VS Code extension) GitHub Copilot (VS Code, preview) Codex CLI Cursor Gemini CLI
Hook file .claude/settings.local.json .github/hooks/git-memory.json .codex/hooks.json .cursor/hooks.json .gemini/settings.json
Capture prompts, edits, commands yes yes yes yes yes
Briefing at session start yes yes yes yes (additional_context) yes
Per-prompt recall injection yes no: Copilot drops userPromptSubmitted output for config-file hooks yes no: Cursor's prompt hook can only allow or block the prompt yes (BeforeAgent)
Final message captured yes (last_assistant_message / transcript) best effort via the transcript path yes (last_assistant_message) best effort via the transcript path yes (prompt_response)
Slash commands skills prompt files skills (.agents/skills) .cursor/commands .gemini/commands (TOML)
Always-on instructions .claude/rules .github/instructions none (briefing only) .cursor/rules none (briefing only)
You must also trust the hooks (/hooks) trust the workspace

Where an agent has no recall, recall happens when the agent runs git-memory grep, as the briefing tells it to. Codex and Gemini CLI get no instructions file because their AGENTS.md / GEMINI.md are the project's own tracked files; the session briefing carries the same guidance. Gemini CLI has no personal "local" settings file, so its hooks go into .gemini/settings.json: git-excluded, which only helps while that file is not tracked.

The session-start briefing itself tells the agent how to search and store memories. Copilot also reads .claude/settings*.json; duplicate events in the same second are dropped.

Caveats

  • The Codex, Cursor and Gemini CLI hooks follow each tool's published hooks reference (event names, payload fields, output shapes) and are covered by tests that replay those payloads, but none has been run against the live tool yet. Gemini CLI's docs say it is being replaced by Antigravity CLI (different hook files and events), which is not supported. Check .git/git-memory/errors.log if a session leaves no page.
  • The Copilot hook payloads and output shapes follow GitHub's published hooks reference. They are covered by tests that replay those payloads, but have not been run against a live VS Code Copilot session yet. Hooks are in preview there, so check .git/git-memory/errors.log if a session leaves no page.
  • The Windows binaries are cross-compiled and vetted, and their path, process and shell handling is written for Windows, but they have not been run on Windows yet (the end-to-end tests that drive the hooks skip on Windows for now). Unverified there: how Claude Code and Copilot run the hook command (the files use "$CLAUDE_PROJECT_DIR/.git/git-memory/gm.exe" agent hook … and ./.git/git-memory/gm.exe agent hook …), and quoting for project paths with spaces.
  • Projects wired by an earlier development build call gm hook <agent> <event>. That form keeps working, and git-memory agent init replaces it. The config files, scopes and commands of those builds (remember, search, sync, doctor, …) are gone: the same things are git commands now.
  • The Claude Code memory location is verified. The Copilot ones (doctor and promote read VS Code Copilot Chat's memory-tool/memories folders) follow its layout but have not been checked against a machine that has Copilot memories yet; if yours are elsewhere doctor says none found.
  • grep, show and friends see what is committed. The hooks commit their own pages; a page you write by hand is found once you add and commit it.
  • Search is lexical (git grep for you, BM25 + recency + kind weighting for the hooks' recall). There are no embeddings.

Development

Go (≥ 1.22) and git are all you need.

make build      # bin/git-memory for this machine
make test       # go vet + go test (unit tests and end-to-end tests: the real binary against real git repos in temp dirs)
make release    # release/git-memory_<os>_<arch> for Linux and Windows, amd64 and arm64, plus SHA256SUMS

Layout: cmd/git-memory is the entry point, and the rest is internal/gm, in layers that only depend downwards:

internal/gm/           the command line: routing to git, the help, dispatching our own commands (and the Windows/Unix process exec)
internal/gm/command/   our own commands, one file each: doctor, list, promote, demote, agent_init (plus slash.go, sources.go,
                        launcher.go and pages.go, which they share)
internal/gm/hook/      what the agents' hooks run, one file per event (start, prompt, tool, stop, precompact, end), plus the
                        spool, session pages, briefing, recall and "remember that …" triggers they share
internal/gm/hook/claude/    Claude Code: its event names, its settings file, what its hooks print (recall: yes)
internal/gm/hook/copilot/   Copilot: the same for Copilot (no failed-tool event, no recall)
internal/gm/hook/codex/     Codex: the same for OpenAI Codex CLI (recall: yes)
internal/gm/hook/cursor/    Cursor: the same for Cursor (a prompt hook cannot hand context back, so no recall)
internal/gm/hook/gemini/    Gemini CLI: the same for Gemini CLI (recall: yes)
internal/gm/hook/agent/     the contract between them: event kinds, the Agent type, recognising our own hook entries
internal/gm/core/      the memory repository and pages, the plain-git helpers, redaction, settings (uses nothing else of ours)

The end-to-end tests (internal/gm/e2e_test.go) build the binary once and drive it exactly as an agent or a person would: git-memory <git command>, agent init, hooks fed on stdin, and the installed launcher. Each package also has its own unit tests.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages