A lightweight, cross-platform utility script to safely clear chat history, wipe prompt drafts, truncate log files, and optimize the local SQLite database of the OpenCode desktop application.
It automatically shrinks the local database size (often from gigabytes down to a few kilobytes) using SQLite's VACUUM process.
- App Shutdown: Gracefully terminates OpenCode before starting the cleanup process.
- Database Optimization: Clears all message/session tables and executes SQLite
VACUUMto free up disk space. - Cache Clean: Wipes prompt history, drafts, scroll positions, and notifications.
- Log Truncation: Empties application log files to 0 bytes.
- Cross-Platform: Supports macOS, Windows, and Linux.
- Download
clear_opencode_history.pyandclear_opencode_history.commandto the same folder. - Double-click
clear_opencode_history.commandto execute.- Note: If macOS prevents execution, open Terminal and run
chmod +x clear_opencode_history.commandfirst.
- Note: If macOS prevents execution, open Terminal and run
- Make sure you have Python 3 installed on your system.
- Download
clear_opencode_history.pyandclear_opencode_history.batto the same folder. - Double-click
clear_opencode_history.batto execute.
This utility only deletes your chat sessions, message history, logs, and prompt caches. It preserves your custom settings, VCS configurations, and open project directories, so you won't lose your workspace preferences.