重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
project-directory-migration by terrylica/cc-skills
npx skills add https://github.com/terrylica/cc-skills --skill project-directory-migration安全迁移 Claude Code 项目上下文(会话、记忆、历史记录),适用于重命名项目目录时。
在以下情况使用此技能:
my-old-name/ 改为 my-new-name/)使用 AskUserQuestion 收集源路径和目标路径。
Question 1 (header: "Source"): "当前项目目录路径是什么?"
Options:
- "使用当前目录:$PWD"(推荐)
- "指定其他路径"
Question 2 (header: "Target"): "新目录路径应该是什么?"
Options:
- (用户通过“其他”自由文本提供)
以 --dry-run 模式运行迁移脚本,以发现需要迁移的内容:
bash "<skill-scripts>/claude-code-migrate.sh" --dry-run "$OLD_PATH" "$NEW_PATH"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
向用户展示发现结果:
Question 3 (header: "Scope", multiSelect: true):
"迁移应包含哪些内容?"
Options:
- "Claude Code 会话 + 历史记录(推荐)"
- "自动记忆(MEMORY.md)(推荐)"
- "向后兼容符号链接(推荐)"
- "自动修复环境:mise trust、venv 重新创建(推荐)"
Question 4 (header: "Execute"):
"准备迁移吗?脚本会先创建带时间戳的备份。"
Options:
- "立即执行迁移(推荐)"
- "导出可复制粘贴的命令供手动执行"
- "取消"
如果用户选择“导出可复制粘贴的命令”:生成他们可以在关闭 Claude Code 后粘贴到终端的精确命令。这是最安全的选择,因为迁移期间 Claude Code 不会访问项目文件。
迁移完成后,报告:
Claude Code 通过将 / 替换为 - 来编码目录路径:
/Users/alice/projects/my-app --> -Users-alice-projects-my-app
| 资产 | 位置 |
|---|---|
| 会话 | ~/.claude/projects/{encoded-path}/*.jsonl |
| 记忆 | ~/.claude/projects/{encoded-path}/memory/MEMORY.md |
| 会话索引 | ~/.claude/projects/{encoded-path}/sessions-index.json |
| 历史记录 | ~/.claude/history.jsonl |
| 子代理 | ~/.claude/projects/{encoded-path}/{session-id}/subagents/ |
| 文件 | 包含路径的字段 | 需要重写? |
|---|---|---|
sessions-index.json | originalPath, entries[].projectPath, entries[].fullPath | 是 |
history.jsonl | 每个条目的 project 字段 | 是 |
会话 .jsonl 文件 | 无 | 否 |
MEMORY.md | 无(仅内容) | 否 |
位于 scripts/claude-code-migrate.sh。
# 模拟运行(预览将发生的情况)
bash scripts/claude-code-migrate.sh --dry-run /old/path /new/path
# 执行迁移
bash scripts/claude-code-migrate.sh /old/path /new/path
# 从最近的备份回滚
bash scripts/claude-code-migrate.sh --rollback
# 显示帮助
bash scripts/claude-code-migrate.sh --help
~/.claude/migration-backup-YYYYMMDD-HHMMSS/~/.claude/projects/ 中重命名mv /old/path /new/path| 问题 | 自动修复? | 手动解决方案 |
|---|---|---|
| 重命名后 mise trust 错误 | 是(阶段 8) | mise trust <new-path> |
Shell 提示符中出现 (old-name) | 是(阶段 8) | 重启终端或执行 uv sync |
| VIRTUAL_ENV 路径不匹配 | 是(阶段 8) | uv sync --dev 重新创建 venv |
| “未找到对话” | 是(阶段 4) | 重新运行迁移脚本 |
.envrc 不允许 | 已警告(阶段 8) | direnv allow |
| Git push 认证失败 | 否 | 更新凭据助手或远程 URL |
| 会话子目录缺失 | 否 | 使用 --rollback,重试 |
每周安装数
52
仓库
GitHub 星标数
25
首次出现
2026年2月13日
安全审计
安装于
opencode51
gemini-cli50
github-copilot50
codex50
kimi-cli50
amp50
Safely migrate Claude Code project context (sessions, memory, history) when renaming a project directory.
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 |
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 |
Weekly Installs
52
Repository
GitHub Stars
25
First Seen
Feb 13, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
opencode51
gemini-cli50
github-copilot50
codex50
kimi-cli50
amp50
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
124,500 周安装
Claude 策略性压缩技能:智能管理上下文,提升AI编程效率与性能
2,500 周安装
代币安全审计API - 检测蜜罐、拉地毯骗局、恶意合约 | Binance Web3技能
2,500 周安装
Django安全最佳实践指南 - 防范常见漏洞,配置生产环境安全设置
2,500 周安装
Firestore 安全规则审计工具 | Firebase 安全审计与渗透测试技能
3,500 周安装
Tushare金融数据Skill:Python获取中国股市/基金/宏观经济数据API接口
2,600 周安装
Spring Boot TDD 工作流指南:单元测试、集成测试与 80% 代码覆盖率实践
2,500 周安装
| None |
| No |
MEMORY.md | None (content only) | No |
| Warned (Phase 8) |
direnv allow |
| Git push auth fails | No | Update credential helper or remote URL |
| Session subdirs missing | No | Use --rollback, retry |