Rebuild your Claude Code Desktop sidebar from CLI session files. Fixes the (no message) bug, deduplicates cloud-sync collisions, and restores missing sessions.
One command. Sixty seconds. Any OS. No dependencies.
If you run Claude Code on multiple machines with cloud-synced session storage (Google Drive, OneDrive, Dropbox), the Desktop sidebar drifts:
| Symptom | Cause |
|---|---|
(no message) entries |
GUI index points to sessions that moved or were renamed |
| Duplicate sessions | Cloud sync creates project (1), project (2) collision copies |
| Missing sessions | CLI sessions exist on disk but aren't in the Desktop index |
| Titles reset to defaults | Desktop rewrites local_*.json and drops custom titles |
The root cause: Claude Code CLI stores sessions as .jsonl files under ~/.claude/projects/. The Desktop app maintains a separate index of local_*.json entries. Cloud sync can desynchronize the two, and there's no built-in way to reconcile them.
# Dry-run first (read-only, safe)
python rebuild_claude_code_gui.py
# Apply the rebuild
python rebuild_claude_code_gui.py --applyExample output (dry-run)
GUI workspace: /Users/you/Library/Application Support/Claude/claude-code-sessions/abc123/def456
Existing entries: 89
Source jsonls: 312
--- DRY-RUN --- No changes made. Re-run with --apply to execute.
Example output (apply)
GUI workspace: /Users/you/Library/Application Support/Claude/claude-code-sessions/abc123/def456
Existing entries: 89
Source jsonls: 312
Backup created: /Users/you/backups/claude_gui_before_rebuild_20260420T143022
Cleared 89 old entries
Result: 308 created, 4 skipped (89 -> 308)
Backup at: /Users/you/backups/claude_gui_before_rebuild_20260420T143022
Restart Claude Code Desktop to see the rebuilt sidebar.
Regenerates the entire Desktop sidebar index from CLI .jsonl session files:
- Extracts metadata: timestamps, model, cwd, worktree info, turn count
- Links GUI entries to CLI sessions via
cliSessionId - Detects worktree sessions and nests them under their parent project
- Identifies scheduled task sessions from
<scheduled-task>wrappers - Excludes subagent traces (they shouldn't appear in the sidebar)
Merges foo (N) collision copies that cloud sync creates when two machines write simultaneously:
- Compares duplicate directories and files using a keep-larger rule
- Recursively merges directory trees
- Cleans up empty duplicate dirs after merge
Re-stamps drifted titles without a full rebuild. Useful when Desktop has overwritten your clean titles:
Before: "chat about the API"
After: "20260420_my-project_main -- chat about the API"
No installation required. Single-file script, stdlib only.
# Download
curl -O https://raw.githubusercontent.com/vaultkeeperflame1ock/claude-code-session-rebuild/main/rebuild_claude_code_gui.py
# Or clone
git clone https://github.com/vaultkeeperflame1ock/claude-code-session-rebuild.git
cd claude-code-session-rebuildRequires Python 3.8+. No pip install needed.
# See what would change (safe, read-only)
python rebuild_claude_code_gui.py
# Rebuild the sidebar index
python rebuild_claude_code_gui.py --apply
# Fix cloud-sync duplicates first, then rebuild
python rebuild_claude_code_gui.py --apply --dedupe
# Only fix drifted titles without full rebuild
python rebuild_claude_code_gui.py --apply --rename-only
# Rebuild but keep original session titles
python rebuild_claude_code_gui.py --apply --no-rename
# Show version
python rebuild_claude_code_gui.py --versionAlways restart Claude Code Desktop after running. The app caches the sidebar index in memory.
Claude Code stores session data in two locations:
~/.claude/projects/<project>/<uuid>.jsonl <-- CLI (source of truth)
<appdata>/Claude/claude-code-sessions/... <-- Desktop GUI (derived index)
CLI .jsonl |
Desktop local_*.json |
|
|---|---|---|
| Contains | Full conversation (messages, tool calls, metadata) | Index entry (title, timestamps, session link) |
| Created by | Every Claude Code session (CLI + Desktop) | Desktop app only |
| Survives sync | Yes (cloud sync copies these) | Often breaks (index drifts) |
This tool reads the CLI .jsonl files and regenerates the Desktop index, restoring the link between the two.
| Platform | GUI index location |
|---|---|
| Windows | %APPDATA%\Claude\claude-code-sessions\ |
| macOS | ~/Library/Application Support/Claude/claude-code-sessions/ |
| Linux | ~/.config/Claude/claude-code-sessions/ |
- Dry-run by default: Without
--apply, nothing is modified - Always backs up: Current GUI state is saved to
~/backups/claude_gui_before_rebuild_<timestamp>/before any changes - Idempotent: Safe to re-run as many times as needed
- No network access: Operates entirely on local files
- No dependencies: Python stdlib only, no
pip install
Q: Will this delete my session data?
No. The script only modifies the Desktop GUI index (local_*.json files). Your actual session data (.jsonl files under ~/.claude/projects/) is never touched. A full backup is created before any changes.
Q: Do I need to close Claude Code Desktop first? No, but you need to restart it after running so it picks up the new index.
Q: What if something goes wrong?
Restore from the backup directory. Copy the backed-up claude-code-sessions/ folder back to its original location.
Q: Does this work with Claude Code CLI only (no Desktop)?
The --dedupe feature works anywhere since it operates on ~/.claude/projects/. The full rebuild requires Claude Code Desktop to be installed (it needs the GUI index directory).
Issues and pull requests welcome. This tool was born from a real incident involving cloud sync and data loss -- if you've hit a similar problem, your edge case report helps everyone.