agent-memory
Open sourceFor Claude Code and Codex

One memory for Claude Code and Codex

agent-memory keeps what your agents learn as plain Markdown files in a git repository you own. Each session starts with what matters where it runs; each turn ends with a commit.

uv tool install "agent-memory-git[ui]"
127.0.0.1:8790
mem ui: a list of memories on the left, one open on the right with its provenance
How it works

Two hooks and a folder of Markdown

mem install wires the same hooks into both tools. Nothing runs in the background, and git does the syncing.

Session start

A hook works out where the session runs and injects an index of the memories that apply: everything global, plus what was learned in this folder or repository.

While you work

The agent saves what is worth keeping as one Markdown file per memory, following the rules in PROTOCOL.md: who you are, how you want work done, facts about a project, where to find things.

Turn end

A hook stamps each new memory with where it came from and commits it, then pushes if there is a remote. The next session, in either tool and on any machine that pulls, sees it.

Claude Codehooks · CLAUDE.md
Codexhooks · AGENTS.md
agent-memory-datagit
memories/2026/10/
  • ask-before-push.md
  • shop-web-v3-freeze.md
  • payments-runbook.md
  • reply-language.md

a1f3c9e memory: +1 ~0 -0 (codex: on-call)

7b20d4a memory: +1 ~0 -0 (claude-code: plan)

You browse and edit it in mem ui
Your other machines through a private remote, if you add one
Why it holds up

Plain files, clear rules, nothing to run

Shared by both tools

A preference you gave Codex is there the next time Claude Code starts, and the other way round. Each tool's own memory is turned off, so there is one source.

Files you can read

Each memory is a Markdown file with a short frontmatter. Grep it, edit it, review it in a pull request; its history is plain git log.

Loads what matters here

Global memories load everywhere. Project memories load only in the folder or repository they came from, and in its other clones and worktrees.

Work and home, kept apart

Keep one area's memories from shaping another's: each profile is its own repository, with its own remote or none. Switch in one click, and running sessions follow with their next message.

Git all the way

Memories live in a git repository you own, and every change is a commit you can review or revert. Push to a private remote to sync machines, or keep it all on one. See an example.

Local by default

No service and no account. Search by meaning uses a small embedding model on your CPU; the network is only git and an optional update check.

mem ui

A page to keep it tidy

Run mem ui to search, read and edit memories in a local page. Every change is a git commit, with Undo.

  • Search by words and by meaning, across Chinese and English.
  • Filter by type, place, source, keyword, date and status.
  • Insights: changes week by week, near-duplicates side by side, and the index a session would get.
  • Settings for profiles, sync, keywords, the local model and one-click updates.
127.0.0.1:8790/#/insights
mem ui Insights: totals, memories added per week by type, where memories load and which tool wrote them
Get started

Set up in a few minutes

You need Python 3.11 or newer, git and uv. Every step that edits your tools' settings shows a diff first.

Codex asks you to trust new hooks once: open /hooks in Codex and enable the three agent-memory hooks. The docs list every file mem install changes, and mem uninstall puts them back.

uv tool install "agent-memory-git[ui]"
mem init ~/repos/agent-memory-data   # your data repository
mem import claude --dry-run          # optional: existing memories
mem import codex --dry-run
mem install --dry-run                # every change, as a diff
mem install

Or look around first, with nothing installed:

uvx --from "agent-memory-git[ui]" mem ui --demo