Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
install-skills: honour CLAUDE_CONFIG_DIR for the global claude root
klebervirgilio4efe608dbb56
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b310b0dc..07316d31 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0resolution for the hooks settings file: `$CLAUDE_CONFIG_DIR/settings.json`when set, else `~/.claude/settings.json`. Rendered output and thechmod-600 warning show the resolved path.+- `install-skills --scope global` (claude-code root) installs to+ `$CLAUDE_CONFIG_DIR/skills` when the variable is set, else+ `~/.claude/skills`. `uninstall` sweeps the relocated root alongside the+ home default so installs that predate the env var are still removed.## [1.17.1] - 2026-07-20diff --git a/crates/ai-memory-cli/src/commands/install_skills.rs b/crates/ai-memory-cli/src/commands/install_skills.rsindex 98337ab5..4e3a3b6e 100644--- a/crates/ai-memory-cli/src/commands/install_skills.rs+++ b/crates/ai-memory-cli/src/commands/install_skills.rs@@ -12,7 +12,7 @@ use anyhow::{Context, Result, bail};use crate::cli::{InstallSkillsAgent, InstallSkillsArgs, InstallSkillsScope};use crate::commands::apply_shared::{ApplyOutcome, apply_atomic};use crate::commands::install_mcp;-use crate::commands::path_util::home_dir;+use crate::commands::path_util::{claude_config_dir, home_dir};use crate::config::Config;#[derive(Debug, Clone, Eq, PartialEq)]@@ -88,12 +88,14 @@ fn resolve_target_roots_from_env(args: &InstallSkillsArgs) -> Result<Vec<TargetR&& args.agent == InstallSkillsAgent::Grok).then(install_mcp::grok_home).transpose()?;+ let claude_config_dir = claude_config_dir(std::env::var_os("CLAUDE_CONFIG_DIR"));resolve_target_roots_for_platform(args,&cwd,home.as_deref(),appdata.as_deref(),grok_home.as_deref(),+ claude_config_dir.as_deref(),SkillHostPlatform::current(),)}@@ -104,7 +106,7 @@ fn resolve_target_roots(cwd: &Path,home: Option<&Path>,) -> Result<Vec<TargetRoot>> {- resolve_target_roots_for_platform(args, cwd, home, None, None, SkillHostPlatform::Other)+ resolve_target_roots_for_platform(args, cwd, home, None, None, None, SkillHostPlatform::Other)}fn resolve_target_roots_for_platform(@@ -113,6 +115,7 @@ fn resolve_target_roots_for_platform(home: Option<&Path>,appdata: Option<&Path>,grok_home: Option<&Path>,+ claude_config_dir: Option<&Path>,platform: SkillHostPlatform,) -> Result<Vec<TargetRoot>> {if let Some(target_dir) = &args.target_dir {@@ -128,6 +131,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?]}@@ -139,6 +143,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?]}@@ -150,6 +155,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?]}@@ -161,6 +167,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?]}@@ -172,6 +179,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?,agent_root(@@ -181,6 +189,7 @@ fn resolve_target_roots_for_platform(home,appdata,grok_home,+ claude_config_dir,platform,)?,],@@ -213,6 +222,7 @@ enum SkillRootKind {Grok,}+#[allow(clippy::too_many_arguments)]fn agent_root(scope: InstallSkillsScope,kind: SkillRootKind,@@ -220,6 +230,7 @@ fn agent_root(home: Option<&Path>,appdata: Option<&Path>,grok_home: Option<&Path>,+ claude_config_dir: Option<&Path>,platform: SkillHostPlatform,) -> Result<PathBuf> {if scope == InstallSkillsScope::Global@@ -238,6 +249,16 @@ fn agent_root(return Ok(grok_home.join(SKILLS_DIR));}+ // Claude Code relocates its whole config dir under $CLAUDE_CONFIG_DIR;+ // global skills live at `$CLAUDE_CONFIG_DIR/skills`, not+ // `~/.claude/skills`. Project scope stays under the repo.+ if scope == InstallSkillsScope::Global+ && kind == SkillRootKind::Claude+ && let Some(claude_config_dir) = claude_config_dir+ {+ return Ok(claude_config_dir.join(SKILLS_DIR));+ }+let base = match scope {InstallSkillsScope::Project => cwd,InstallSkillsScope::Global => {@@ -445,6 +466,7 @@ mod tests {Some(home),Some(appdata),None,+ None,SkillHostPlatform::Windows,).unwrap();@@ -466,6 +488,7 @@ mod tests {Some(home),None,None,+ None,SkillHostPlatform::Windows,).unwrap_err();@@ -481,12 +504,43 @@ mod tests {Some(Path::new("/home/alice")),None,Some(Path::new("/custom/grok")),+ None,SkillHostPlatform::Other,).unwrap();assert_eq!(root_names(&roots), ["/custom/grok/skills"]);}+ #[test]+ fn global_claude_skill_root_uses_injected_claude_config_dir() {+ let roots = resolve_target_roots_for_platform(+ &args(InstallSkillsScope::Global, InstallSkillsAgent::ClaudeCode),+ Path::new("/repo"),+ Some(Path::new("/home/alice")),+ None,+ None,+ Some(Path::new("/stores/claude")),+ SkillHostPlatform::Other,+ )+ .unwrap();+ assert_eq!(root_names(&roots), ["/stores/claude/skills"]);+ }++ #[test]+ fn project_claude_skill_root_ignores_claude_config_dir() {+ let roots = resolve_target_roots_for_platform(+ &args(InstallSkillsScope::Project, InstallSkillsAgent::ClaudeCode),+ Path::new("/repo"),+ Some(Path::new("/home/alice")),+ None,+ None,+ Some(Path::new("/stores/claude")),+ SkillHostPlatform::Other,+ )+ .unwrap();+ assert_eq!(root_names(&roots), ["/repo/.claude/skills"]);+ }+#[test]fn explicit_target_dir_overrides_scope_and_agent_roots() {let cwd = Path::new("/repo");diff --git a/crates/ai-memory-cli/src/commands/uninstall.rs b/crates/ai-memory-cli/src/commands/uninstall.rsindex f6031f7d..d9f77947 100644--- a/crates/ai-memory-cli/src/commands/uninstall.rs+++ b/crates/ai-memory-cli/src/commands/uninstall.rs@@ -327,11 +327,14 @@ fn build_plan(args: &UninstallArgs) -> anyhow::Result<Vec<PlannedChange>> {let home = home_dir();let appdata = std::env::var_os("APPDATA").map(PathBuf::from);let grok_home = install_mcp::grok_home().ok();+ let claude_config_dir =+ crate::commands::path_util::claude_config_dir(std::env::var_os("CLAUDE_CONFIG_DIR"));for root in skill_roots(&cwd,home.as_deref(),appdata.as_deref(),grok_home.as_deref(),+ claude_config_dir.as_deref(),) {for skill in MANAGED_SKILLS {push_generated_delete(@@ -351,8 +354,9 @@ fn skill_roots(home: Option<&Path>,appdata: Option<&Path>,grok_home: Option<&Path>,+ claude_config_dir: Option<&Path>,) -> Vec<PathBuf> {- let mut roots = Vec::with_capacity(9);+ let mut roots = Vec::with_capacity(10);push_unique_skill_root(&mut roots, cwd.join(CLAUDE_SKILL_DIR).join(SKILLS_DIR));push_unique_skill_root(&mut roots, cwd.join(AGENTS_SKILL_DIR).join(SKILLS_DIR));push_unique_skill_root(&mut roots, cwd.join(DEVIN_SKILL_DIR).join(SKILLS_DIR));@@ -371,6 +375,12 @@ fn skill_roots(if let Some(appdata) = appdata {push_unique_skill_root(&mut roots, appdata.join("devin").join(SKILLS_DIR));}+ // With CLAUDE_CONFIG_DIR set, global Claude Code skills install to+ // `$CLAUDE_CONFIG_DIR/skills`. Sweep it alongside ~/.claude/skills —+ // installs may predate the env var.+ if let Some(claude_config_dir) = claude_config_dir {+ push_unique_skill_root(&mut roots, claude_config_dir.join(SKILLS_DIR));+ }roots}@@ -1089,13 +1099,13 @@ mod tests {let home = Path::new("/home/alice");let appdata = Path::new("C:/Users/Alice/AppData/Roaming");- let roots = skill_roots(cwd, Some(home), Some(appdata), None);+ let roots = skill_roots(cwd, Some(home), Some(appdata), None, None);assert!(roots.contains(&appdata.join("devin").join(SKILLS_DIR)),"{roots:?}");- let without = skill_roots(cwd, Some(home), None, None);+ let without = skill_roots(cwd, Some(home), None, None, None);assert_eq!(without.len(),8,@@ -1111,6 +1121,28 @@ mod tests {);}+ /// `$CLAUDE_CONFIG_DIR/skills` is swept *in addition to*+ /// `~/.claude/skills` — installs may predate the env var, so uninstall+ /// must plan removal from both candidate roots.+ #[test]+ fn skill_roots_sweep_claude_config_dir_root_alongside_home() {+ let roots = skill_roots(+ Path::new("/repo"),+ Some(Path::new("/home/alice")),+ None,+ None,+ Some(Path::new("/stores/claude")),+ );+ assert!(+ roots.contains(&PathBuf::from("/stores/claude/skills")),+ "{roots:?}"+ );+ assert!(+ roots.contains(&PathBuf::from("/home/alice/.claude/skills")),+ "{roots:?}"+ );+ }+#[test]fn skill_roots_use_injected_grok_home_override() {let roots = skill_roots(@@ -1118,6 +1150,7 @@ mod tests {Some(Path::new("/home/alice")),None,Some(Path::new("/custom/grok")),+ None,);assert!(roots.contains(&PathBuf::from("/custom/grok/skills")),diff --git a/docs/install.md b/docs/install.mdindex 2e77b476..aa37d668 100644--- a/docs/install.md+++ b/docs/install.md@@ -70,9 +70,11 @@ ai-memory install-hooks --agent claude-code --applyIf `CLAUDE_CONFIG_DIR` is set, the claude-code installers match Claude Code'sown config resolution: `install-mcp` writes the MCP registration to-`$CLAUDE_CONFIG_DIR/.claude.json` (instead of `~/.claude.json`) and+`$CLAUDE_CONFIG_DIR/.claude.json` (instead of `~/.claude.json`),`install-hooks` / `setup-agent` target `$CLAUDE_CONFIG_DIR/settings.json`-(instead of `~/.claude/settings.json`). `uninstall` sweeps the same paths.+(instead of `~/.claude/settings.json`), and `install-skills --scope global`+uses `$CLAUDE_CONFIG_DIR/skills` (instead of `~/.claude/skills`). `uninstall`+sweeps the relocated paths alongside the defaults.The CLI commands (`bootstrap`, `status`, `search`, `lint`, `auto-improve`,`curator`, `pending-writes`, etc.) inherit the two env vars automatically. So do