Migrate Claude Code project sessions when renaming directories. TRIGGERS - directory rename, move project, migrate sessions, project path change, workspace reorganization, rename folder.
From devops-toolsnpx claudepluginhub terrylica/cc-skills --plugin devops-toolsThis skill is limited to using the following tools:
references/evolution-log.mdreferences/session-storage-anatomy.mdreferences/troubleshooting.mdscripts/claude-code-migrate.shSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Generates platform-native social content for X, LinkedIn, TikTok, YouTube, newsletters from source material like articles, demos, docs, or notes. Adapts voice and format per platform.
Safely migrate Claude Code project context (sessions, memory, history) when renaming a project directory.
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
Use this skill when:
my-old-name/ to my-new-name/)Use AskUserQuestion to collect source and target paths.
Question 1 (header: "Source"): "What is the current project directory path?"
Options:
- "Use current directory: $PWD" (Recommended)
- "Specify a different path"
Question 2 (header: "Target"): "What should the new directory path be?"
Options:
- (User provides via "Other" free text)
Run the migration script in --dry-run mode to discover what needs migrating:
bash "<skill-scripts>/claude-code-migrate.sh" --dry-run "$OLD_PATH" "$NEW_PATH"
Present findings to user:
Question 3 (header: "Scope", multiSelect: true):
"What should be included in migration?"
Options:
- "Claude Code sessions + history (Recommended)"
- "Auto-memory (MEMORY.md) (Recommended)"
- "Backward-compatibility symlink (Recommended)"
- "Auto-fix environment: mise trust, venv recreate (Recommended)"
Question 4 (header: "Execute"):
"Ready to migrate? The script creates a timestamped backup first."
Options:
- "Execute migration now (Recommended)"
- "Export copy-paste commands for manual execution"
- "Cancel"
If user chooses "Export copy-paste commands": Generate the exact commands they can paste into their terminal after closing Claude Code. This is the safest option since Claude Code won't be accessing the project files during migration.
After migration completes, report:
Claude Code encodes directory paths by replacing / with -:
/Users/alice/projects/my-app --> -Users-alice-projects-my-app
| Asset | Location |
|---|---|
| Sessions | ~/.claude/projects/{encoded-path}/*.jsonl |
| Memory | ~/.claude/projects/{encoded-path}/memory/MEMORY.md |
| Session index | ~/.claude/projects/{encoded-path}/sessions-index.json |
| History | ~/.claude/history.jsonl |
| Subagents | ~/.claude/projects/{encoded-path}/{session-id}/subagents/ |
| File | Fields with paths | Needs rewriting? |
|---|---|---|
sessions-index.json | originalPath, entries[].projectPath, entries[].fullPath | Yes |
history.jsonl | project field per entry | Yes |
Session .jsonl files | None | No |
MEMORY.md | None (content only) | No |
Located at scripts/claude-code-migrate.sh.
# Dry run (preview what would happen)
bash scripts/claude-code-migrate.sh --dry-run /old/path /new/path
# Execute migration
bash scripts/claude-code-migrate.sh /old/path /new/path
# Rollback from most recent backup
bash scripts/claude-code-migrate.sh --rollback
# Show help
bash scripts/claude-code-migrate.sh --help
~/.claude/migration-backup-YYYYMMDD-HHMMSS/~/.claude/projects/mv /old/path /new/path| Issue | Auto-fixed? | Manual Solution |
|---|---|---|
| mise trust error after rename | Yes (Phase 8) | mise trust <new-path> |
(old-name) in shell prompt | Yes (Phase 8) | Restart terminal or uv sync |
| VIRTUAL_ENV path mismatch | Yes (Phase 8) | uv sync --dev recreates venv |
| "No conversations found" | Yes (Phase 4) | Re-run migration script |
.envrc not allowed | Warned (Phase 8) | direnv allow |
| Git push auth fails | No | Update credential helper or remote URL |
| Session subdirs missing | No | Use --rollback, retry |
After this skill completes, reflect before closing the task:
Do NOT defer. The next invocation inherits whatever you leave behind.