Guide
Undo a bad change to your AI agent's memory
Agents that keep memory also rewrite it. A session that misreads a test failure saves "never mock the database" over a rule you wrote on purpose, and every later session follows the new one. In a plain memory file the old line is gone unless you happened to commit the file.
memgit stores each memory as a versioned object and each session's changes as a checkpoint, so the old line is still there. This works in the free local CLI, with no account.
See what changed
memgit log -n 5 memgit diff --full
log lists the recent checkpoints with how many memories each added, changed or removed. diff compares the last two checkpoints; --full prints the rule text before and after. To compare older checkpoints, pass their ids: memgit diff a1d9f3c c3a891f.
Put it back
memgit rollback HEAD~1 --dry-run memgit rollback HEAD~1
--dry-run shows what the store will look like. The rollback itself creates a new checkpoint that matches the earlier state, so nothing is deleted: the bad change stays in the history and you can roll forward again. Use a checkpoint id in place of HEAD~1 to go further back.
Set it up
pip install memgit memgit init
init creates the store, imports the memory Claude Code already keeps and offers to connect Cursor, Codex and Gemini CLI to the same store. Inside Claude Code you can install the plugin instead: /plugin marketplace add code4161/claude-plugins, then /plugin install memgit@memgit.
With sync turned on, a rollback on one machine reaches the others like any other change.