The short answer
- 01
Careful. ~/.codex (or CODEX_HOME) is Codex's local state: config, sign-in, history, sessions and logs.
- 02
Never delete config.toml or auth.json. They are your settings and, with file-based storage, your sign-in.
- 03
Old sessions can go, but a deleted session can no longer be reopened with codex resume.
- 04
Sessions grow without a limit you can set; history.jsonl has one, history.max_bytes in config.toml.
- 05
Check first: du -sh ~/.codex/* shows which part holds the space.
See its real size on your Mac. Hoardless measures this folder and previews the delete.Download free trial
What is the ~/.codex folder?
It is OpenAI Codex's local state folder. OpenAI's docs say Codex stores its local state under CODEX_HOME, which defaults to ~/.codex, and list what you may see there:
config.toml: your local configuration.auth.json: sign-in, if you use file-based credential storage. Otherwise credentials can live in the keychain.history.jsonl: session history, if history persistence is on.- Logs and caches, which the docs mention without naming.
Two more parts matter for disk space. sessions holds one JSONL rollout file per session in dated folders; OpenAI's Codex SDK readme says threads are persisted in ~/.codex/sessions. Hoardless also finds Codex's logs there: a log folder and logs_*.sqlite databases at the top level.
What writes it and why does it grow?
Every Codex session writes a rollout file with the conversation and tool activity, so codex resume can reopen a saved chat later. Nothing in the docs expires old sessions.
- history.jsonl has a cap you can set:
history.max_bytesmakes Codex drop the oldest entries when the file goes over it. - Sessions and logs have no documented retention setting, so they keep growing.
How big does it get?
It follows how much you use Codex; there is no normal size. See where the space is:
du -sh ~/.codex/* | sort -h
Lists every part of the folder, largest last. Removes nothing. If you set CODEX_HOME, measure that folder instead.
du -sh ~/.codex/sessions/*/*
Shows session data per month, so you can see how much is old.
Is it safe to delete ~/.codex?
| What | Verdict | What you lose |
|---|---|---|
Old files in log | Safe | Old log history. Codex starts new logs. |
logs_*.sqlite, with Codex closed | Safe | Codex's diagnostic log history. |
Old session files in sessions | Careful | Those sessions can no longer be reopened with codex resume. |
history.jsonl | Careful | Your saved prompt history. |
config.toml, auth.json | Never | Your settings and sign-in. |
| The whole folder | Never | Configuration, sign-in and every session. |
How do I clean up ~/.codex?
Use Codex's settings for history. In ~/.codex/config.toml, a [history] table with max_bytes caps history.jsonl, and persistence = "none" turns it off.
Codex has no documented command to delete old sessions, so the manual way is to quit Codex and remove old dated folders yourself:
rm -rf ~/.codex/sessions/2025
Deletes every session from 2025 permanently, without the Trash. Pick a year or month folder from the du list above.
What Hoardless does: its Codex detector reads CODEX_HOME, else ~/.codex. It lists session files older than 30 days as one Confirm row, and always keeps the 20 newest sessions whatever their age. A logs_*.sqlite database over 500 MB, with its -wal and -shm files, is a Confirm row listed only while no Codex process is running. Files in log older than 30 days are an Auto row. It never touches config.toml, auth.json, history.jsonl, the other .sqlite state databases or the worktrees folder. Everything goes to the Trash with an undo log.
What comes back and when?
Your next session writes a new rollout and new log entries, so the folder starts growing again. Deleted sessions never come back. After a log database or old logs are removed, Codex starts new logs.
Old Codex sessions, newest always kept
Hoardless lists Codex sessions older than 30 days (Confirm tier, the 20 newest always stay), oversized log databases while Codex is closed (Confirm) and old logs (Auto), never config or sign-in, and moves them to the Trash with an undo log.
14-day full trial. macOS 14 or later.
Questions
Where does Codex store its data on a Mac?
Under CODEX_HOME, which defaults to ~/.codex. OpenAI's docs list config.toml, auth.json when you use file-based credential storage, and history.jsonl when history persistence is on.
Where are Codex session transcripts?
In ~/.codex/sessions, as JSONL rollout files in year, month and day folders. OpenAI's TypeScript SDK docs say threads are persisted in ~/.codex/sessions.
Can I stop Codex from saving history?
Yes. Set persistence = "none" in a [history] table in config.toml. To cap the file instead, set history.max_bytes; Codex then drops the oldest entries.
Will deleting ~/.codex sign me out?
If you use file-based credential storage, yes, because auth.json goes with it. Otherwise Codex may keep credentials in the macOS keychain.
New guides by email
New guides and Hoardless releases, twice a month at most.
Confirm first. Unsubscribe in one click. Privacy.