You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE REQUEST] Ability to move directories and not break --continue #1516
[docs/feature] claude --continue after moving directory : Guide + Internals explained
As I haven't found good claude feature or info in documentation how to proceed when moving project directory so claude --continue still works,
I run claude code to investigate claude code a bit, and produced clear instructions + explanation of internals how information about project history is stored,
that you may find useful either for updating docs, docs sdk or implementing directory ``claude mv` kind of feature... as I haven't found branch or repo to make merge request into documentation directly let me share here with community:
Claude Code Continue Functionality: Directory Migration Guide ( Claude Code --continue after Directory mv move - Migration Guide and Internal Mechanics explanation )
This guide explains how to preserve Claude Code's --continue functionality when moving project directories, along with the underlying mechanics.
Note: Claude Code currently lacks built-in directory migration features. Each directory maintains independent conversation sessions, and history doesn't automatically transfer when projects are moved.
Quick Fix: Steps to Maintain Continue History
When you move a project directory and want to preserve your conversation history:
1. Identify the Old and New Encoded Paths
Claude encodes directory paths by replacing forward slashes with hyphens:
# Original path
/home/user/projects/myapp
# Encoded path
-home-user-projects-myapp
2. Locate Your History Directory
Your conversation history is stored in:
~/.claude/projects/[encoded-directory-path]/
3. Rename the History Directory
After moving your project, rename the history directory to match:
# If you moved from:
/home/user/old-location/project
# To:
/home/user/new-location/project
# Run:cd~/.claude/projects/
mv -- -home-user-old-location-project -home-user-new-location-project
# Note: Use -- to prevent mv from interpreting the hyphen as an option
4. Verify
Navigate to your new project directory and run:
claude --continue
Your conversation history should be restored.
Alternative Approaches
Symbolic Links for History Preservation
If you frequently move directories, create a symbolic link:
# Create a stable location
mkdir -p ~/.claude/projects/stable-links
ln -s ~/.claude/projects/-actual-encoded-path ~/.claude/projects/stable-links/myproject
# When moving, just update the symlink
ln -sfn ~/.claude/projects/-new-encoded-path ~/.claude/projects/stable-links/myproject
Git Worktrees for Parallel Sessions
For maintaining separate conversation contexts on the same codebase:
# From your original repositorycd~/path/foo
git worktree add ~/path/bar feature-branch
# Each worktree maintains independent Claude sessionscd~/path/bar && claude
This provides the cleanest separation while avoiding shared conversation state complexity.
How Claude's Continue System Works
Storage Architecture
Claude CLI uses a file-based storage system with the following structure:
~/.claude/
├── projects/
│ └── [encoded-directory-paths]/
│ ├── [session-uuid].jsonl # Full conversation history
│ └── [summary-uuid].jsonl # Conversation summaries
├── settings.json # Global user preferences
├── .credentials.json # Authentication
└── statsig/ # Analytics and session tracking
Project-specific files (in your project directory):
The Claude Code community has actively requested better session persistence features. Current limitations:
No automatic session migration between directories
Each directory maintains completely independent conversation history
No built-in export/import functionality for conversations
Manual configuration transfer required when moving projects
No cross-directory continuation support
Security Considerations
History files may contain sensitive information
Set appropriate permissions (700) on ~/.claude/ directory
Consider encrypting ~/.claude/ if working with sensitive data
Exclude ~/.claude/ from backups if necessary
JSONL files contain full conversation content including code snippets
Advanced Tips
Debugging Path Encoding
# View all Claude project histories
ls -la ~/.claude/projects/ | grep "^d"# Find history for current directory
CURRENT_ENCODED=$(pwd | sed 's/\//-/g')
ls -la ~/.claude/projects/$CURRENT_ENCODED/
# Check latest session
ls -t ~/.claude/projects/$CURRENT_ENCODED/*.jsonl | head -1 | xargs tail -1 | jq
Session File Analysis
# Count messages in a session
wc -l ~/.claude/projects/$CURRENT_ENCODED/*.jsonl
# Extract all user messages
grep '"type":"user"'~/.claude/projects/$CURRENT_ENCODED/*.jsonl | jq -r '.message.content'# Find sessions by date
find ~/.claude/projects/ -name "*.jsonl" -newermt "2025-06-01" -ls
I haven't had time to peruse this, which is really detailed, thanks again, but I'd like to add one problem to the list:
Deleting a directory does not delete the CC history for that directory.
Repro:
Start a session in a directory (".../foo"), have a chat.
Close the session, rm -rf the directory, go have some coffee.
Create a new directory with the same name as previous ("...foo")
I think you can resume a session from the previously deleted directory. Also if you had a CLAUDE.md in the previous directory, I think might remember the instructions (since it reads them into the conversation at the beginning).
Sorry, I can't repro this right now, cuz API is having an outage, but I'm pretty sure deleting a directory does not delete the CC project folder.
changed the title [-][docs/feature] `claude --continue` after moving directory : Guide + Internals explained[/-][+][FEATURE REQUEST] Ability to move directories and not break --continue[/+]on Jun 18, 2025
It copies Claude Code conversations between directories with an interactive picker. Perfect for the git worktree use case mentioned here.
Quick example:
# Copy a conversation to a new directory
claude-cp ~/my-new-feature
# Works even if source directory is deleted!
claude-cp ~/new-project ~/worktrees/deleted-branch
Features:
📋 Interactive fzf picker with conversation summaries and previews
🕐 Sorts by modification time (most recent first)
👻 Works with deleted source directories
🔗 Handles symlinks correctly (important for macOS /tmp → /private/tmp)
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
gwpl commentedon Jun 2, 2025
https://gist.github.com/gwpl/e0b78a711b4a6b2fc4b594c9b9fa2c4c
copy&paste in comment below
Claude Code Continue Functionality: Directory Migration Guide ( Claude Code
--continueafter Directorymvmove - Migration Guide and Internal Mechanics explanation )This guide explains how to preserve Claude Code's
--continuefunctionality when moving project directories, along with the underlying mechanics.Quick Fix: Steps to Maintain Continue History
When you move a project directory and want to preserve your conversation history:
1. Identify the Old and New Encoded Paths
Claude encodes directory paths by replacing forward slashes with hyphens:
2. Locate Your History Directory
Your conversation history is stored in:
3. Rename the History Directory
After moving your project, rename the history directory to match:
4. Verify
Navigate to your new project directory and run:
Your conversation history should be restored.
Alternative Approaches
Symbolic Links for History Preservation
If you frequently move directories, create a symbolic link:
Git Worktrees for Parallel Sessions
For maintaining separate conversation contexts on the same codebase:
This provides the cleanest separation while avoiding shared conversation state complexity.
How Claude's Continue System Works
Storage Architecture
Claude CLI uses a file-based storage system with the following structure:
Project-specific files (in your project directory):
Session Files (JSONL Format)
Each conversation is stored in JSONL (JSON Lines) format, where each line represents a single event:
{"type":"user","message":{"role":"user","content":"Hello"},"timestamp":"2025-06-02T18:46:59.937Z"} {"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Hi!"}]},"timestamp":"2025-06-02T18:47:06.267Z"}Each session file includes:
parentUuid: Links messages in conversation threadssessionId: Unique identifier for the conversation sessioncwd: Working directory at message timeversion: Claude Code versiontimestamp: ISO 8601 timestampDirectory Path Encoding
The encoding algorithm:
/characters with-~/.claude/projects/Example transformations:
/home/alice/code/project→-home-alice-code-project/Users/bob/Documents/work→-Users-bob-Documents-work/var/www/app→-var-www-appContinue Resolution Process
When you run
claude --continue:pwd)~/.claude/projects/[encoded-path]/Session Management Commands
claude --continue: Resumes the most recent conversation in current directoryclaude --resume: Shows picker to select from previous sessionsclaude --continue --print "prompt": Continues with specific prompt/compact: Compresses conversation history to save context windowHeadless automation:
claude -p "continue our previous work" --output-format stream-jsonFile Types
Session Files (
[uuid].jsonl):Summary Files (
[uuid].jsonl):Complete Migration Procedure
Step 1: Migrate Configuration Files
After moving from
~/path/footo~/path/bar, copy all Claude-specific files:Step 2: Migrate Conversation History
Best Practices
1. Before Moving Directories
2. Use Version Control for History
3. Clean Up Old Histories
4. Project-Specific Instructions
Claude reads
CLAUDE.mdfiles in your project root for additional context. These move with your project automatically.5. Automate Migration
Create a migration script:
Troubleshooting
Continue Not Finding History
Verify the encoded path matches:
Check for multiple similar directories:
Permission Issues
Ensure proper permissions:
chmod -R 700 ~/.claude/Corrupted History
If history appears corrupted:
Current Limitations
The Claude Code community has actively requested better session persistence features. Current limitations:
Security Considerations
700) on~/.claude/directory~/.claude/if working with sensitive data~/.claude/from backups if necessaryAdvanced Tips
Debugging Path Encoding
Session File Analysis
Further Reading
hesreallyhim commentedon Jun 12, 2025
Thanks for sharing this
hesreallyhim commentedon Jun 12, 2025
I haven't had time to peruse this, which is really detailed, thanks again, but I'd like to add one problem to the list:
Repro:
rm -rfthe directory, go have some coffee.Sorry, I can't repro this right now, cuz API is having an outage, but I'm pretty sure deleting a directory does not delete the CC project folder.
[-][docs/feature] `claude --continue` after moving directory : Guide + Internals explained[/-][+][FEATURE REQUEST] Ability to move directories and not break --continue[/+]ogt commentedon Jun 26, 2025
Very useful!
gitmpr commentedon Jul 30, 2025
In the path encoding of project names under
~/.claude/projects/not only slashes, but also
dots in dir names area also replaced by hyphens it seems
unfortunately it seems claude wasn't able to find this out about itself
dlond commentedon Oct 20, 2025
Hey folks! 👋
I built a tool to solve this problem: claude-cp
It copies Claude Code conversations between directories with an interactive picker. Perfect for the git worktree use case mentioned here.
Quick example:
Features:
--no-fzffallback for non-interactive contextsRepo: https://github.com/dlond/claude-tools
It uses the same
~/.claude/projects/structure mentioned in the gist, but automates the whole process with a nice UX.Would love feedback! Built entirely with Claude Code itself 🤖
dlond commentedon Oct 22, 2025
claude-tools binaries for aarm64-darwin, and linux and mac nix users should be able to build locally
github-actions commentedon Dec 8, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
github-actions commentedon Jan 8, 2026
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
github-actions commentedon Jan 16, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.