Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
docs(routing): CLAUDE.md must import AGENTS.md to load it (#680)
Felipe Neves Ricardoa091c6c85803
diff --git a/AGENTS.md b/AGENTS.mdindex 5501c0c7..6192afa5 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -70,6 +70,11 @@ Many projects use CLAUDE.md for Claude Code andAGENTS.md for Codex / OpenCode / OpenCode 2 / Cursor / Gemini CLI / Grok Build CLI / Kimi Code / Kiro CLI / Command Code,but if the project says one file is canonical, use that file.+Claude Code loads `CLAUDE.md` and does not read `AGENTS.md`. In a project+where `AGENTS.md` is canonical, give `CLAUDE.md` a bare `@AGENTS.md` import+line. Without it a rule written to `AGENTS.md` is absent from context at+session start and reaches Claude Code only if the agent opens the file.+If the rule is a standing *user/team* preference that should apply toevery project (tech choices, code style, personal conventions), save itto ai-memory's reserved global scope instead — the durable-pages skilldiff --git a/CHANGELOG.md b/CHANGELOG.mdindex dbec8a60..6530cf68 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Changed+- The managed routing snippet now states that Claude Code loads `CLAUDE.md` and+ does not read `AGENTS.md`: a project whose canonical instruction file is+ `AGENTS.md` needs a bare `@AGENTS.md` import line in `CLAUDE.md`, or the rules+ written there are absent from context at session start and reach the agent only+ if it opens the file. `docs/install.md` and `docs/usage.md` carry the same note+ beside the `--target AGENTS.md` guidance, and this repository's own `CLAUDE.md`+ now uses the import instead of a prose pointer (#680).+### Fixed- Wiki auto-commits stage what the wiki wrote instead of walking thewhole tree, keep the repository open between commits, and no longerdiff --git a/CLAUDE.md b/CLAUDE.mdindex 113043a9..e7a5f290 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1,7 +1,14 @@-# Claude Code Instructions-Read and follow [`AGENTS.md`](AGENTS.md). This repository keeps a single-canonical agent instruction file for Claude Code, OpenCode, Codex, Cursor,-Gemini CLI, and other AGENTS-aware harnesses.+<!--+Claude Code reads CLAUDE.md and does not read AGENTS.md, so the import on the+first line is what loads this repository's canonical instruction file into a+Claude Code session: https://code.claude.com/docs/en/memory#agents-md-Do not duplicate project rules here. Update `AGENTS.md` instead.+A prose "read AGENTS.md" pointer loads nothing at session start; it asks the+agent to open the file, which leaves adherence to whether it does.++Do not duplicate project rules here. Update AGENTS.md instead. Add content+below the import only when it is specific to Claude Code and has no AGENTS.md+counterpart.+-->diff --git a/crates/ai-memory-core/src/routing_snippet.rs b/crates/ai-memory-core/src/routing_snippet.rsindex bd2149e9..5ee57156 100644--- a/crates/ai-memory-core/src/routing_snippet.rs+++ b/crates/ai-memory-core/src/routing_snippet.rs@@ -98,6 +98,11 @@ Many projects use CLAUDE.md for Claude Code andAGENTS.md for Codex / OpenCode / OpenCode 2 / Cursor / Gemini CLI / Grok Build CLI / Kimi Code / Kiro CLI / Command Code,but if the project says one file is canonical, use that file.+Claude Code loads `CLAUDE.md` and does not read `AGENTS.md`. In a project+where `AGENTS.md` is canonical, give `CLAUDE.md` a bare `@AGENTS.md` import+line. Without it a rule written to `AGENTS.md` is absent from context at+session start and reaches Claude Code only if the agent opens the file.+If the rule is a standing *user/team* preference that should apply toevery project (tech choices, code style, personal conventions), save itto ai-memory's reserved global scope instead — the durable-pages skill@@ -228,7 +233,8 @@ mod tests {/// (`ai-memory install-instructions --target AGENTS.md`) and committed/// separately, so nothing forces it to track [`SNIPPET_BODY`]. This guard/// fails when the two drift — regenerate to fix it. Only `AGENTS.md` is- /// checked (root `CLAUDE.md` is a pointer; `README.md` is prose).+ /// checked (root `CLAUDE.md` imports it with `@AGENTS.md` and carries no+ /// block of its own; `README.md` is prose).#[test]fn committed_agents_md_matches_snippet_body() {// From `crates/ai-memory-core` up to the repo root.diff --git a/docs/install.md b/docs/install.mdindex 70273c66..a5c1af96 100644--- a/docs/install.md+++ b/docs/install.md@@ -124,6 +124,12 @@ legacy long snippets between `<!-- ai-memory:start -->` /`<!-- ai-memory:end -->` are replaced in place with the slim snippet, andmanaged Agent Skills are installed or updated alongside it.+If you install into `AGENTS.md` and the project is also used from Claude Code,+make `CLAUDE.md` import it with a bare `@AGENTS.md` first line. Claude Code+loads `CLAUDE.md` and does not read `AGENTS.md`, so without that import the+installed block is absent from context at session start. See+[Claude Code memory](https://code.claude.com/docs/en/memory#agents-md).+---## Configuring the CLI URL and authdiff --git a/docs/usage.md b/docs/usage.mdindex 5ef245cc..6403d8c9 100644--- a/docs/usage.md+++ b/docs/usage.md@@ -229,6 +229,15 @@ instruction target unless you override it: `CLAUDE.md` impliesboth skill roots. For Grok Build CLI, select `--skills-agent grok` so skillsinstall under its `.grok/skills` root.+When a project keeps `AGENTS.md` as its canonical instruction file, give it a+`CLAUDE.md` whose first line is a bare `@AGENTS.md` import. Claude Code loads+`CLAUDE.md` and does not read `AGENTS.md`, so without that import a block+installed with `--target AGENTS.md`, along with every project rule in the same+file, is absent from context at session start. A prose "read AGENTS.md" pointer+does not load the file; it asks the agent to open it, which leaves adherence to+whether the agent does. See+[Claude Code memory](https://code.claude.com/docs/en/memory#agents-md).+To refresh only the managed Agent Skills:```bash