gitmem
Provides MCP tools that give AI agents persistent, append-only memory in a git repository, letting them record observations, decisions, and corrections while retrieving context briefs, current facts, conflicts, and traceable event history without a vector database.
README
gitmem
Persistent, reviewable memory for your AI agents — in a git repo you can read, diff, and blame.
Your coding agent forgets everything between sessions. gitmem gives it an append-only event log of facts, decisions, and corrections, stored as plain JSONL in git, with deterministic projections: a token-budgeted brief to inject into context, a current-facts view, and a conflict queue that surfaces contradictions instead of silently overwriting them.
No vector store. No LLM calls. No server. A memory system you can git log.
<p align="center"><img src="assets/demo.svg" alt="gitmem demo" width="780"></p>
Installation
Install from npm:
npm install -g @josephy02/gitmem
Or, if you are developing or setting up the Claude Code plugin, clone the repository and install it locally:
git clone https://github.com/josephy02/gitmem.git
cd gitmem
npm install # builds automatically
npm link # puts `gitmem` on your PATH
Verify the install:
gitmem --help
60-second quickstart
gitmem init --root ./memory
gitmem --root ./memory append --scope team/core --kind decision \
--body "Mobile still depends on the old auth module; do not refactor." \
--author human:joseph
gitmem --root ./memory append --scope team/core \
--body "The staging DB is reset every Sunday 03:00 UTC." \
--author agent:builder-3
gitmem --root ./memory brief # the context bootstrap, capped at 1,500 tokens
gitmem --root ./memory facts --json # current-value view, NDJSON
gitmem --root ./memory conflicts # contradictions, surfaced never auto-resolved
gitmem --root ./memory commit # git commit of the log, on your cadence
Or explore the bundled demo — 45 realistic events with corrections, a retraction, a promotion, and a live conflict:
gitmem --root /tmp/demo init
gitmem --root /tmp/demo append --json --force - < demo/events.ndjson
gitmem --root /tmp/demo brief
How it works
flowchart LR
subgraph writers[" "]
CLI[CLI / library]
MCP[MCP client<br/>Claude Code etc.]
end
CLI -->|append| LOG
MCP -->|memory_append| LOG
LOG[("log/YYYY/MM/DD.jsonl<br/>append-only, in git")]
LOG -->|pure function| PROJ[projections]
PROJ --> BRIEF["brief.md<br/>≤1500 tokens"]
PROJ --> FACTS["facts.json<br/>live/superseded/contested"]
PROJ --> CONF["conflicts.json<br/>never auto-resolved"]
LOG -.->|every read| CHOKE{{"readEvents()<br/>capability choke point"}}
CHOKE --> BRIEF & FACTS & CONF
GIT[git history] -->|"gitmem stale"| FACTS
- The log is the only source of truth. One event per line in
log/YYYY/MM/DD.jsonl. Nothing is ever mutated or deleted — corrections and retractions are new events that supersede old ones, so provenance is always reconstructible (gitmem trace <id>). - Projections are pure functions of the log.
facts.json(current values with live/superseded/retracted/expired/contested status),brief.md(the always-injected core, hard-capped at 1,500 tokens, decisions first),conflicts.json,stats.json.gitmem rebuildis byte-identical to an incremental build — that's a test. - Conflicts are surfaced, never auto-resolved. Deterministic heuristics (divergent corrections, negation pairs, same-subject divergence) flag contradictions; both sides are returned together as
contested. Resolution is a human act: write a correction that supersedes the losers. - Scope is enforced at one choke point. Every read path — search, point-get, brief, trace — goes through a single capability-checked function. Segment-aware:
team/coregrantsteam/core/authbut neverteam/core-secrets. Promotions change a fact's effective scope, and access control follows the effective scope, so narrowing actually narrows. - Git-native for real.
gitmem initinstalls a union merge driver: two branches appending to the same day file merge automatically — union of lines, sorted by ULID, always correct because events are immutable.gitmem verifycatches duplicate ids from bad merges.
Event format
The format is the product. One JSON object per line, schema in schema/memevent.schema.json — any language can write events without this library:
{"id":"01K2X9...","ts":"2026-08-15T14:03:11.000Z","scope":"team/core","author":{"kind":"human","id":"joseph"},"kind":"decision","body":"Mobile still depends on the old auth module; do not refactor.","derived_from":[],"supersedes":[],"confidence":1}
Five event kinds: observation, decision, correction, retraction, promotion (scope changes are events too — sharing has provenance).
Library
import { GitMem } from "@josephy02/gitmem";
const log = GitMem.open("./memory");
const cap = { principal: "agent:builder-3", scopes: ["team/core"], mode: "read" as const };
log.append({ scope: "team/core", kind: "observation", body: "...", author: { kind: "agent", id: "builder-3" } });
log.brief(cap); // markdown string, reprojects lazily if the log advanced
log.facts(cap, { status: "live" });
log.conflicts(cap);
log.trace(cap, id); // full derivation ancestry
Design commitments
- No LLM in the write path. Writes are cheap, lossless, synchronous.
- No write-time dedup. Contradictions look like near-duplicates; a write-time gate would reject exactly the events the conflict detector needs to see. Everything is admitted; resolution happens at projection time.
brief.override.md— a human-authored file that always wins the top of the brief.- Human-first storage.
git diffa memory change.git blamea fact. Review an agent's memory in a PR.
Claude Code plugin
The fastest way to give Claude Code persistent memory. This repo is a plugin marketplace:
/plugin marketplace add josephy02/gitmem
/plugin install gitmem@gitmem
(Requires the gitmem CLI: npm install -g @josephy02/gitmem.)
What you get:
- Memory brief at session start — a
SessionStarthook injectsgitmem briefinto context, so every session begins knowing your project's decisions and facts. No gitmem root in the project? The hook is a silent no-op. - Memory tools over MCP — Claude can append observations, decisions, and corrections as it works. The root is auto-discovered (
$GITMEM_ROOT,./.gitmem,./memory,./.memory) and auto-initialized on first use. /remember <fact>— save a durable fact or decision, with correction semantics when it contradicts an existing memory./rememberwith no arguments harvests the current conversation./memory-review— walk the conflict queue and stale anchors, and resolve them through the log.
MCP server
Give any MCP client (Claude Code, Claude Desktop, anything speaking MCP) persistent memory in one line:
{
"mcpServers": {
"gitmem": { "command": "gitmem", "args": ["--root", "/path/to/memory", "serve"] }
}
}
Exposes five tools over stdio: memory_append, memory_brief, memory_facts, memory_conflicts, memory_trace. Appends are attributed to agent:mcp by default (--author to change); reads go through the same capability choke point as everything else.
Git-anchored staleness
A fact can anchor itself to code via meta.source_uri (e.g. "src/auth.ts#validateToken"). Because the log lives in git next to the code, staleness detection is just a git log:
gitmem stale # lists live facts whose anchored file changed since the fact was written
[stale?] validateToken always returns true in dev mode
anchor: src/auth.ts#validateToken
changed by:
e1faa27 flip validateToken default
No embeddings, no LLM, no index to maintain — the same property that makes memory reviewable makes it self-invalidating.
Development
npm install
npm run build
npm test # 16 tests incl. property-based scope isolation and a real git-branch merge
Performance: full projection of a 10k-event log runs in ~50ms.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。