Three lines of code to give your AI agents persistent memory. Reduce 90% token consumption while also maintaining quality.
$git clone https://github.com/angelnicolasc/graymatterInstalls into the current project.
Install graymatter by running `git clone https://github.com/angelnicolasc/graymatter`, then use it for the current task and follow its documentation at https://github.com/angelnicolasc/graymatter.
| 1 | <div align="center"> |
| 2 | <img width="1500" height="276" alt="graymatter-banner" src=".github/assets/graymatter-banner-1.jpg" /> |
| 3 | </div> |
| 4 | |
| 5 | <h1 align="center"> GrayMatter </h1> |
| 6 | |
| 7 | |
| 8 | <p align="center"> |
| 9 | <a href="https://github.com/angelnicolasc/graymatter/actions/workflows/ci.yml"><img src="https://github.com/angelnicolasc/graymatter/actions/workflows/ci.yml/badge.svg" alt="CI"></a> |
| 10 | <a href="https://pkg.go.dev/github.com/angelnicolasc/graymatter"><img src="https://pkg.go.dev/badge/github.com/angelnicolasc/graymatter.svg" alt="Go Reference"></a> |
| 11 | <a href="https://github.com/angelnicolasc/graymatter/releases/tag/v0.6.0"><img src="https://img.shields.io/github/v/release/angelnicolasc/graymatter" alt="Latest Release"></a> |
| 12 | <img src="https://img.shields.io/badge/coverage-73.5%25-brightgreen" alt="Coverage 73.5%"> |
| 13 | <img src="https://img.shields.io/badge/platforms-linux%20%7C%20macOS%20%7C%20windows-blue" alt="Platforms"> |
| 14 | <img src="https://goreportcard.com/badge/github.com/angelnicolasc/graymatter" alt="Go Report Card"> |
| 15 | <img src="https://img.shields.io/github/license/angelnicolasc/graymatter" alt="License"> |
| 16 | <div align="center"> |
| 17 | <br /> |
| 18 | |
| 19 | <strong>Three lines of code to give your AI agents persistent memory and cut token usage by 90%.</strong> |
| 20 | <br /><br /> |
| 21 | One binary. Drop it in. Run it. No Docker, no databases, no config files, no cloud accounts, no bullshit. |
| 22 | <br /><br /> |
| 23 | <strong>General-purpose MCP server. Zero vendor lock-in.</strong> |
| 24 | <br /> |
| 25 | Works with Claude Code, Cursor, Codex, OpenCode, Antigravity — and any MCP-compatible client. |
| 26 | <br /> |
| 27 | Also a plain Go library if you don't use MCP. |
| 28 | <br /><br /> |
| 29 | Free. Offline. No account required. |
| 30 | |
| 31 | <br /> |
| 32 | </div> |
| 33 | |
| 34 | ```go |
| 35 | ctx := context.Background() |
| 36 | mem := graymatter.New(".graymatter") |
| 37 | mem.Remember(ctx, "agent", "user prefers bullet points, hates long intros") |
| 38 | facts, _ := mem.Recall(ctx, "agent", "how should I format this response?") |
| 39 | // ["user prefers bullet points, hates long intros"] |
| 40 | ``` |
| 41 | |
| 42 | --- |
| 43 | |
| 44 | ## Why |
| 45 | |
| 46 | Every AI agent is **stateless by default**. Each run re-injects the full |
| 47 | conversation history — and that history grows linearly. Two prompts in and you've already burned half of your daily quota. |
| 48 | |
| 49 | That's not just a memory problem. That's a money and performance problem. |
| 50 | |
| 51 | |
| 52 | **Mem0, Zep, Supermemory** solve this — but they're Python/TypeScript-only |
| 53 | and require a running server. The Go ecosystem has no production-ready, |
| 54 | embeddable, zero-dependency memory layer for agents. |
| 55 | |
| 56 | That gap is GrayMatter. |
| 57 | |
| 58 | <p align="center"> |
| 59 | <img src=".github/assets/token-reduction-chart1.jpg" alt="GrayMatter-Chart1" width="800px" style="max-width: 900px;"> |
| 60 | </p> |
| 61 | |
| 62 | |
| 63 | <p align="center"> |
| 64 | <strong>~97% reduction in context tokens</strong> — versus full-history injection.<br> |
| 65 | Context quality <em>improves</em> over time as consolidation surfaces only what matters.<br> |
| 66 | No Docker. No Redis. No API key required for storage.<br><br> |
| 67 | Drop it in once. It auto-connects to <strong>Claude Code, Cursor, Codex, OpenCode, Antigravity</strong> — any MCP-compatible client picks it up automatically. |
| 68 | </p> |
| 69 | |
| 70 | --- |
| 71 | |
| 72 | ## Observability |
| 73 | |
| 74 | You can't improve what you can't see. |
| 75 | |
| 76 | `graymatter tui` opens a live terminal dashboard with everything your |
| 77 | agent memory is doing — no extra setup required. |
| 78 | |
| 79 | <p align="center"> |
| 80 | <img src=".github/assets/tui-graymatter.jpg" alt="GrayMatter-TUI" width="900px" style="max-width: 900px;"> |
| 81 | </p> |
| 82 | |
| 83 | **What you get at a glance:** |
| 84 | |
| 85 | - **Facts** — total stored, distributed across agents |
| 86 | - **Memory cost** — KB on disk (text + embeddings), not tokens |
| 87 | - **Recalls** — cumulative access count across all sessions |
| 88 | - **Health** — percentage of facts above relevance threshold (weight > 0.5) |
| 89 | - **Token cost (30d)** — real spend breakdown by model, with cache hit rate |
| 90 | - **Agent activity** — facts vs recalls per agent, side by side |
| 91 | - **Weight distribution** — how consolidated your memory is over time |
| 92 | - **Activity timeline** — facts created per day, last 30 days |
| 93 | |
| 94 | The dashboard auto-refreshes every 5 seconds. Press `1–4` to switch tabs, |
| 95 | `r` to force refres |