Expand description
Where the Claude Code CLI keeps a conversation under a CLAUDE_CONFIG_DIR.
One implementation, because every reader has to agree with the CLI byte for byte: a resume check that computes a different folder name than the CLI reports a transcript that is sitting on disk as unreachable, and the agent loses its native resume. Three copies of this rule used to disagree, and the one on the resume path was wrong for any working directory holding an underscore, a space or most other punctuation.
Functions§
- has_
linked_ worktrees - Whether the repository whose main checkout is
roothas linked worktrees — each of which sharesroot’s memory folder. - memory_
project_ root - 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): - memory_
project_ root_ with memory_project_root, withwrittensaying whether a container agent can write a folder.- physical_
dir - The working directory as the CLI’s process sees it (
process.cwd()): symlinks resolved. On Windowscanonicalizereturns a\\?\verbatim path the CLI never sees, and the current directory keeps links as given. - project_
dir_ name - The folder under
<CLAUDE_CONFIG_DIR>/projects/that holds the sessions the CLI ran withcwdas its working directory. - real_
path pwith symlinks resolved, as the CLI’s process would name it. On Windowscanonicalizereturns a\\?\verbatim path, which names the folder----C--repowhere the CLI, seeingC:\repo, names itC--repo. Tests that build a working directory take it from here too: a rawcanonicalizegives them a path no real cwd has (#3749).