Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

docs(prompts): default every command to the current project unless told otherwise

AkitaOnRailseadd4d932a65
diff --git a/CLAUDE.md b/CLAUDE.md
index 434861ef..69e83e25 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -232,10 +232,23 @@ Live progress is tracked via the TaskList tool inside Claude Code sessions.
## Long-term memory (ai-memory)
This project uses [ai-memory](https://github.com/akitaonrails/ai-memory)
-for cross-session continuity. **Lifecycle hooks already capture every
-prompt + tool call automatically.** You never need to manually write
-routine notes; the SessionStart hook auto-fetches pending handoffs, and
-on session end ai-memory writes a session-summary page and a handoff.
+for cross-session continuity.
+
+**Default to the current project — always.** Every ai-memory tool
+auto-scopes to the project resolved from your session's working
+directory. **Do NOT pass `project` or `cwd` arguments unless the user
+explicitly references a *different* project by name** (e.g. "what did we
+decide in the `other-app` project?"). Phrases like "this project",
+"here", "we", "our work", "where did we leave off" all mean the *current*
+project — call the tool with no scoping args. If the user asks about a
+handoff and the SessionStart auto-fetched block is already in your
+context, just answer from it; do not re-call the tool to "find it again"
+in another project.
+
+**Lifecycle hooks already capture every prompt + tool call
+automatically.** You never need to manually write routine notes; the
+SessionStart hook auto-fetches pending handoffs, and on session end
+ai-memory writes a session-summary page and a handoff.
LLM consolidation (compiling observations into topical wiki pages) runs
on PreCompact, on demand via `memory_consolidate`, and at session end
only when the server sets `AI_MEMORY_CONSOLIDATE_ON_SESSION_END`. Only
diff --git a/crates/ai-memory-core/src/routing_snippet.rs b/crates/ai-memory-core/src/routing_snippet.rs
index 0a291838..0c6dcf98 100644
--- a/crates/ai-memory-core/src/routing_snippet.rs
+++ b/crates/ai-memory-core/src/routing_snippet.rs
@@ -30,10 +30,23 @@ pub const SNIPPET_BODY: &str = r#"
## Long-term memory (ai-memory)
This project uses [ai-memory](https://github.com/akitaonrails/ai-memory)
-for cross-session continuity. **Lifecycle hooks already capture every
-prompt + tool call automatically.** You never need to manually write
-routine notes; the SessionStart hook auto-fetches pending handoffs, and
-on session end ai-memory writes a session-summary page and a handoff.
+for cross-session continuity.
+
+**Default to the current project — always.** Every ai-memory tool
+auto-scopes to the project resolved from your session's working
+directory. **Do NOT pass `project` or `cwd` arguments unless the user
+explicitly references a *different* project by name** (e.g. "what did we
+decide in the `other-app` project?"). Phrases like "this project",
+"here", "we", "our work", "where did we leave off" all mean the *current*
+project — call the tool with no scoping args. If the user asks about a
+handoff and the SessionStart auto-fetched block is already in your
+context, just answer from it; do not re-call the tool to "find it again"
+in another project.
+
+**Lifecycle hooks already capture every prompt + tool call
+automatically.** You never need to manually write routine notes; the
+SessionStart hook auto-fetches pending handoffs, and on session end
+ai-memory writes a session-summary page and a handoff.
LLM consolidation (compiling observations into topical wiki pages) runs
on PreCompact, on demand via `memory_consolidate`, and at session end
only when the server sets `AI_MEMORY_CONSOLIDATE_ON_SESSION_END`. Only
diff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rs
index 80225478..ff93c381 100644
--- a/crates/ai-memory-mcp/src/server.rs
+++ b/crates/ai-memory-mcp/src/server.rs
@@ -24,12 +24,24 @@ use serde::{Deserialize, Serialize};
/// the agent can route natural-language requests without the user
/// having to know the tool name or schema.
pub const MEMORY_INSTRUCTIONS: &str = "\
-Long-term memory for the current project. Lifecycle hooks already \
-capture every prompt + tool call automatically — you do NOT need to \
-write routine notes by hand. When the user explicitly asks to remember \
-a permanent annotation/fact/rule, write a durable wiki page; do not use \
-a handoff for that. Use these tools when the conversation calls for \
-them:\n\
+Long-term memory for the current project.\n\
+\n\
+**Default to the current project — always.** Every tool here \
+auto-scopes to the project resolved from your session's working \
+directory. **Do NOT pass `project` or `cwd` arguments unless the user \
+explicitly references a *different* project by name** (e.g. 'what did \
+we decide in the other-app project?'). Phrases like 'this project', \
+'here', 'we', 'our work', 'where did we leave off' all mean the \
+*current* project — call the tool with no scoping args. If the user \
+asks about a handoff and the SessionStart auto-fetched block is already \
+in your context, answer from it; do NOT re-call the tool to look for it \
+in another project.\n\
+\n\
+Lifecycle hooks already capture every prompt + tool call automatically \
+— you do NOT need to write routine notes by hand. When the user \
+explicitly asks to remember a permanent annotation/fact/rule, write a \
+durable wiki page; do not use a handoff for that. Use these tools when \
+the conversation calls for them:\n\
\n\
- `memory_query` — when the user references prior work you don't \
recognise, or asks 'have we done / discussed X', or you're about \
@@ -129,7 +141,7 @@ struct QueryArgs {
#[serde(default, alias = "n", alias = "top_k")]
limit: Option<usize>,
/// Project to search. Omit to target the project you're currently
- /// working in (resolved from recent hook activity). Only needed when
+ /// working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.** Only needed when
/// one shared server fields several projects at once.
#[serde(default)]
project: Option<String>,
@@ -141,7 +153,7 @@ struct RecentArgs {
#[serde(default, alias = "n")]
limit: Option<usize>,
/// Project to read. Omit to target the project you're currently
- /// working in (resolved from recent hook activity).
+ /// working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -149,7 +161,7 @@ struct RecentArgs {
#[derive(Debug, Serialize, Deserialize, schemars::JsonSchema)]
struct StatusArgs {
/// Project to report counts for. Omit to target the project you're
- /// currently working in (resolved from recent hook activity).
+ /// currently working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -220,7 +232,7 @@ struct HandoffBeginArgs {
#[serde(default)]
cwd: Option<String>,
/// Project to scope the handoff to. Omit to target the project you're
- /// currently working in (resolved from recent hook activity).
+ /// currently working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -228,10 +240,13 @@ struct HandoffBeginArgs {
#[derive(Debug, Serialize, Deserialize, schemars::JsonSchema)]
struct HandoffAcceptArgs {
/// Restrict the search to handoffs created for a specific cwd.
+ /// **Omit unless the user explicitly asks about a handoff from a
+ /// *different* directory** — by default this scopes to the current
+ /// project (the SessionStart hook usually pre-fetches it into context).
#[serde(default)]
cwd: Option<String>,
/// Project to accept a handoff from. Omit to target the project you're
- /// currently working in (resolved from recent hook activity).
+ /// currently working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -242,7 +257,7 @@ struct BriefingArgs {
#[serde(default)]
recent_pages_limit: Option<usize>,
/// Project to brief on. Omit to target the project you're currently
- /// working in (resolved from recent hook activity).
+ /// working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -259,7 +274,7 @@ struct ExploreArgs {
#[serde(default)]
recent_pages_limit: Option<usize>,
/// Project to explore. Omit to target the project you're currently
- /// working in (resolved from recent hook activity).
+ /// working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}
@@ -283,7 +298,7 @@ struct WritePageArgs {
#[serde(default)]
pinned: bool,
/// Project to write into. Omit to target the project you're currently
- /// working in (resolved from recent hook activity).
+ /// working in (resolved from recent hook activity). **Omit unless the user explicitly names a *different* project.**
#[serde(default)]
project: Option<String>,
}