Problem
opencode stores all session history, messages, file parts, and diffs in ~/.local/share/opencode/storage/ with no automatic cleanup and no CLI command to reclaim disk space.
After ~5 months of regular use on a single project, my storage has grown to:
~/.local/share/opencode/
├── storage/
│ ├── message/ 497 MB (conversation messages)
│ ├── part/ 966 MB (30,122 files — file content snapshots)
│ ├── session_diff/ 989 MB (session state diffs)
│ └── session/ 5.3 MB (1,324 session index files)
└── tool-output/ 52 MB (Playwright, shell outputs)
Total: ~5.1 GB
Growth rate: ~500 MB/month. At this pace, it will reach 6+ GB within a year for a single project.
What I'd expect
1. CLI command: opencode session prune
# Dry run — show what would be deleted
opencode session prune --older-than 30d --dry-run
# Delete sessions older than 30 days and reclaim disk space
opencode session prune --older-than 30d
# Show current storage usage by category
opencode session stats
2. Config option for automatic cleanup
3. What should be cleaned up
When a session is deleted, all associated data should be removed:
storage/session/{project_id}/ses_*.json
storage/message/ entries linked to that session
storage/part/ entries linked to those messages (the biggest contributor at ~1 GB)
storage/session_diff/ses_*.json
tool-output/ entries linked to that session
Problem
opencode stores all session history, messages, file parts, and diffs in
~/.local/share/opencode/storage/with no automatic cleanup and no CLI command to reclaim disk space.After ~5 months of regular use on a single project, my storage has grown to:
Growth rate: ~500 MB/month. At this pace, it will reach 6+ GB within a year for a single project.
What I'd expect
1. CLI command:
opencode session prune2. Config option for automatic cleanup
3. What should be cleaned up
When a session is deleted, all associated data should be removed:
storage/session/{project_id}/ses_*.jsonstorage/message/entries linked to that sessionstorage/part/entries linked to those messages (the biggest contributor at ~1 GB)storage/session_diff/ses_*.jsontool-output/entries linked to that session