Restoring Archived Sessions¶
When you run claude-code-log, you may see output like:
This indicates that 3 sessions exist in the cache whose source JSONL files have been deleted.
What Are Archived Sessions?¶
Archived sessions are sessions preserved in the SQLite cache (~/.claude/projects/claude-code-log-cache.db) even after their source JSONL files have been deleted. This happens when:
- Claude Code automatically deletes old JSONL files based on the
cleanupPeriodDayssetting - You manually delete JSONL files from
~/.claude/projects/*/ - You archive sessions using the TUI (
akey)
The cache stores the complete message data, so full restoration is possible.
Preventing Automatic Deletion¶
Claude Code automatically deletes session logs after 30 days by default. To change this, add cleanupPeriodDays to your ~/.claude/settings.json:
This effectively disables automatic cleanup (274 years). You can also set it to a specific number of days.
See Claude Code's settings documentation for more details.
Using the TUI to Manage Archived Sessions¶
The easiest way to browse and restore archived sessions is through the interactive TUI.
Launch the TUI¶
Viewing Archived Sessions¶
Archived sessions appear inline with current sessions, marked with an [ARCHIVED] prefix:
┌─ Claude Code Log ─────────────────────────────────────────────────┐
│ Project: my-project (3 archived) │
│ Sessions: 5 │ Messages: 456 │ Tokens: 45,230 │
├──────────┬───────────────────────────────────────┬─────────┬──────┤
│ Session │ Title │ Start │ Msgs │
├──────────┼───────────────────────────────────────┼─────────┼──────┤
│ xyz789 │ Current session │ 01-20 │ 32 │
│ abc123 │ [ARCHIVED] Fix authentication bug │ 12-01 │ 45 │
│ def456 │ [ARCHIVED] Add user settings page │ 11-28 │ 123 │
└──────────┴───────────────────────────────────────┴─────────┴──────┘
[a] Archive [r] Restore [h] HTML [v] View [c] Resume [q] Quit
Archive and Restore Keys¶
a- Archive Session: Deletes the JSONL file but keeps the session in cacher- Restore JSONL: Recreates the JSONL file from cached data
Restore a Session¶
- Navigate to the archived session (marked with
[ARCHIVED]) - Press
rto restore the session to a JSONL file - The session will be restored to
~/.claude/projects/{project}/{session-id}.jsonl - The
[ARCHIVED]prefix will be removed after the session list refreshes
View Archived Sessions¶
You can view archived sessions as HTML or Markdown without restoring them:
h- Open HTML in browserm- Open Markdown in browserv- View Markdown in embedded viewer
Limitations¶
- Message order: Messages are ordered by timestamp, which may differ slightly from original file order for same-timestamp entries
- Whitespace: Original JSON formatting is not preserved (semantically identical)
Manual SQL Approach¶
For advanced users, you can also query the cache database directly: