A simple Python script to restore your chat history in Cursor Editor after moving projects or upgrading your hard drive.
Cursor ties your chat history (and other workspace state) to the absolute path of your project folder. If you:
- Move a project folder
- Rename a project folder
- Migrate to a new hard drive with a different mount point
...Cursor sees it as a brand new project, and your chat history disappears. This script helps you map the "old" history to the "new" project location.
- Cross-Platform: Works on Linux, macOS, and Windows.
- Automatic Matching: Scans for moved projects based on path prefixes (e.g., moving from
/mnt/old/to/home/new/). - Manual Migration: Restore history for specifically renamed projects (e.g.,
project-v1->project-v2). - Safe: Performs a "dry run" by default and backs up existing data before overwriting.
- Clone this repository or download
cursor_chat_history_fix.py. - Ensure you have Python 3 installed.
The script uses a .env file for personal defaults so you don't have to keep re-typing them.
- Create a
.envfile (see.env.example):CURSOR_OLD_PREFIX=file:///your/old/path CURSOR_NEW_PREFIX=file:///your/new/path
If your .env is set up, just run:
# Preview changes (Dry Run)
python3 cursor_chat_history_fix.py
# Apply changes
python3 cursor_chat_history_fix.py --applyYou can still override the .env values using command-line arguments:
python3 cursor_chat_history_fix.py --apply --old-prefix "file:///mnt/old/path" --new-prefix "file:///home/new/path"Use this if you renamed a single project folder and want your history back.
-
List all workspaces to find your IDs:
python3 cursor_chat_history_fix.py --list
Look for the old folder (large size) and new folder (small size).
-
Migrate manually:
python3 cursor_chat_history_fix.py --manual OLD_ID:NEW_ID
- Open the project in its new location at least once so Cursor creates the destination folder.
- Close Cursor before running the migration (the script will warn you if it detects it running).
MIT