Skip to main content

memory_project_root

Function memory_project_root 

Source
pub fn memory_project_root(cwd: &Path) -> PathBuf
Expand description

The directory the CLI names a working directory’s auto-memory folder after — not the working directory itself, unlike its sessions. The CLI’s rule (its defaultPath(), Claude Code v2.1.280):

g = this.canonicalWcRootForProject(r) ?? Ur(r) ?? r   // r: the process cwd
function Ur(e){let n=Un(e);if(!n)return null;return eQ(uu().canonicalRootByRoot,n,ke)}

That is: the physical working directory, walked up to the nearest .git (a directory or a file), and — for a linked worktree, whose .git is a gitdir: file — on to the main checkout that owns it. So every subdirectory and every linked worktree of one repository shares the repository root’s memory folder.

Returns the working directory unchanged when it isn’t in a repository.