session-archive
Claude Code deletes your old session logs after 30 days by default
(~/.claude/projects/*.jsonl). session-archive backs up expired sessions
into a local archive directory — gzip-compressed, with a searchable JSON index —
so the full transcript is kept before anything is deleted.
Stdlib-only. No dependencies.
Install
pip install session-archive
Usage
Archive every session older than the retention window (default: 30 days). Each archive is verified byte-for-byte before the original is deleted:
# archive expired sessions (deletes sources after verified backup)
session-archive archive
# preview what would be archived, change nothing
session-archive archive --dry-run
# keep the originals too
session-archive archive --no-delete-source
# custom retention window and locations
session-archive archive --retention-days 14 \
--source ~/.claude/projects \
--dest ~/backups/claude-sessions
Browse and recover:
session-archive list # all archived sessions
session-archive list --project myproj # filter by project directory
session-archive search "login flow" # search id / project / path / preview
session-archive restore sess-abc123 # restore to ~/.claude/projects/...
session-archive restore sess-abc123 --target ./recovered.jsonl --overwrite
session-archive status # source vs archive counts
Optional config file (~/.config/session-archive/config.json); every key is
overridable by CLI flags:
{
"source": "/home/hao/.claude/projects",
"dest": "/home/hao/.claude/session-archive",
"retention_days": 30,
"delete_source": true
}
Archive layout: <dest>/YYYY-MM/<session-id>.jsonl.gz plus <dest>/index.json.
Each index entry carries the session id, original path, message counts,
first/last timestamps, a text preview, and a sha256 of the compressed file —
restore verifies the checksum before writing.
Run it on a schedule (cron/systemd timer) or manually. The point is to run it before the 30-day window closes on sessions you still care about.
Differentiation
- vs session-handover:
session-handover distills a session into a compact handover packet for the
next agent — it deliberately throws away detail. session-archive is the
opposite: a full-fidelity backup. Transcripts are kept verbatim
(gzip of the original
.jsonl), plus a searchable index so you can find and restore any session later. Backup and handover are two different jobs; this tool does backup.
License
MIT
Metadata
Release files for session-archive 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| session_archive-0.1.0.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| session_archive-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / session_archive-0.1.0.tar.gz
| Download URL | session_archive-0.1.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9388a8e97b7a52773647dde3b9439ac9fcb7c4bcd469292eb989da3e6c0c2e3f
|
|
BLAKE2b-256 checksum How to use checksums |
bdde0a5a2ccfe09a51101cb0a088d84f5c8751d55b9c871b3f49c44aa89c4a35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / session_archive-0.1.0-py3-none-any.whl
| Download URL | session_archive-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24af9011a02c4fc4a3c015b3a9f6e024908b590d81ecf72900fa8cf75ae171bc
|
|
BLAKE2b-256 checksum How to use checksums |
f1f69355949677212dd91ed1857112b93edec1e285f022dda9877a1859c691e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|