m3-memory
CLAUDE.md30 starsChanged 42 days agoApache-2.0View on GitHub
Persistent state is split across three roots so the engine (databases) and the configuration can live and be secured independently. Only the config root is located from the environment; every other root comes from [paths] in m3_config.toml (owner: m3_memory._roots): - Config root — --config <file> > M3_CONFIG_ROOT > ~/.m3/config. Holds m3_config.toml, .chatlog_config.json, .migrate_config.json, .agent_os_salt. - Engine root — [paths] engine_root, else <memory_root>/engine when [paths] memory_root is set, else ~/.m3/engine. Holds agent_memory.db, agent_chatlog.db, chatlog state/cursor, spill dir. - Logs root —…
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agentsAGENTS.md
- docs/AGENTS.mdAGENTS.md
- m3-guideSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 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.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 3
NOT instructions for the agent working in this repo, and it is deliberately NOT an @-import - at 750+ lines it would load into every …
- Very specific: line 4
NOT an @-import - at 750+ lines it would load into every session for no benefit and push this file far past the 200-line target.
- Distinctive: line 9
Commit Messages: Do NOT include "Co-Authored-By" lines in commit messages.
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.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
<!-- `docs/AGENT_INSTRUCTIONS.md` is PUBLISHED MATERIAL FOR ADOPTERS: a menu of
agent-setup guidance for people installing m3, to cut and choose from. It is
NOT instructions for the agent working in this repo, and it is deliberately
NOT an `@`-import - at 750+ lines it would load into every session for no
benefit and push this file far past the 200-line target. Mentioned here in a
comment so the path cannot be mistaken for a directive. -->Git Standards
- Commit Messages: Do NOT include "Co-Authored-By" lines in commit messages. Focus on clear, concise descriptions of "why" and "what".
- Pre-push process (MANDATORY, all agents): After cloning, run
python bin/setup_hooks.pyonce to enable the shared pre-push gate. Before any push, the tool-catalog drift check (python bin/check_tool_catalog_drift.py) and bench-data leakage scan must pass. If you changebin/mcp_tool_catalog.py, regenerate the catalog/inventory and update the "N tools" counts in the same change. Full rationale: the "Pre-push process — ALL agents" section indocs/AGENT_INSTRUCTIONS.md. This is enforced by the local hook AND CI, not just convention. The leakage scan runs inpython3and compiles each prohibited pattern independently — do NOT fold it back into onegrep -E, where a single pattern the platform's grep rejects disables the whole policy while still printing "no leakage detected". To confirm the gate is alive on this box:python bin/prepush/scan_diff.py --selftest --patterns <policy>(exits non-zero if the policy will not compile). - Edited anything under
bin/? Runpython bin/gen_tool_inventory.py. Eachbin/script has a generated page underdocs/tools/stamped with a hash of its source, andtests/test_generated_docs_fresh.py::test_tool_pages_are_freshfails when the source moves without the page. This is a THIRD generator, separate fromgen_tool_manifest.pyandgen_mcp_inventory.py(which cover the MCP catalog), and neither the pre-push hook norcheck_tool_catalog_drift.pyruns it — only the full suite catches it, at the end of a ~5.5-minute run. Cheapest habit: regenerate right after the edit, not after the failure. (Hit three times in one session, 2026-09-08.) - Cutting a release (version bump): The version has ONE source of truth —
pyproject.toml[project].version. Do NOT hand-edit version strings in the derived manifests. Instead: (1) bumppyproject.toml, (2) runpython bin/sync_manifest_versions.py— it writes the new version into every derived manifest (server.json,mcp-server.json,.claude-plugin/plugin.json,plugins/antigravity/plugin.json,plugins/codex/.codex-plugin/plugin.json,gemini-extension.json; the plugin manifests are served straight frommainto every user's/plugin install), plus the README's PyPI badge (docs/badges/pypi-version.svg) and SECURITY.md's "Supported Versions" row, (3) commit all together.tests/test_tool_count_drift.py::test_all_manifests_synced_to_pyproject_version(runs--check) fails the build if you skip step 2, so a stale manifest can't ship. Plugin manifest descriptions say "100+ MCP tools", never an exact count (also test-guarded).
Homecoming Architecture (decoupled roots)
Persistent state is split across three roots so the engine (databases) and
the configuration can live and be secured independently. Only the config root is
located from the environment; every other root comes from [paths] in
m3_config.toml (owner: m3_memory._roots):
- Config root —
--config <file>>M3_CONFIG_ROOT>~/.m3/config. Holdsm3_config.toml,.chatlog_config.json,.migrate_config.json,.agent_os_salt. - Engine root —
[paths] engine_root, else<memory_root>/enginewhen[paths] memory_rootis set, else~/.m3/engine. Holdsagent_memory.db,agent_chatlog.db, chatlog state/cursor, spill dir. - Logs root —
[paths] logs_root(same fallbacks,/logs), default~/.m3/logs(m3_core.paths.get_m3_logs_root). Never under the payload — a reinstall wipes it.
M3_ENGINE_ROOT, M3_LOGS_ROOT and M3_MEMORY_ROOT are not read (nor any
other setting's env name); m3 doctor names any still set. M3_HOME is
retired (2026.10.19.0): hooks locate the payload from their own path.
M3_LIB_DIR locates the wolfSSL library ([paths] lib_dir is the setting).
Migration
bin/homecoming.py relocates legacy state (repo-relative memory/* or the old
unified ~/.m3-memory/) into the decoupled roots. It rewrites the chatlog
config's pinned db_path to the new engine root (a verbatim copy would leave the
chatlog pointing at the old path), and prints a post-migration checklist.
Split-brain hazard (read before changing roots)
With the default config root (~/.m3/config) nothing needs pinning: every
process finds the same m3_config.toml. With a non-default config root, two
env paths must BOTH carry M3_CONFIG_ROOT or the system splits: the MCP
server reads it from its own registration's env block (NOT from ~/.zshenv),
while the chatlog Stop/PreCompact hook inherits the agent's process env (NOT
the server env block). Pinning only one makes the server read one config (and
its stores) while the hook writes turns through the other. Fix: set
M3_CONFIG_ROOT in the server registration's env AND inline-prefix both hook
commands with it. m3 doctor reports the config file in use and every surface
that names another root or lacks the pin.
Where the server env lives is agent-specific — and Claude Code is the
exception. Claude Code does NOT read MCP server definitions from
~/.claude/settings.json (only ~/.claude.json, .mcp.json, and plugins are
honored). So m3's Claude memory server is registered via
claude mcp add --scope user m3_memory m3 [--env M3_CONFIG_ROOT=…] (written to
~/.claude.json; the --env only for a non-default config root) — that --env
is where Claude's server config root must go, NOT a settings.json mcpServers block (which Claude
ignores; generate_configs no longer writes one). The m3 plugin alternative
carries the config root via its userConfig (${user_config.config_root});
m3 setup keeps the plugin's server disabled (disabledMcpServers +=
plugin:m3:memory — written atomically with the claude mcp add, not only via
the hooks writer) so only the direct mcp__m3_memory__ server runs. That
disable is a one-shot write, so a LATER /plugin install m3 re-enables the
plugin server behind m3's back → two live servers (double payload load, split
mcp__m3_memory__ / mcp__plugin_m3_memory__ namespace). claude_mcp_probe
(the m3 doctor "one m3 server, not two" check) is the only thing that catches
that; m3 doctor --fix --fix-hooks converges back to one. For
Gemini/Antigravity/Cursor/Cline a non-default M3_CONFIG_ROOT DOES go in the env block of the
memory entry in their own config files (those ARE read). settings.json hooks
and statusLine ARE read for Claude — only mcpServers is not.
Claude Code reloads hooks live but re-resolves server env only on restart — a
mid-session pin diverges the two chatlog DBs; reconcile with a UNION merge
(INSERT OR IGNORE), never an overwrite.
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.

