Skip to main content

Module claude_layout

Module claude_layout 

Source
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 root has linked worktrees — each of which shares root’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, with written saying 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 Windows canonicalize returns 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 with cwd as its working directory.
real_path
p with symlinks resolved, as the CLI’s process would name it. On Windows canonicalize returns a \\?\ verbatim path, which names the folder ----C--repo where the CLI, seeing C:\repo, names it C--repo. Tests that build a working directory take it from here too: a raw canonicalize gives them a path no real cwd has (#3749).