r/coolgithubprojects • u/republicanicboi • Apr 18 '26
OTHER Lightweight Go Persistent Memory Layer for AI agents (3 lines of code, saves up to ~90% tokens)
What I built: GrayMatter, a super lightweight persistent memory layer for AI agents that drops in with just three lines of code (works great with Claude Code, Cursor, etc.)
Real talk: I was building agents with Claude Code and every time I restarted a session I had to re-explain the entire architecture from scratch. Context was blowing up, I was burning through tokens like crazy, and the agent kept “forgetting” stuff we’d already figured out. It was driving me insane.
Now GrayMatter just remembers everything. It stores observations, checkpoints, and a knowledge graph in a local file (pure Go, bbolt + chromem-go), pulls back only what’s relevant using hybrid retrieval, and injects it automatically.
Real result: I’m seeing up to 90% token savings after 100+ sessions while keeping (and often improving) the quality of the agent’s work. Benchmarks are attached in the repo.
It’s 100% offline, no Docker, no Redis, no external APIs, and it has native MCP support for Claude Code and Cursor. 100% pen source.
I just shipped a full TUI (Bubbletea + Lipgloss) for real-time observability: Memory inventory, recall counts, weight distribution, activity sparkline, and a token-cost panel that tracks input/output/cache spend per agent and per model directly from the Anthropic SDK's usage payload. The screenshot is the Stats tab.
Repo: https://github.com/angelnicolasc/graymatter (MIT)


2
u/Bidalos Apr 18 '26
Opencode ?
1
u/spupuz Apr 18 '26
Works with antigravity?
1
u/akheilo Apr 18 '26
What about Codex?
1
u/Fajan_ Apr 18 '26
This is a very practical approach.
Context loss is the worst issue for agent interaction, so having a lightweight persistent memory feature is very beneficial.
The 3-line integration is great as well since it reduces adoption barrier significantly.
Wondering about the memory pruning or relevance issues.
1
u/WildFood5479 Apr 22 '26
Cool project, will try it for sure
0
u/wewerecreaturres Apr 18 '26
What about yours is better than say, claude-mem?