Keeping Claude Code sessions for your repository in one place
I keep my Claude Code sessions in Dropbox so that I can pick up a conversation on another Mac. That works, but it comes with an annoyance: Claude Code names each project folder after the whole working directory path, so the moment a path differs even slightly — a different machine layout, or a git worktree — a brand new folder appears and the session history splits again.…
Claude Code users can keep their code sessions organized by naming the project directory themselves. This fixes the issue where Claude Code creates a new folder for each working directory path, splitting session history across machines and git worktrees. By setting the CLAUDE_CODE_PROJECT_DIR_NAME environment variable, users can specify a custom folder name for their sessions.
This requires Claude Code version 2.1.234 or later. The variable must be set in the shell environment that launches Claude Code, and direnv can automate this process by loading and unloading the variable as the user enters and leaves the repository directory. With this setup, sessions from the same project will live in a single, stable folder regardless of the machine or worktree, making it easier to share conversations across devices through Dropbox.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.