{"id":"3ef34e7f-34f6-4483-ac37-ade96e09e3c3","shortId":"KSXy27","kind":"skill","title":"lovstudio:cc-migrate-session","tagline":"Recover Claude Code session history lost after a project folder moved or was renamed. 项目迁移后 claude --resume / cc --resume 找不到历史会话时用此 skill 迁移 session 存储。","description":"# lovstudio:cc-migrate-session\n\nMoves the session store `~/.claude/projects/<slug>/` from the old path-slug to the new one and rewrites every `\"cwd\"` field inside the jsonl files. After this, `claude --resume` from the new directory will see all prior sessions.\n\n## When to Trigger\n\n**YES** — invoke this skill when:\n- User says the project folder moved / was renamed at the filesystem level\n- User mentions both FROM and TO paths, OR mentions one and the current cwd implies the other\n- User complains that `claude --resume` no longer shows history after moving a folder\n- User wants to \"recover\" sessions from a path they used to work in\n\n**NO** — don't invoke when:\n- User is renaming a file, function, variable, or branch (not the project root)\n- User is asking a general question about CC's storage model (just explain, don't migrate)\n- Paths are ambiguous — ask first\n\n## Workflow\n\n### Step 1 — Gather FROM and TO\n\nInfer from the conversation first. Typical patterns:\n\n| User said | FROM | TO |\n|-----------|------|----|\n| \"我把项目从 /a 搬到了 /b\" | /a | /b |\n| \"this project used to be at /old\" (in new cwd) | /old | `process.cwd()` (current) |\n| \"本项目已迁移到 /new\" (in old cwd) | `process.cwd()` (current) | /new |\n| \"I renamed ~/foo to ~/bar\" | ~/foo | ~/bar |\n\nIf either side is ambiguous, **ask once** with `AskUserQuestion`. Don't guess.\n\n**Always** expand `~` and resolve to absolute paths before running the CLI.\n\n### Step 2 — Run dry-run + json to preview\n\n```bash\nnpx -y @lovstudio/cc-migrate-session <FROM> <TO> --dry-run --json\n```\n\nParse the JSON. Tell the user:\n- How many sessions were found\n- Total size\n- Warn if `toDirExists` is true (destination slug dir already exists — merge risk)\n- Show the FROM and TO slugs so the user can sanity-check the path mapping\n\nIf `sessionCount === 0`, stop. Tell the user either (a) the FROM path is wrong, or (b) CC never ran there. Do NOT proceed.\n\n### Step 3 — Confirm with user\n\nUse `AskUserQuestion` (or inline yes/no) asking: \"Migrate N sessions from <FROM> to <TO>?\"\n\nOnly proceed on explicit yes.\n\n### Step 4 — Execute\n\n```bash\nnpx -y @lovstudio/cc-migrate-session <FROM> <TO> --yes --json\n```\n\nParse `phase: \"done\"` output. Extract:\n- `rewrites` (total cwd lines changed)\n- `restartHint.cd` and `restartHint.command`\n\n### Step 5 — Tell user to restart CC\n\nOutput something like:\n\n```\n✓ Migrated N session(s), rewrote M cwd lines.\n\nTo load them, restart Claude Code in the new location:\n\n  cd <TO>\n  claude --resume\n\n(The original session dir at ~/.claude/projects/<old-slug>/ is untouched —\nyou can delete it after verifying the new location works.)\n```\n\n**IMPORTANT**: The CURRENT Claude Code session (the one running this skill) cannot \"switch\" its own cwd mid-session. The user must exit and re-invoke `claude` from the new directory. State this clearly.\n\n## CLI Reference\n\n`npx -y @lovstudio/cc-migrate-session <FROM> <TO> [options]`\n\n| Option | Purpose |\n|--------|---------|\n| `-y`, `--yes` | Skip confirmation prompt |\n| `--dry-run` | Show plan, don't write |\n| `--json` | Machine-readable output (use this from the skill) |\n| `--projects-dir <dir>` | Override CC projects dir (default `~/.claude/projects`) |\n\n## Slug Rule (FYI)\n\nCC computes the slug by replacing every non-alphanumeric character with `-`. So:\n- `/Users/mark/my-project` → `-Users-mark-my-project`\n- `/Users/mark/.claude` → `-Users-mark--claude` (double `-` because `.` is non-alnum)\n- `/Users/mark/@手工川` → `-Users-mark-----` (one per `@` and each CJK char)\n\nThe CLI handles this automatically — don't try to hand-compute it.\n\n## Safety\n\n- The old dir is NEVER deleted by this skill. It's a copy-then-rewrite, not a move.\n- Tell the user to verify `claude --resume` works in the new location before rm'ing the old slug dir.\n- If destination slug dir already exists, the CLI merges (overwriting conflicting jsonls). Warn the user.","tags":["migrate","session","skills","lovstudio","agent-skills","ai-coding-assistant","cjk","claude-code","cursor","gemini-cli","markdown-to-docx","markdown-to-pdf"],"capabilities":["skill","source-lovstudio","skill-cc-migrate-session","topic-agent-skills","topic-ai-coding-assistant","topic-cjk","topic-claude-code","topic-cursor","topic-gemini-cli","topic-markdown-to-docx","topic-markdown-to-pdf"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/lovstudio/skills/cc-migrate-session","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add lovstudio/skills","source_repo":"https://github.com/lovstudio/skills","install_from":"skills.sh"}},"qualityScore":"0.469","qualityRationale":"deterministic score 0.47 from registry signals: · indexed on github topic:agent-skills · 39 github stars · SKILL.md body (3,860 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-21T01:36:38.076Z","embedding":null,"createdAt":"2026-04-18T22:18:53.572Z","updatedAt":"2026-04-21T01:36:38.076Z","lastSeenAt":"2026-04-21T01:36:38.076Z","tsv":"'/.claude/projects':39,409,496 '/a':193,196 '/b':195,197 '/bar':223,225 '/foo':221,224 '/new':212,218 '/old':204,208 '/users/mark':530 '/users/mark/.claude':519 '/users/mark/my-project':513 '0':309 '1':176 '2':250 '3':331 '4':352 '5':374 'absolut':243 'alnum':529 'alphanumer':509 'alreadi':287,597 'alway':238 'ambigu':171,230 'ask':155,172,231,340 'askuserquest':234,336 'automat':545 'b':322 'bash':258,354 'branch':148 'cannot':433 'cc':3,23,32,160,323,379,492,500 'cc-migrate-sess':2,31 'cd':401 'chang':369 'char':540 'charact':510 'check':303 'cjk':539 'claud':7,21,61,112,395,402,425,449,523,579 'clear':456 'cli':248,457,542,600 'code':8,396,426 'complain':110 'comput':501,552 'confirm':332,468 'conflict':603 'convers':184 'copi':568 'copy-then-rewrit':567 'current':104,210,217,424 'cwd':53,105,207,215,367,389,437 'default':495 'delet':414,560 'destin':284,594 'dir':286,407,490,494,557,592,596 'directori':66,453 'done':362 'doubl':524 'dri':253,263,471 'dry-run':252,262,470 'either':227,314 'everi':52,506 'execut':353 'exist':288,598 'exit':444 'expand':239 'explain':165 'explicit':349 'extract':364 'field':54 'file':58,144 'filesystem':90 'first':173,185 'folder':15,84,121 'found':276 'function':145 'fyi':499 'gather':177 'general':157 'guess':237 'hand':551 'hand-comput':550 'handl':543 'histori':10,117 'impli':106 'import':422 'infer':181 'ing':588 'inlin':338 'insid':55 'invok':76,138,448 'json':255,265,268,359,478 'jsonl':57,604 'level':91 'like':382 'line':368,390 'load':392 'locat':400,420,585 'longer':115 'lost':11 'lovstudio':1,30 'lovstudio/cc-migrate-session':261,357,461 'm':388 'machin':480 'machine-read':479 'mani':273 'map':306 'mark':516,522,534 'mention':93,100 'merg':289,601 'mid':439 'mid-sess':438 'migrat':4,33,168,341,383 'model':163 'move':16,35,85,119,573 'must':443 'n':342,384 'never':324,559 'new':48,65,206,399,419,452,584 'non':508,528 'non-alnum':527 'non-alphanumer':507 'npx':259,355,459 'old':42,214,556,590 'one':49,101,429,535 'option':462,463 'origin':405 'output':363,380,482 'overrid':491 'overwrit':602 'pars':266,360 'path':44,98,129,169,244,305,318 'path-slug':43 'pattern':187 'per':536 'phase':361 'plan':474 'preview':257 'prior':70 'proceed':329,347 'process.cwd':209,216 'project':14,83,151,199,489,493,518 'projects-dir':488 'prompt':469 'purpos':464 'question':158 'ran':325 're':447 're-invok':446 'readabl':481 'recov':6,125 'refer':458 'renam':19,87,142,220 'replac':505 'resolv':241 'restart':378,394 'restarthint.cd':370 'restarthint.command':372 'resum':22,24,62,113,403,580 'rewrit':51,365,570 'rewrot':387 'risk':290 'rm':587 'root':152 'rule':498 'run':246,251,254,264,430,472 'safeti':554 'said':189 'saniti':302 'sanity-check':301 'say':81 'see':68 'session':5,9,28,34,37,71,126,274,343,385,406,427,440 'sessioncount':308 'show':116,291,473 'side':228 'size':278 'skill':26,78,432,487,563 'skill-cc-migrate-session' 'skip':467 'slug':45,285,296,497,503,591,595 'someth':381 'source-lovstudio' 'state':454 'step':175,249,330,351,373 'stop':310 'storag':162 'store':38 'switch':434 'tell':269,311,375,574 'todirexist':281 'topic-agent-skills' 'topic-ai-coding-assistant' 'topic-cjk' 'topic-claude-code' 'topic-cursor' 'topic-gemini-cli' 'topic-markdown-to-docx' 'topic-markdown-to-pdf' 'total':277,366 'tri':548 'trigger':74 'true':283 'typic':186 'untouch':411 'use':131,200,335,483 'user':80,92,109,122,140,153,188,271,299,313,334,376,442,515,521,533,576,607 'users-mark':520,532 'users-mark-my-project':514 'variabl':146 'verifi':417,578 'want':123 'warn':279,605 'work':133,421,581 'workflow':174 'write':477 'wrong':320 'y':260,356,460,465 'yes':75,350,358,466 'yes/no':339 '存储':29 '我把项目从':192 '手工川':531 '找不到历史会话时用此':25 '搬到了':194 '本项目已迁移到':211 '迁移':27 '项目迁移后':20","prices":[{"id":"0554d4eb-78e7-45b7-a0e6-460390a75145","listingId":"3ef34e7f-34f6-4483-ac37-ade96e09e3c3","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"lovstudio","category":"skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:18:53.572Z"}],"sources":[{"listingId":"3ef34e7f-34f6-4483-ac37-ade96e09e3c3","source":"github","sourceId":"lovstudio/skills/cc-migrate-session","sourceUrl":"https://github.com/lovstudio/skills/tree/main/skills/cc-migrate-session","isPrimary":false,"firstSeenAt":"2026-04-18T22:18:53.572Z","lastSeenAt":"2026-04-21T01:36:38.076Z"}],"details":{"listingId":"3ef34e7f-34f6-4483-ac37-ade96e09e3c3","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"lovstudio","slug":"cc-migrate-session","github":{"repo":"lovstudio/skills","stars":39,"topics":["agent-skills","ai-coding-assistant","cjk","claude-code","cursor","gemini-cli","markdown-to-docx","markdown-to-pdf"],"license":"mit","html_url":"https://github.com/lovstudio/skills","pushed_at":"2026-04-20T21:40:57Z","description":"Agent skills for AI coding assistants — Markdown to PDF/DOCX with 14 themes, CJK support","skill_md_sha":"6084c9ed796d6b44808f67f906ea933dda73d491","skill_md_path":"skills/cc-migrate-session/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/lovstudio/skills/tree/main/skills/cc-migrate-session"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"lovstudio:cc-migrate-session","license":"MIT","description":"Recover Claude Code session history lost after a project folder moved or was renamed. 项目迁移后 claude --resume / cc --resume 找不到历史会话时用此 skill 迁移 session 存储。","compatibility":"claude-code"},"skills_sh_url":"https://skills.sh/lovstudio/skills/cc-migrate-session"},"updatedAt":"2026-04-21T01:36:38.076Z"}}