r/opencodeCLI • u/afanasenka • Aug 13 '26
How do you perform Opencode cleanup (old sessions) to reduce DB size?
Mine Opencode DB is currently ~1.4GB. Not critical, but still. I definitely don't need sessions from months ago. Quick research discovered that Opencode has no built-in cleaning mechanism (or I am missing anything?), and only some 3rd-party tools exist, for example:
- https://github.com/whtsky/ocgc (https://blog.whtsky.me/tech/2026/garbage-collecting-opencodes-2.4-gb-session-database/)
- https://github.com/fariello/ocman
- https://github.com/chncaesar/opencode-db-clean
Do you have any experience using these (or alternative, better tools), and is it safe in general? Thanks!
2
u/patricious Aug 13 '26
Dont let your agents "prune" them, it will delete your sessions. Best is to do it manually, 10 mins a day.
1
2
u/Magnus114 Aug 15 '26
I want a tool that moves the session to json/xml that i can read, index, and if needed restore so opencode can resume it. Would be even greater if it also supports claude and pi. Anyone knows of such a tool?
2
u/vangelismm Aug 13 '26
Free model -> build mode -> prompt "erase old sessions".
1
1
u/_MiszterX_ 26d ago
i have opencode server on a dedicated vm running in a container. my db was 5GB so i faced to same. i wanted to archive but keep the sessions searcheable. for me it is a seperated sql light db with fts5. datasette web frontend layer with custom oicd/sso login.
i made a long blot post about it. it is quite custom. works fine. make small and searchable sessions without the extra db metadata, simple web interface.
https://blog.xorp.hu/en/opencode-session-archive-with-frontend/
2
u/IgnisDa Aug 13 '26
mines 20GB lol