graymatter
AGENTS.md478 starsChanged 58 days agoMITView on GitHub
If you're an AI agent (Claude Code, OpenCode, Codex, Cursor, Antigravity, custom MCP client) operating in this repo, read this first. Full operational manual: docs/AGENTS.md. This repo is a memory system for AI agents. While you work here, you also get to use it: it's wired into your MCP toolbelt as seven tools that persist facts and checkpoints across sessions. memory_reflect uses agent_id (canonical since ADR-014). The other six also use agent_id. The deprecated alias agent is still accepted for…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- docs/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 35
Search and batch accept min_confidence before ranking and top-k, and a finite confidence_weight in [0, 0.5].
- Very specific: line 42
Do not supply confidence on forget/pin/unpin/link, or search options on writes.
- Distinctive: line 56
Before the first substantive reply, inspect only the newest hook block available for the session's initial turn.
- Very specific: line 61
If that id differs from the agent_id you would search, run both project and __shared__ searches.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
If you're an AI agent (Claude Code, OpenCode, Codex, Cursor, Antigravity, custom MCP client) operating in this repo, read this first. Full operational manual:
docs/AGENTS.md.
This repo is a memory system for AI agents. While you work here, you also get to use it: it's wired into your MCP toolbelt as seven tools that persist facts and checkpoints across sessions.
Your tools
| Tool | Required params | Optional |
memory_search | agent_id, query | top_k (default 8), explain (boolean, default false), min_confidence, confidence_weight |
memory_search_batch | agent_id, queries | top_k (default 8), min_confidence, confidence_weight |
memory_add | agent_id, text | confidence |
memory_alias | agent_id, term, equivalents | — |
memory_reflect | action (add|update|forget|link|pin|unpin), plus at least one of agent_id (canonical) or agent (deprecated alias; agent_id wins when both are set) | text, target (which one is required depends on action — for forget/pin/unpin, either works) |
checkpoint_save | agent_id | state (JSON-encoded string) |
checkpoint_resume | agent_id | on_missing (enum error|empty, default error) |
memory_reflectusesagent_id(canonical since ADR-014). The other six also useagent_id. The deprecated aliasagentis still accepted for compatibility;agent_idwins when both are set.
memory_reflect also accepts confidence for add and update only.
<a id="confidence-options-unreleased"></a>
Confidence options
These options are available since v0.20.0 and are absent from v0.19.1.
verified, inferred and unverified are the writer's declarations, not
verification performed by GrayMatter. An omitted label on add remains legacy
inferred; an omitted label on update is the minimum of inferred and the
effective confidence of every live target. A revision does not inherit a pin.
Generated summaries follow that same conservative rule; facts produced by
LLM extraction are unverified. Pin, decay and access tracking preserve labels.
Search and batch accept min_confidence before ranking and top-k, and a finite
confidence_weight in [0, 0.5]. The default remains zero. Explicit zero
preserves an explicit filter. A filter suppresses graph neighbor hints, which
have no confidence receipts. New options require a supporting daemon; an
unsupported request reports an update/restart error. Read the effective policy
and final score from retrieval metadata and explain, not just the label.
Do not supply confidence on forget/pin/unpin/link, or search options on writes. Explicit null, empty labels, unknown labels and incorrect types are errors. See the complete contract.
When to call which
- At session start, check
checkpoint_resumebefore searches when work may have been interrupted. - Before the first substantive reply, pull project and
__shared__context unless the session's newest startup hook block can safely supply it as described below. - After learning a user preference, project convention, or making a non-obvious decision →
memory_add. - When the user corrects you or a fact becomes stale →
memory_reflectwithaction="update"andtarget=<old fact text>. - Before stopping mid-task →
checkpoint_save.
First calls
Before the first substantive reply, inspect only the newest hook block
available for the session's initial turn; ignore quoted examples and blocks
from older turns. A real recall block begins with a bracketed GrayMatter
hook-recall marker naming its agent_id.
If that id differs from the agent_id you would search, run both project and
__shared__ searches; cross-namespace dedup may have put a shared duplicate
under ## Memory. When the ids match, reuse each non-empty section and run the
search for every missing section. This does not suppress checkpoint_resume,
focused or batch searches, writes, reflections, aliases, or checkpoint saves.
With no fresh block, pull both scopes before replying:
{ "tool": "memory_search", "args": {
"agent_id": "<project>-<your-role>",
"query": "<the task the user just asked you to do>",
"top_k": 8
}}
{ "tool": "memory_search", "args": {
"agent_id": "__shared__",
"query": "<the task the user just asked you to do>",
"top_k": 5
}}Inject the returned or hook-supplied facts into your working context before composing your reply.
Identity
Pick a stable agent_id of the form <project>-<role> (e.g. graymatter-backend, okuna-frontend). Don't invent a new ID per session — that defeats persistence.
Shared facts (__shared__)
Project-wide rules — conventions every agent in this repo should respect — go in the reserved namespace __shared__. Pass it as agent_id exactly like any other ID:
{ "tool": "memory_add", "args": {
"agent_id": "__shared__",
"text": "Project convention: all timestamps stored as UTC ISO-8601"
}}To get both your agent-specific facts and shared facts, issue two memory_search calls (one with your own agent_id, one with __shared__) and merge the results. Before the first reply, skip a routine call only when a same-id initial hook block supplies its matching non-empty section.
Don't store
- Conversation logs ("user said X, I said Y") — store the conclusion, not the dialogue
- Transient state (current file, line numbers, ephemeral debug values) — that's what
checkpoint_saveis for - Over-specific facts ("fixed bug at line 47 on 2026-04-15") — generalise to the lesson ("auth.js: JWT validation fails when clock skew > 5 min")
- Secrets, credentials, API keys — never
- Things already in code, README, or this file
Working in this codebase
- Go workspace with a library module and a CLI module. Build both with
go build ./...andgo build ./cmd/graymatterfrom the root. Rungo test ./...at the root and again incmd/graymatter/; the root pattern does not include the nested CLI module. The workspace requires Go 1.25.5 or newer, and CI runs Ubuntu / macOS / Windows × Go 1.25 / 1.26.7. - bbolt is single-writer, but daemon mode handles that: a store daemon owns the lock and every
graymatterprocess connects to it as a client, so concurrent TUI/MCP/CLI access works. Clients auto-start the daemon and it idle-exits when unused.--no-daemonopts out (and reintroduces the lock contention). Resolved issue #8.
More
For RRF retrieval mechanics, anti-patterns, full session-start/end checklists, decay/consolidation defaults, and the CLI parity table: docs/AGENTS.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

