Codex Clean History
Quick Start
Use scripts/clean_codex_history.py to inspect or clean local Codex history artifacts. The script defaults to dry-run and preserves memory, configuration, authentication, rules, skills, plugins, cache, and goal/state databases.
python3 /path/to/codex-clean-history/scripts/clean_codex_history.py
python3 /path/to/codex-clean-history/scripts/clean_codex_history.py --apply
python3 /path/to/codex-clean-history/scripts/clean_codex_history.py --codex-home ~/.codex --days 30 --apply
Workflow
- Resolve Codex home from
--codex-home,$CODEX_HOME, or~/.codex. - Run the script without
--applyfirst and show the user the planned deletions. - If the user asked to actually clean, rerun with
--apply. - If the user asks to keep recent history, pass
--days Nto remove only matching artifacts older than N days. - If the user asks to include or exclude specific categories, use the script flags instead of manually deleting files.
Cleanup Scope
Default targets:
history.jsonlsessions/log/logs_*.sqlite, including-waland-shmsidecarsshell_snapshots/- temporary Codex files under
.tmp/andtmp/
Never target these by default:
memories/memories_*.sqlite, including sidecarsconfig.tomlauth.jsonrules/skills/plugins/cache/goals_*.sqlitestate_*.sqlitemodels_cache.jsoninstallation_idversion.json
Safety Rules
- Prefer the script over ad hoc
rmcommands. - Keep dry-run output in the response when the user asks what would be removed.
- Do not clean memories unless the user explicitly changes the requirement.
- If Codex is currently running, warn that open sessions may recreate log/session files after cleanup.